项目设置

图 5.30. 资源管理器属性页,Subversion 页面

资源管理器属性页,Subversion 页面


有时你可能想得到关于一个文件/目录的更多的细节信息而不仅是一个重载的标志。 你能得到Subversion的属性对话框中浏览到的所有信息。只需选择指定文件或目录,然后在文件菜单中选择Windows Menuproperties(注意: 这是浏览器提供的标准属性菜单,而不是TortoiseSVN 子菜单的其中之一)。在TortoiseSVN 属性对话框中已经为在Subversion控制下的文件/目录增加新的属性页。在这里你能看到所有的关于选择文件/目录的相关信息。

Subversion 属性

图 5.31. Subversion 属性页

Subversion 属性页


You can read and set the Subversion properties from the Windows properties dialog, but also from TortoiseSVNproperties and within TortoiseSVN's status lists, from Context menuproperties.

You can add your own properties, or some properties with a special meaning in Subversion. These begin with svn:. svn:externals is such a property; see how to handle externals in “引用的工程”一节.

svn:keywords

Subversion 支持类似 CVS 的关键字扩展,用来在文件中嵌入文件名称和版本信息。当前支持的关键字有:

$Date$

已知最后提交的日期。它基于你更新工作副本时获得的信息。它检查版本库查找最新的修改。

$Revision$

已知最后提交的版本。

$Author$

已知最后提交的作者。

$HeadURL$

此文件在版本库中的 URL。

$Id$

前述四个关键字的压缩组合。

To find out how to use these keywords, look at the svn:keywords section in the Subversion book, which gives a full description of these keywords and how to enable and use them.

For more information about properties in Subversion see the Special Properties.

Adding and Editing Properties

图 5.32. 增加属性

增加属性


为了增加新属性,先单击增加...,从组合框中选择需要的属性名称,或者输入你自定义的名称,然后在下面的编辑框内输入取值。有多个取值的属性,例如忽略列表,肯呢个输入多行。单极确认将属性增加到属性列表。

如果你想一次性设置许多文件的属性,在资源管理器中选择文件/文件夹,然后选择上下文菜单属性

如果你想设置当前文件夹内的全部文件和文件夹,选中递归检查框。

一些属性,例如svn:needs-lock只能用于文件,所以它们在文件夹的属性下拉列表内不会出现。你仍旧可以递归的设置目录树中所有文件的属性,但是需要你自己输入属性名称。

如果你想编辑一个已有属性,在已有属性列表中选择它,然后单击编辑...即可。

如果你想删除已有属性,在已有属性列表中选择它,然后单击删除即可。

属性svn:externals可以用来下载位于同一版本库或不同版本库的其它工程。阅读“引用的工程”一节以获得更多信息。

Exporting and Importing Properties

Often you will find yourself applying the same set of properties many times, for example bugtraq:logregex. To simplify the process of copying properties from one project to another, you can use the Export/Import feature.

From the file or folder where the properties are already set, use TortoiseSVNproperties, select the properties you wish to export and click on Export.... You will be prompted for a filename where the property names and values will be saved.

From the folder(s) where you wish to apply these properties, use TortoiseSVNproperties and click on Import.... You will be prompted for a filename to import from, so navigate to the place you saved the export file previously and select it. The properties will be added to the folders non-recursively.

If you want to add properties to a tree recursively, follow the steps above, then in the property dialog select each property in turn, click on Edit..., check the Apply property recursively box and click on OK.

The Import file format is binary and proprietary to TortoiseSVN. Its only purpose is to transfer properties using Import and Export, so there is no need to edit these files.

二进制属性

TortoiseSVN可以处理文件的二进制属性。使用保存...到文件读取二进制属性值。使用十六进制编辑器或其它适当的工具创建文件,然后用从文件加载...设置二进制值为此文件的内容。

尽管二进制文件不经常使用,它们在一些程序中是有用的。举例来说,如果你存储了巨大的图形文件,或者用程序加载的文件巨大,你可能想将缩略图作为属性存储,于是你可以快速的预览。

提交属性

Subversion 属性是受版本控制的。在你改变或增加属性后必须提交。

属性冲突

如果因为其他用户已经提交了同样的属性,提交时出现冲突,Subversion 会产生一个 .prej 文件。在你解决冲突后,请删除此文件。

自动属性设置

你可以设置当文件和文件夹加入版本库时,自动设置属性。阅读“TortoiseSVN的设置”一节以获得更多信息。

TortoiseSVN 项目属性

TortoiseSVN 有自己专用的几个属性,它们都有tsvn:前缀。

  • tsvn:logminsize设置提交日志的最小长度。如果你输入的日志短于预设值,提交会被禁止。这个属性对于提醒你为每次提交提供一个适当的描述信息非常有用。如果不设置这个属性,或者设置为0,那么就允许空提交信息。

    tsvn:lockmsgminsize设置锁定日志的最小长度。如果你输入的日志短于预设值,加锁会被禁止。这个属性对于提醒你为每次加锁提供一个适当的描述信息非常有用。如果不设置这个属性,或者设置为0,那么就允许空加锁信息。

  • tsvn:logwidthmarker用在要求日志信息被格式化为在最大宽度(典型是80字符)处换行非常有用。设置此属性为大于0的值会在日志消息对话框中做两件事: 放置一个标记指示最大宽度,和禁止自动换行,于是你可以看到输入的信息是否太长。注意: 这个特性仅在你选择的消息使用固定宽度字体时才能正确工作。

  • tsvn:logtemplate在需要定义日志消息格式化规则的工程中使用。在你开始提交时,这个属性的多行消息会被插入日志消息编辑框。你可以编辑它以便包含需要的信息。注意: 如果你使用了tsvn:logminsize属性,请确认这个长度大于模版的长度,不然就会失去其保护作用。

  • Subversion allows you to set “autoprops” which will be applied to newly added or imported files, based on the file extension. This depends on every client having set appropriate autoprops in their subversion configuration file. tsvn:autoprops can be set on folders and these will be merged with the user's local autoprops when importing or adding files.

    如果本地 autoprops 与 tsvn:autoprops 冲突,项目设置优先(因为它们是针对此项目的)。

  • In the Commit dialog you have the option to paste in the list of changed files, including the status of each file (added, modified, etc). tsvn:logfilelistenglish defines whether the file status is inserted in English or in the localized language. If the property is not set, the default is true.

  • TortoiseSVN can use spell checker modules which are also used by OpenOffice and Mozilla. If you have those installed this property will determine which spell checker to use, i.e. in which language the log messages for your project should be written. tsvn:projectlanguage sets the language module the spell checking engine should use when you enter a log message. You can find the values for your language on this page: MSDN: Language Identifiers.

    你可以用十进制输入取值,如果用0x前缀的话,也可以用十六进制。例如英语(美国英语)可以输入0x0409或者1033

  • The property tsvn:logsummary is used to extract a portion of the log message which is then shown in the log dialog as the log message summary.

    The value of the tsvn:logsummary property must be set to a one line regex string which contains one regex group. Whatever matches that group is used as the summary.

    An example: \[SUMMARY\]:\s+(.*) Will catch everything after “[SUMMARY]” in the log message and use that as the summary.

  • 当你想增加新属性时,你可以从组合框的下拉列表选取,也可以输入你喜欢的任何属性名称。如果你的项目使用了自定义属性,并且想让这些属性出现在组合框的下拉列表中(避免输入时拼写错误),你可以使用tsvn:userfilepropertiestsvn:userdirproperties创建自定义属性列表。对目录应用这些属性,当你编辑其任何子项属性时,你自定义的属性将会在预定义属性名称列表中出现。

Some tsvn: properties require a true/false value. TortoiseSVN also understands yes as a synonym for true and no as a synonym for false.

TortoiseSVN can integrate with some bug tracking tools. This uses project properties that start with bugtraq:. Read “与 BUG 跟踪系统/问题跟踪集成”一节 for further information.

It can also integrate with some web-based repository browsers, using project properties that start with webviewer:. Read “与基于 WEB 的版本库浏览器集成”一节 for further information.

设置文件夹的项目属性

These special project properties must be set on folders for the system to work. When you commit a file or folder the properties are read from that folder. If the properties are not found there, TortoiseSVN will search upwards through the folder tree to find them until it comes to an unversioned folder, or the tree root (eg. C:\) is found. If you can be sure that each user checks out only from e.g trunk/ and not some sub-folder, then it is sufficient to set the properties on trunk/. If you can't be sure, you should set the properties recursively on each sub-folder. A property setting deeper in the project hierarchy overrides settings on higher levels (closer to trunk/).

For project properties only you can use the Recursive checkbox to set the property to all sub-folders in the hierarchy, without also setting it on all files.

当你使用 TortoiseSVN 增加新的目录时,任何父目录的项目属性都会被自动增加到子目录。

小心

Although TortoiseSVN's project properties are extremely useful, they only work with TortoiseSVN, and some will only work in newer versions of TortoiseSVN. If people working on your project use a variety of Subversion clients, or possibly have old versions of TortoiseSVN, you may want to use repository hooks to enforce project policies. project properties can only help to implement a policy, they cannot enforce it.