Manuals

项目设置

Subversion 属性

图 4.35. Subversion 属性页

Subversion 属性页


你可以通过右键菜单属性从 Windows 属性对话框来读写 Subversion 属性,这样也能得到 TortoiseSVN 的状态列表。也可以从TortoiseSVN属性来读写 Subversion 属性。

你可以添加你自己定义的属性,或者一些在 Subversion 中有特殊含义的属性。这些属性以 svn: 开头。svn:externals 就是这一类型的属性; 关于如何引用外部条目,请参阅“外部条目”一节.

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.

更多的关于 Subversion 中属性的信息可以看Special Properties

增加和编辑属性

图 4.36. 增加属性

增加属性


要添加一个新的属性,先点击新建... 。从菜单中选择需要的属性名称,然后在特定的属性对话框内填写所需的信息。这些特定的属性对话框中详细描述“属性编辑器”一节

想添加没有自己的对话框的属性,从新建... 菜单中选择高级 。然后从组合框中选择已经存在的属性或者输入自定义的属性名称。

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

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

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

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

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

编辑最新修订版本的属性

因为属性是受版本控制的,因此您不能编辑以前修订版本的属性。如果您从日志对话框或库浏览器中的无头部修订版本来查看属性,您将会看到一个属性和值的列表,但没有编辑控件。

导出和导入属性

通常,你会发现你要设置同一组属性很多遍,例如 bugtraq:logregex。要想简单的完成从一个项目复制属性到另一个项目,你可以使用导出/导入特性。

在已经设置了属性的文件或文件上使用TortoiseSVN属性,选择你想要导出的属性并单击导出...。然后会提示你输入文件名,属性名和属性值会保存在此文件中。

在你想要应用这些属性的文件夹上使用TortoiseSVN属性并单击导入...。然后会提示你选择从哪个文件导入,找到之前你保存导出文件的地方并选中它。属性会添加到文件夹,不递归。

如果你想递归的添加属性到目录树,按照上述的步骤,然后在属性对话框依次选中每一个需要递归的属性,单击编辑...,选中递归应用该属性并单击确定

导入文件是二进制格式的,并且只被 TortoiseSVN 所使用。它唯一的用途是在导入和导出命令之间传递属性,所以不要编辑这些文件。

二进制属性

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

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

自动属性设置

你可以配置 Subversion 和 TortoiseSVN 在文件和文件夹添加到版本库时自动设置属性。这里有两种实现方法。

You can edit the Subversion configuration file to enable this feature on your client. The General page of TortoiseSVN's settings dialog has an edit button to take you there directly. The config file is a simple text file which controls some of Subversion's workings. You need to change two things: firstly in the section headed miscellany uncomment the line enable-auto-props = yes. Secondly you need to edit the section below to define which properties you want added to which file types. This method is a standard Subversion feature and works with any Subversion client. However it has to be defined on each client individually - there is no way to propagate these settings from the repository.

另一个办法是在文件夹上设置 tsvn:autoprops 属性,将会在下一节详细描述。这个方法仅对 TortoiseSVN 客户端有效,但是它可以在更新时应用于所有的工作副本。

As of Subversion 1.8, you can also set the property svn:auto-props on the root folder. The property value is automatically inherited by all child items.

无论您选择哪种方法,您应该注意 Auto-props 仅应用于本次被添加到工作副本的那些文件。Auto-props 将决不会更改已受版本控制的文件的属性。

如果你想确保所有的新文件设置了正确的属性,你应该设置版本库的 pre-commit 钩子脚本来拒绝那些没有设置必要属性的提交。

提交属性

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

属性冲突

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

TortoiseSVN 项目属性

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

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

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

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

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

    也会有一些可替代 tsvn:logtemplate 的操作特定模板以供使用。这些特定模板被设置后即可使用,但如果没有设置任何特定模板,则将会使用 tsvn:logtemplate

    这些操作特定模板是:

    • tsvn:logtemplatecommit 用于所有来自工作副本的提交。

    • tsvn:logtemplatebranch 用于在您创建分支/标记或直接在版本库浏览器中复制文件或文件夹时。

    • tsvn:logtemplateimport 用于导入。

    • tsvn:logtemplatedelete 用于直接在版本库浏览中删除项目时。

    • tsvn:logtemplatemove 用于在版本库浏览器中重命名或移动项目时。

    • tsvn:logtemplatemkdir 用于在版本库浏览中创建目录时。

    • tsvn:logtemplatepropset 用于在版本库浏览器中修改属性时。

    • tsvn:logtemplatelock 用于获取一个锁定。

  • 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. The format is the same as for Subversion autoprops, e.g. *.sh = svn:eol-style=native;svn:executable sets two properties on files with the .sh extension.

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

    As of Subversion 1.8, you should use the property svn:auto-props instead of tsvn:autoprops since this has the very same functionality but works with all svn clients and is not specific to TortoiseSVN.

  • 在提交对话框,你可以粘贴修改的文件列表,包含每个文件的状态(增加,修改等)。tsvn:logfilelistenglish定义了文件状态用英文插入,还是用本机语言插入。如果此属性没有设置,默认值是 true

  • TortoiseSVN can use a spell checker. On Windows 10, the spell checker of the OS is used. On earlier Windows versions, it 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

  • 属性 tsvn:logsummary 用于摘录日志的一部分,在日志对话框中显示为日志摘要。

    属性 tsvn:logsummary 的值必须设置为一行包含一个正则组的正则字符串。匹配于这个正则组的任何内容被当作摘要。

    例如: \[SUMMARY\]:\s+(.*) 将会抓取 [SUMMARY] 后面的所有内容并将其用作摘要。

  • 属性 tsvn:logrevregex 定义了一个正则表达式,它匹配日志消息中的对版本号的引文。它的用处是,在日志对话框中,将这样的版本号变成链接,当点击链接的时候滚动到这一版本(如果此版本已经显示在日志对话框中被显示出来,或者它在日志缓存中)或者打开一个新的日志对话框显示那个版本。

    正则表达式必须匹配整个引文,而不仅仅是版本号。版本号可以自动的从匹配的引文字符串中提取出来。

    如果这个属性没有设置,一个默认的正则表达式被用来链接版本引文。

  • There are several properties available to configure client-side hook scripts. Each property is for one specific hook script type.

    The available properties/hook-scripts are

    • tsvn:启动提交钩子
    • tsvn:提交之前钩子
    • tsvn:提交之后钩子
    • tsvn:启动更新钩子
    • tsvn:更新之前钩子
    • tsvn:更新之后钩子
    • tsvn:加锁之前钩子
    • tsvn:加锁之后钩子

    The parameters are the same as if you would configure the hook scripts in the settings dialog. See “客户端钩子脚本”一节 for the details.

    Since not every user has his or her working copy checked out at the same location with the same name, you can configure a script/tool to execute that resides in your working copy by specifying the URL in the repository instead, using %REPOROOT% as the part of the URL to the repository root. For example, if your hook script is in your working copy under contrib/hook-scripts/client-side/checkyear.js, you would specify the path to the script as %REPOROOT%/trunk/contrib/hook-scripts/client-side/checkyear.js. This way even if you move your repository to another server you do not have to adjust the hook script properties.

    Instead of %REPOROOT% you can also specify %REPOROOT+%. The + is used to insert any number of folder paths necessary to find the script. This is useful if you want to specify your script so that if you create a branch the script is still found even though the url of the working copy is now different. Using the example above, you would specify the path to the script as %REPOROOT+%/contrib/hook-scripts/client-side/checkyear.js.

    The following screenshot shows how the script to check for current copyright years in source file headers is configured for TortoiseSVN.

    图 4.37. 钩子脚本的属性对话框

    钩子脚本的属性对话框


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

    You can also specify whether a custom dialog is used to add/edit your property. TortoiseSVN offers four different dialog, depending on the type of your property.

    bool

    If your property can only have two states, e.g., true and false, then you can configure your property as a bool type.

    图 4.38. Property dialog boolean user types

    Property dialog boolean user types


    Specify your property like this:

    propertyname=bool;labeltext(YESVALUE;NOVALUE;Checkboxtext)

    the labeltext is the text shown in the dialog above the checkbox where you can explain the purpose and use of the property. The other parameters should be self explanatory.

    state

    If your property represents one of many possible states, e.g., yes, no, maybe, then you can configure your property as a state

    图 4.39. 属性对话框显示用户类型

    属性对话框显示用户类型
    属性对话框显示用户类型
    属性对话框显示用户类型


    property like this:

    propertyname=state;labeltext(DEFVAL;VAL1;TEXT1;VAL2;TEXT2;VAL3;TEXT3;...)

    The parameters are the same as for the bool property, with DEFVAL being the default value to be used if the property isn't set yet or has a value that's not configured.

    For up to three different values, the dialog shows up to three radio buttons. If there are more values configured, it uses a combo box from where the user can select the required state.

    singleline

    For properties that consist of one line of text, use the singleline property type:

    图 4.40. Property dialog single-line user types

    Property dialog single-line user types


    propertyname=singleline;labeltext(regex)

    the regex specifies a regular expression which is used to validate (match) the text the user entered. If the text does not match the regex, then the user is shown an error and the property isn't set.

    multiline

    For properties that consist of multiple lines of text, use the multiline property type:

    图 4.41. Property dialog multi-line user types

    Property dialog multi-line user types


    propertyname=multiline;labeltext(regex)

    the regex specifies a regular expression which is used to validate (match) the text the user entered. Don't forget to include the newline (\n) character in the regex!

    The screenshots above were made with the following tsvn:userdirproperties:

    my:boolprop=bool;This is a bool type property. Either check or uncheck it.(true;false;my bool prop)
    my:stateprop1=state;This is a state property. Select one of the two states.(true;true;true value;false;false value)
    my:stateprop2=state;This is a state property. Select one of the three states.(maybe;true;answer is correct;false;answer is wrong;maybe;not answered)
    my:stateprop3=state;Specify the day to set this property.(1;1;Monday;2;Tuesday;3;Wednesday;4;Thursday;5;Friday;6;Saturday;7;Sunday)
    my:singlelineprop=singleline;enter a small comment(.*)
    my:multilineprop=multiline;copy and paste a full chapter here(.*)
                

TortoiseSVN 可以与一些 BUG 跟踪工具集成。它使用 bugtraq: 开始的项目属性。阅读“与 BUG 跟踪系统/问题跟踪集成”一节以获得更多信息。

它也与一些基于 WEB 的版本库浏览器集成,使用 webviewer: 开始的项目属性。阅读“与基于 WEB 的版本库浏览器集成”一节以获得更多信息。

设置文件夹的项目属性

为了让系统更好的工作,某些特别的项目属性必须保存在 文件夹中。 当你使用了 TortoiseSVN 命令调用这些属性,属性值就从选中的文件夹读取出来。如果在文件夹中找不到属性值, TortoiseSVN 会沿着文件夹树一直向上搜索,直到出现未版本化的 文件夹或者到达根目录 (例如: C:\) 。 如果您可以肯定每个用户都是只从类似 trunk/的位置签出代码,而且没什么子目录, 那么只需要设置属性在 trunk/上就够了。 假如你并不确定,那就需要在每个子目录都设置属性。 如果你给每个目录设置了相同的属性但是不同的项目角色又要使用不同的值,那么从不同的目录签出的时候,会得到不同的结果。

对于tsvn:属性,例如 tsvn:bugtraq:webviewer:,你只能对于所有子文件夹使用递归复选框设置属性,不用将这些属性设置在文件上。

当你使用TortoiseSVN在工作副本中新建一个子目录, 上层目录的所有项目属性都会自动的被继承。.

限制使用代码库浏览器

远程获取项目属性是一项很耗时的操作,因此上面描述的某些功能查看工作副本时是没有问题的,但在浏览库的时候不一定会显示。

  • 当你使用版本库浏览器添加一个属性时,在预定义列表中只会提供标准的 svn: 属性。任何其他的属性名称都必须手动输入。

  • 属性不能设置或删除递归使用回购浏览器。

  • 当使用版本库浏览器添加一个新的子文件夹时,项目属性将 不会 被自动传递到子文件夹。

  • 当使用版本库浏览器添加文件时,tsvn:autoprops不会 给这些添加的文件设定属性。

小心

尽管 TortoiseSVN 的项目属性很有用,但它们只适用于 TortoiseSVN,而且一些只是对于新版本的 TortoiseSVN 才生效。如果你的项目中的人使用各种 Subversion 客户端,或者使用低版本的 TortoiseSVN,你可能要使用版本库钩子强制执行项目策略。项目属性只能帮助你实现策略,不能强制执行。

属性编辑器

有些属性必须使用特定的值或以某种特定的方式进行格式化,以便能被自动使用。为了帮助正确地进行格式化,TortoiseSVN 为某些显示可能值或将属性分解给它的单独组件的特殊属性提供了编辑对话框。

外部条目

图 4.42. svn:externals 属性页

svn:externals 属性页


svn:外部 属性可用于从同一版本库或一个如 “外部条目”一节 所述的完全不同的版本库中引入其他项目。

You need to define the name of the sub-folder that the external folder is checked out as, and the Subversion URL of the external item. You can check out an external at its HEAD revision, so when the external item changes in the repository, your working copy will receive those changes on update. However, if you want the external to reference a particular stable point then you can specify the specific revision to use. IN this case you may also want to specify the same revision as a peg revision. If the external item is renamed at some point in the future then Subversion will not be able to update this item in your working copy. By specifying a peg revision you tell Subversion to look for an item that had that name at the peg revision rather than at HEAD.

The button Find HEAD-Revision fetches the HEAD revision of every external URL and shows that HEAD revision in the rightmost column. After the HEAD revision is known, a simple right click on an external gives you the command to peg the selected externals to their explicit HEAD revision. In case the HEAD revision is not known yet, the right click command will fetch the HEAD revision first.

SVN 关键字

图 4.43. svn:keywords 属性页

svn:keywords 属性页


选择你想要在文件中被扩展的关键字。

EOL 样式

图 4.44. svn:eol-style 属性页

svn:eol-style 属性页


选择您想使用的并且 TortoiseSVN 会使用正确属性值的行结束样式。

问题跟踪器集成

图 4.45. tsvn:bugtraq 属性页

tsvn:bugtraq 属性页


日志消息大小

图 4.46. 日志信息属性页的大小

日志信息属性页的大小


These 3 properties control the formatting of log messages. The first 2 disable the OK in the commit or lock dialogs until the message meets the minimum length. The border position shows a marker at the given column width as a guide for projects which have width limits on their log messages. Setting a value to zero will delete the property.

项目语言

图 4.47. 语言属性页

语言属性页


Choose the language to use for spell-checking log messages in the commit dialog. The file lists checkbox comes into effect when you right click in the log message pane and select Paste file list. By default the Subversion status will be shown in your local language. When this box is checked the status is always given in English, for projects which require English-only log messages.

MIME 类型

图 4.48. svn:mime-type 属性页

svn:mime-type 属性页


svn:needs-lock

图 4.49. svn:needs-lock 属性页

svn:needs-lock 属性页


此属性只是简单地控制一个文件是否要被检出为只读,如果没有在工作副本中锁定它。

svn:executable

图 4.50. svn:executable 属性页

svn:executable 属性页


该属性控制一个文件在 Unix/Linux 系统上检出时是否将被给予可执行状态。在 Windows 签出时则没有任何影响。

合并日志信息模板

Whenever revisions are merged into a working copy, TortoiseSVN generates a log message from all the merged revisions. Those are then available from the Recent Messages button in the commit dialog.

你可使用以下属性自定义生成的信息:

图 4.51. 合并日志信息模板属性对话框

合并日志信息模板属性对话框


tsvn:mergelogtemplatetitle, tsvn:mergelogtemplatereversetitle

This property specifies the first part of the generated log message. The following keywords can be used:

{revisions}

A comma separated list of the merged revisions, e.g., 3, 5, 6, 7

{revisionsr}

Like {revisions}, but with each revision preceded with an r, e.g., r3, r5, r6, r7

{revrange}

A comma separated list of the merged revisions, grouped into ranges if possible, e.g., 3, 5-7

{mergeurl}

The source URL of the merge, i.e., where the revisions are merged from.

The default value for this string is Merged revision(s) {revrange} from {mergeurl}: with a newline at the end.

tsvn:mergelogtemplatemsg

This property specifies how the text for each merged revision should look like. The following keywords can be used:

{msg}

The log message of the merged revision, as it was entered.

{msgoneline}

Like {msg}, but all newlines are replaced with a space, so that the whole log message appears on one single line.

{author}

合并修订版本号的作者

{rev}

The merged revision itself.

{bugids}

The bug IDs of the merged revision, if there are any.

tsvn:mergelogtemplatemsgtitlebottom

This property specifies the position of the title string specified with the tsvn:mergelogtemplatetitle or tsvn:mergelogtemplatereversetitle. If the property is set to yes or true, then the title string is appended at the bottom instead of the top.

重要

This only works if the merged revisions are already in the log cache. If you have disabled the log cache or not shown the log first before the merge, the generated message won't contain any information about the merged revisions.

TortoiseSVN homepage