目的
找 到SVN Server中的倉庫(Repositories)文件夾的位置,在相應的項目文件夾中找到hooks文件夾。在該文件夾中添加一個post- commit文件;當有commit動作發生時(提交到SVN Server時)就會執行這個post-commit文件,在該文件實現數據的復制、
步驟
1.找到svn服務器端某個項目倉庫目錄下(本例中服務端已新建一個test項目):
2.在hooks目錄下新建post-commit.bat 文件,內容如下:
@echo off
SET REPOS=%1
SET REV=%2
SET DIR=%REPOS%/hooks
SET PATH=%PATH%;
SET WORKING_COPY=E:/myweb //此處是你的項目路徑
svn update %WORKING_COPY% --username tianyl --password 111111 //輸入svn用戶名密碼
3.web目錄下一定要用TortoiseSVN checkout出Repositories的代碼
4..還有一個注意問題——Visual SVN Server的權限,否則可能會出現下列錯誤:
post-commit hook failed (exit code 1) with output:
svn: E155004: Working copy 'D:/www/Test' locked
svn: E200031: sqlite: attempt to write a readonly database
svn: E200031: sqlite: attempt to write a readonly database
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)
原因是Visual SVN Server服務的執行權限不夠,不能對指定目錄做讀寫操作。解決辦法,修改Visual SVN Server
簡單操作 windown下在運行中輸入 services.msc 找到visual svn server 服務 右鍵屬性 登陸面板 設置桌面交互或者管理員權限再試
如圖: