- 论坛徽章:
- 0
|
Subversion provides a flexible feature to set the properties for files in repository, which includes user customeed properties, keyword expansion, and SVN built-in properties. This paper will introduct how to set the properties for a file, and how to use these properties in development.
1. Customed Properties
SVN allows user set any property on a file in SVN repository with the command svn propset, as following example:
svn propset user_desc "Descriptions on this file" file
This command will add a property "user_desc" on the file, and you can check current properties set on the file:
svn proplist file
then you can get the property of the file:
svn propget user_desc file
To update the property, command svn propedit can help you implement it:
svn propedit user_desc file
Finally, you can remove the property from file using command svn propdel:
svn propdel user_desc file
And what I must reminder is that you should commit your property operation into the repository.
2. Keyword Expansion
Keyword expansion basically means getting your version control system to modify your working copy files as it checks them out and updates them so it can fill in useful information for you. Each of these useful pieces of information is represented by a keyword, ususally surrounded by dollar signs, which you put strategically inside the files you're storing in version constrol. Subversion offers the following keyword:
- $LastChangedDate$
- $LastChangedRevision$
- $LastChangedBy$
- $HeadURL$
- $Id$
To switch on keyword expansion, you need to set svn:keywords on each file containing keywords.
3. Built-in Properties
Subversion provides some built-in properties for user to control the stored file. This paper just introduces some common properties used in development.
1) Ignore Certain Files
In development, some meta files are often created automatically, such as .o files for the .c/cpp files. When we use svn stat to check what have been modified in the project, these meta files will be shown as the symbol "?". To ignore these certain file in the result, we should set the property svn:ignore for specified directory with the specified file postfix as following:.
*.o
*.pyc
2) Setting End-of-Line Style
As we know, the carriage-return will use different control characters to denote the end of a line of text in different system, just like Windows using CRLF, while Linux using LF.
Subversion can do a conversion for you if you set svn:eol-style property to one of the values in the following table:
native
Subversion will translate end-of-line characters to
whatever the client operating system expects, and so
will use CRLF on Windows and LF on Unix.
CRLF
Subversion will always use CRLF as an end-of-line
marker when it creates files in the working copy.
LF
Subversion will always use LF as an end-of-line
marker on the client.
CR
Subversion will always use CR as an end-of-line
marker on the client.
3) Executable Flag
In Unix like system, we often need to set the executable flag for certain files, such as shell script files. Subversion will not set the execute bit automatically when you check in these files. Command svn:executable will help you set the execute bit on the specified files.
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/48729/showart_463723.html |
|