思路:
找 到SVN Server中的倉庫(Repositories)文件夾的位置,在相應的項目文件夾中找到hooks文件夾。在該文件夾中添加一個post- commit文件;當有commit動做發生時(提交到SVN Server時)就會執行這個post-commit文件,在該文件實現數據的複製。 php
實際:html
今天測試了半天,一直說subversion is too old 讓升級,後來就升級了TortoiseSVN到1.8發現仍是有問題,最後卸了裝裝了卸,終於弄明白了,就是TortoiseSVN 要和 VisualSVN 中subversion的版本一直,目前用的是VisualSVN-Server-2.5.20 和 TortoiseSVN-1.7.10.23359-win32-svn-1.7.7 ,就能完美運行了!目前軟件在百度雲的 /軟件/svn中web
之後可能用到的參考:sql
http://blog.csdn.net/wu407797466/article/details/7946269
http://subversion.apache.org/faq.html#working-copy-format-change
http://www.2cto.com/os/201303/192225.html
http://www.cnblogs.com/ttzhang/archive/2008/11/03/1325102.html
http://www.cnblogs.com/mr-amazing/p/3875044.htmlapache
實例:
環境:SVN Server與測試用的Web Server在同一臺Windows系統服務器上,SVN Server使用的是VisualSVN,Web Server使用的是Apache。項目的名稱爲test,客戶端使用TortoiseSVN。
首先在apache的www目錄下建立一個文件夾,進行checkout,輸入須要用戶名和密碼,將test項目取出到該文件夾中。
找到SVN Server的Repositories目錄,在Repositories/test/hooks文件夾中建立post-commit.bat,在其中寫入命令:
"C:\Program Files\VisualSVN Server\bin\svn.exe" update "D:\www\test" --quiet --username name --password pwd 服務器
(即執行svn update命令,請自行替換用戶名和密碼) svn
也能夠這樣寫post
@echo off SET REPOS=%1 SET USER=%2 SET SVN="E:/Program Files/VisualSVN Server/bin/svn.exe" SET DIR="E:/wamp2/www" (call %SVN% update %DIR% --username izaodao --password izaodao --non-interactive)
大功告成。
注:測試
1.web目錄下必定要用TortoiseSVN checkout出Repositories的代碼ui
2.
-username izaodao --password izaodao
izaodao替換爲登陸svn的用戶名和密碼
在使用中可能會遇到的錯誤排除 :
1.Error: svn: 解析「D:\www\test」出錯,或svn: E020024: Error resolving case of 'D:\www\test"',則有多是由於目標文件名以後多加了」\」
2.「D:\www\test"或Skipped 'd:\www\test',則多是由於沒有執行步驟提交更新處理文件 即上面提到的.bat文件,svn.exe不認識目標文件夾
3. Working copy 'D:\www\test' is too old,則可能須要使用sven.exe upgrade命令從新整理一下目標文件夾 或者從新安裝一個較高客戶端版本至少要2.6以上吧
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
簡單操做 win+R 運行 services.msc 找到visual svn server 服務 右鍵屬性 登錄面板 設置桌面交互或者管理員權限再試
源地址:http://www.cnblogs.com/xiezhengcai/archive/2013/11/27/3445457.html
參考:http://www.2cto.com/os/201303/192225.html
http://www.php100.com/html/webkaifa/PHP/PHPyingyong/2009/0709/3066.html
http://blog.sina.com.cn/s/blog_418bef9d0100rqmx.html