附录 D. TortoiseSVN 操作

目录

TortoiseSVN 命令
TortoiseIDiff Commands

因为所有的命令使用命令行参数控制,你可以使用特定的批处理脚本或从其它程序(例如你喜欢的文本编辑器)启动。

重要

请记住TortoiseSVN是一个GUI客户端,这个自动化指导为你展示了让TortoiseSVN对话框显示并收集客户输入,如果你希望编写不需要输入的脚本,你应该使用官方的Subversion命令行客户端。

TortoiseSVN 命令

TortoiseSVN的GUI程序叫做TortoiseProc.exe。所有的命令通过参数/command:abcd指定,其中abcd是必须的命令名。大多数此类命令至少需要一个路径参数,使用/path:"some\path"指定。在下面的命令表格中,命令引用的是/command:abcd参数,余下的代表了/path:"some\path"参数。

因为一些命令需要一个目标路径的列表(例如提交一些特定的文件),/path参数可以接收多个路径,使用*分割。

TortoiseSVN 使用临时文件在 shell 扩展和主程序之间传递多个参数。从 TortoiseSVN 1.5.0 开始,废弃/notempfile参数,不再需要增加此参数。

The progress dialog which is used for commits, updates and many more commands usually stays open after the command has finished until the user presses the OK button. This can be changed by checking the corresponding option in the settings dialog. But using that setting will close the progress dialog, no matter if you start the command from your batch file or from the TortoiseSVN context menu.

To specify a different location of the configuration file, use the parameter /configdir:"path\to\config\directory". This will override the default path, including any registry setting.

如果想在进度对话框执行完毕后自动关闭,而又不必设置永久性的参数,可以传递/closeonend参数。

  • /closeonend:0 不自动关闭对话框

  • /closeonend:1 如果没发生错误则自动关闭对话框

  • /closeonend:2 如果没发生错误和冲突则自动关闭对话框

  • /closeonend:3如果没有错误、冲突和合并,会自动关闭

  • /closeonend:4如果没有错误、冲突和合并,会自动关闭

下面的列表列出了所有可以使用TortoiseProc.exe访问的命令,就像上面的描述,必须使用/command:abcd的形式,在列表中,因为节省空间的关系省略了/command的前缀。

表 D.1. 有效命令及选项列表

命令描述
:aboutShows the about dialog. This is also shown if no command is given.
日志Opens the log dialog. The /path specifies the file or folder for which the log should be shown. Three additional options can be set: /startrev:xxx, /endrev:xxx and /strict
检出打开检出对话框,/path指定了目标路径,而/url制定了检出的URL。
导入Opens the import dialog. The /path specifies the directory with the data to import.
更新将工作副本的/path更新到HEAD,如果给定参数/rev,就会弹出一个对话框询问用户需要更新到哪个修订版本。为了防止指定修订版本号/rev:1234的对话框,需要选项/nonrecursive/ignoreexternals
提交Opens the commit dialog. The /path specifies the target directory or the list of files to commit. You can also specify the /logmsg switch to pass a predefined log message to the commit 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. To pre-fill the bug ID box (in case you've set up integration with bug trackers properly), you can use the /bugid:"the bug id here" to do that.
增加/path的文件添加到版本控制 。
恢复恢复工作副本的本地修改,/path说明恢复哪些条目。
清理清理中断和终止的操作,将工作副本的/path解锁。
解决/path指定文件的冲突标示为解决,如果给定/noquestion,解决不会向用户确认操作。
重新定位/path创建一个版本库。
切换Opens the switch dialog. The /path specifies the target directory.
导出Exports the working copy in /path to another directory. If the /path points to an unversioned directory, a dialog will ask for an URL to export to the directory in /path.
合并Opens the merge dialog. The /path specifies the target directory. Three additional options can be set: /mergefrom:xxx, /mergeto:xxx and /fromurl:URL. These pre-fill the relevant fields in the merge dialog.
:mergeallOpens the merge all dialog. The /path specifies the target directory.
复制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.
设置打开设置对话框。
删除从版本控制里移除/path中的文件。
改名重命名/path的文件,会在对话框中询问新文件,为了防止一个步骤中询问相似文件,传递/noquestion
比较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 unified is set), a dialog with a list of files that have changed or if the URLs point to files starts the diff viewer for those two files.

The options url1, url2, revision1 and revision2 must be specified. The options pegrevision, ignoreancestry, blame and unified are optional.

冲突打开TortoiseSVN设置的冲突工具,在/path中需要设置冲突文件的正确文件。
重新定位打开重定位对话框,/path指定了重定位的工作副本路径。
Windows 外壳打开帮助文件
状态Opens the check-for-modifications dialog. The /path specifies the working copy directory.
版本库浏览器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.
忽略Adds all targets in /path to the ignore list, i.e. adds the svn:ignore property to those files.
追溯

Opens the blame dialog for the file specified in /path.

If the options /startrev and /endrev are set, then the dialog asking for the blame range is not shown but the revision values of those options are used instead.

If the option /line:nnn is set, TortoiseBlame will open with the specified line number showing.

The options /ignoreeol, /ignorespaces and /ignoreallspaces are also supported.

:cat/path指定的工作副本或URL的文件保存到/savepath:path,修订版本号在/revision:xxx,这样可以得到特定修订版本的文件。
创建补丁创建/path下的补丁文件。
版本图显示/path目录下的版本变化图。
加锁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.
:unlockUnlocks a file or all files in a directory given in /path.
:rebuildiconcacheRebuilds 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.
属性显示 /path 给出的路径之属性对话框。


Examples (which should be entered on one line):

TortoiseProc.exe /command:commit
                 /path:"c:\svn_wc\file1.txt*c:\svn_wc\file2.txt"
                 /logmsg:"test log message" /closeonend:0

TortoiseProc.exe /command:update /path:"c:\svn_wc\" /closeonend:0

TortoiseProc.exe /command:log /path:"c:\svn_wc\file1.txt"
                 /startrev:50 /endrev:60 /closeonend:0