為了一句話:不要動手做機器能夠做的事情.
天天工作用svn,更新啥的打開目錄啥的動作天天在重復.每次寫些命令也蠻無聊的,不說了,看下面:
1 @echo off
2 rem 顯示部分
3 @echo 注 意 事 項
4 @echo ************************************************************************
5 @echo 可以精簡並通過計划任務來制定自動執行,運行前請檢查下面目錄:
6 @echo.
7 @echo 1.svn_bin 為安裝TortoiseSVN客戶端的可執行程序目錄
8 @echo 2.svn_work 為更新項目文件的目錄
9 @echo.
10 @echo WIN7或WINVista或WIN2008的用戶請用管理員身份運行
11 @echo ************************************************************************
12
13 rem 路徑變量,請在此處按實際修改,最后面不要帶斜杠
14 @set svn_bin=D:\Program Files\TortoiseSVN\bin
15 @set svn_work=E:\SVN
16
17 rem 判斷可執行文件及項目文件目錄是否正確
18 @if not exist "%svn_bin%\TortoiseProc.exe" (
19 echo.
20 echo error: 請確認TortoiseSVN客戶端目錄正確?
21 echo 目前定義的是:%svn_bin%
22 echo.
23 pause & exit 1
24 )
25 if not exist "%svn_work%\.svn" (
26 echo.
27 echo error: 請確認SVN項目文件目錄正確?
28 echo 目前定義的是:%svn_bin%
29 echo.
30 pause & exit 2
31 )
32
33 rem 顯示操作菜單
34 :menu
35 echo.
36 echo ☆☆☆請選擇數字后按回車☆☆☆
37 echo.
38 echo 1.SVN全目錄更新
39 echo.
40 echo 2.打開某某項目SVN(QA專用)
41 echo.
42 echo 3.打開某某項目網站SVN (QA專用)
43 echo.
44 echo 4.SVN全目錄日志
45 echo.
46 echo 0.退出
47 echo.
48 set choice=
49 set /p choice=請選擇對應數字輸入:
50 if not "%choice%"=="" choice=%choice:~0,1%
51 if /i "%choice%"=="1" goto start1
52 if /i "%choice%"=="2" goto start2
53 if /i "%choice%"=="3" goto start3
54 if /i "%choice%"=="4" goto start4
55 if /i "%choice%"=="0" goto exit
56 echo 選擇無效,請重新輸入...
57 echo.
58 goto :menu
59
60 :start1
61 cls
62 echo SVN目錄更新
63 echo.
64 rem 更新snv
65 "%svn_bin%"\TortoiseProc.exe/command:update /path:"%svn_work%" /notempfile /closeonend:4
66 echo 已完成,返回主菜單
67 goto :menu
68
69 :start2
70 cls
71 echo 打開SVN某某項目目錄
72 echo.
73 rem 打開某某項目,固定寫死
74 explorer /e,"%svn_work%\Testing\Videocomm"
75 goto :menu
76
77 :start3
78 cls
79 echo 打開SVN某某項目網站目錄
80 echo.
81 explorer /e,"%svn_work%\Testing\Trunk\"
82 goto :menu
83
84 :start4
85 cls
86 echo 打開SVN全目錄日志
87 echo.
88 "%svn_bin%"\TortoiseProc.exe/command:log /path:"%svn_work%" /notempfile /closeonend:0
89 goto :menu
這中間是隨便寫了幾個操作,可根據實際需要自行增減,代碼行應該可以精簡,哪位同學閑來無事的可以試試
附svn的一些命令行說明
命令 | 描述 |
---|---|
:about | 顯示關於對話框。如果沒有給命令也會顯示。 |
:log | 打開日志對話框,/path 指定了顯示日志的文件或目錄,另外還有三個選項可以設置: /startrev:xxx 、/endrev:xxx 和/strict |
:checkout | 打開檢出對話框,/path 指定了目標路徑,而/url 制定了檢出的URL。 |
:import | 打開導入對話框,/path 指定了數據導入路徑。 |
:update | 將工作副本的/path 更新到HEAD,如果給定參數/rev ,就會彈出一個對話框詢問用戶需要更新到哪個修訂版本。為了防止指定修訂版本號/rev:1234 的對話框,需要選項/nonrecursive 和/ignoreexternals 。 |
:commit | 打開提交對話框,/path 指定了目標路徑或需要提交的文件列表,你也可以使用參數 /logmsg 給提交窗口傳遞預定義的日志信息,或者你不希望將日志傳遞給命令行,你也可以使用 /logmsgfile:path ,path 指向了保存日志信息的文件。為了預先填入bug的ID(如果你設置了集成bug追蹤屬性),你可以使用/bugid:"the bug id here" 完成這個任務。 |
:add | 將/path 的文件添加到版本控制 。 |
:revert | 恢復工作副本的本地修改,/path 說明恢復哪些條目。 |
:cleanup | 清理中斷和終止的操作,將工作副本的/path 解鎖。 |
:resolve | 將/path 指定文件的沖突標示為解決,如果給定/noquestion ,解決不會向用戶確認操作。 |
:repocreate | 在/path 創建一個版本庫。 |
:switch | 打開選項對話框。/path 指定目標目錄。 |
:export | 將/path 的工作副本導出到另一個目錄,如果/path 指向另一個未版本控制目錄,對話框會詢問要導出到/path 的URL。 |
:merge | Opens the merge dialog. The /path specifies the target directory. For merging a revision range, the following options are available: /fromurl:URL , /revrange:string . For merging two repository trees, the following options are available: /fromurl:URL , /tourl:URL , /fromrev:xxx and /torev:xxx . These pre-fill the relevant fields in the merge dialog. |
:mergeall | Opens the merge all dialog. The /path specifies the target directory. |
:copy | Brings up the branch/tag dialog. The /path is the working copy to branch/tag from. And the /url is the target URL. You can also specify the /logmsg switch to pass a predefined log message to the branch/tag dialog. Or, if you don't want to pass the log message on the command line, use /logmsgfile:path , where path points to a file containing the log message. |
:settings | 打開設置對話框。 |
:remove | 從版本控制里移除/path 中的文件。 |
:rename | 重命名/path 的文件,會在對話框中詢問新文件,為了防止一個步驟中詢問相似文件,傳遞/noquestion 。 |
:diff | Starts the external diff program specified in the TortoiseSVN settings. The /path specifies the first file. If the option /path2 is set, then the diff program is started with those two files. If /path2 is omitted, then the diff is done between the file in /path and its BASE. To explicitly set the revision numbers use /startrev:xxx and /endrev:xxx . If /blame is set and /path2 is not set, then the diff is done by first blaming the files with the given revisions. |
:showcompare | Depending on the URLs and revisions to compare, this either shows a unified diff (if the option The options |
:conflicteditor | Starts the conflict editor specified in the TortoiseSVN settings with the correct files for the conflicted file in /path . |
:relocate | 打開重定位對話框,/path 指定了重定位的工作副本路徑。 |
:help | 打開幫助文件 |
:repostatus | 打開為修改檢出對話框,/path 指定了工作副本目錄。 |
:repobrowser | Starts the repository browser dialog, pointing to the URL of the working copy given in /path or /path points directly to an URL. An additional option /rev:xxx can be used to specify the revision which the repository browser should show. If the /rev:xxx is omitted, it defaults to HEAD. If /path points to an URL, the /projectpropertiespath:path/to/wc specifies the path from where to read and use the project properties. |
:ignore | 將/path 中的對象加入到忽略列表,也就是將這些文件添加到 svn:ignore 屬性。 |
:blame | 為 如果設置了 如果設置了 也支持 |
:cat | 將/path 指定的工作副本或URL的文件保存到/savepath:path ,修訂版本號在/revision:xxx ,這樣可以得到特定修訂版本的文件。 |
:createpatch | 創建/path 下的補丁文件。 |
:revisiongraph | 顯示/path 目錄下的版本變化圖。 |
:lock | Locks a file or all files in a directory given in /path . The 'lock' dialog is shown so the user can enter a comment for the lock. |
:unlock | Unlocks a file or all files in a directory given in /path . |
:rebuildiconcache | Rebuilds the windows icon cache. Only use this in case the windows icons are corrupted. A side effect of this (which can't be avoided) is that the icons on the desktop get rearranged. To suppress the message box, pass /noquestion . |
:properties | 顯示 /path 給出的路徑之屬性對話框。 |
另外:
1 如果想在進度對話框執行完畢后自動關閉,而又不必設置永久性的參數,可以傳遞/closeonend參數。
2 /closeonend:0 不自動關閉對話框
3 /closeonend:1 如果沒發生錯誤則自動關閉對話框
4 /closeonend:2 如果沒發生錯誤和沖突則自動關閉對話框
5 /closeonend:3如果沒有錯誤、沖突和合並,會自動關閉
6 /closeonend:4如果沒有錯誤、沖突和合並,會自動關閉
7 下面的列表列出了所有可以使用TortoiseProc.exe訪問的命令,就像上面的描述,必須使用/command:abcd的形式,在列表中,因為節省空間的關系省略了/command的前綴。
示例:
1 Examples (which should be entered on one line):
2 TortoiseProc.exe /command:commit
3 /path:"c:\svn_wc\file1.txt*c:\svn_wc\file2.txt"
4 /logmsg:"test log message" /closeonend:0
5
6 TortoiseProc.exe /command:update /path:"c:\svn_wc\" /closeonend:0
7
8 TortoiseProc.exe /command:log /path:"c:\svn_wc\file1.txt"
9 /startrev:50 /endrev:60 /closeonend:0
OK...