Manuals

第 6 章 SubWCRev 程序

目录

SubWCRev 命令行
关键字替换
关键字例子
COM 接口

SubWCRev是Windows的命令行工具,可以阅读Subversion工作副本的状态,可以在模版中随意执行关键字替换。这通常是构建过程的一部分,将工作副本信息结合到创建的对象当中。通常情况下,可能是用来将修订版本号存入关于窗口。

SubWCRev 命令行

SubWCRev reads the Subversion status of all files in a working copy, excluding externals by default. It records the highest commit revision number found, and the commit timestamp of that revision, it also records whether there are local modifications in the working copy, or mixed update revisions. The revision number, update revision range and modification status are displayed on stdout.

SubWCRev.exe is called from the command line or a script, and is controlled using the command line parameters.

SubWCRev WorkingCopyPath [SrcVersionFile DstVersionFile] [-nmdfe]
      

WorkingCopyPath是要检查的工作副本路径,你可以只对工作副本使用SubWCRev,而不是直接对版本库,这个路径可以是绝对路径,也可以是工作目录的相对路径。

如果你想让SubWCRev执行关键字替换,象版本库版本,地址等字段保存到文本文件,就需要提供一个模版文件SrcVersionFile,输出文件DstVersionFile就是模版替换之后的版本。

You can specify ignore patterns for SubWCRev to prevent specific files and paths from being considered. The patterns are read from a file named .subwcrevignore. The file is read from the specified path, and also from the working copy root. If the file does not exist, no files or paths are ignored. The .subwcrevignore file can contain multiple patterns, separated by newlines. The patterns are matched against the paths relative to the repository root and paths relative to the path of the .subwcrevignore file. For example, to ignore all files in the doc folder of the TortoiseSVN working copy, the .subwcrevignore would contain the following lines:

/trunk/doc
/trunk/doc/*

Or, assuming the .subwcrevignore file is in the working copy root which is checked out from trunk, using the patterns

doc
doc/*

is the same as the example above.

To ignore all images, the ignore patterns could be set like this:

*.png
*.jpg
*.ico
*.bmp

重要

忽视参数大小写敏感,就像Subversion一样

提示

To create a file with a starting dot in the Windows explorer, enter .subwcrevignore.. Note the trailing dot.

There are a number of optional switches which affect the way SubWCRev works. If you use more than one, they must be specified as a single group, e.g. -nm, not -n -m.

表 6.1. 列出可用的命令行开关

切换描述
-nIf this switch is given, SubWCRev will exit with ERRORLEVEL 7 if the working copy contains local modifications. This may be used to prevent building with uncommitted changes present.
-NIf this switch is given, SubWCRev will exit with ERRORLEVEL 11 if the working copy contains unversioned items that are not ignored.
-mIf this switch is given, SubWCRev will exit with ERRORLEVEL 8 if the working copy contains mixed revisions. This may be used to prevent building with a partially updated working copy.
-dIf this switch is given, SubWCRev will exit with ERRORLEVEL 9 if the destination file already exists.
-f如果给出这个开关,SubWCRev 就会包含文件夹的最后修改版本。默认行为是取得版本号时只考虑文件。
-eIf this switch is given, SubWCRev will examine directories which are included with svn:externals, but only if they are from the same repository. The default behaviour is to ignore externals.
-EIf this switch is given, same as -e, but it ignores the externals with explicit revisions, when the revision range inside of them is only the given explicit revision in the properties. So it doesn't lead to mixed revisions.
-x如果给出这个开关,SubWCRev 就会以十六进制输出修订版本号。
-X如果给出这个开关,SubWCRev 就会以十六进制输出修订版本号,并且加上 '0X' 前缀。
-FIf this switch is given, SubWCRev will ignore any .subwcrevignore files and include all files.
-qIf this switch is given, SubWCRev will perform the keyword substitution without showing working copy status on stdout.


如果没有错误,SubWCRev返回0。 但是如果发生错误,错误信息将写入stderr并显示在控制台中。 返回的错误代码是:

表 6.2. SubWCRev 错误代码列表

错误代码描述
1语法错误。 一个或多个命令行参数无效。
2未找到命令行上指定的文件或文件夹。
3输入文件无法打开,或目标文件无法创建。
4无法分配内存。 发生的可能原因如源文件太大等。
5源文件无法正确扫描。
6SVN错误:当SubWCRev尝试从工作副本中查找信息时,Subversion返回了一个错误。
7工作副本包含本地修改。需要-n切换。
8工作副本包含混合的版本。需要-m切换。
9输出文件已存在,需要-d切换。
10指定的路径不是工作副本或部分或其中之一。
11此工作副本中有未版本控制的文件或文件夹。这需要 -N 切换。


TortoiseSVN homepage