Automatic locking of ankhsvn

Source: Internet
Author: User
Reposted belowArticle. When "[auto-Props]" is configured, Files Added to SVN are automatically locked. In the ankhsvn plug-in, the lock icon in front of the file is displayed, which is similar to VSS.Note: files that have been added to SVN do not automatically have the lock attribute and need to be added again. Or if you are not afraid of trouble, manually add the svn attributes of files one by one, such The following figure shows the configuration according to the following document.Useful subversion configurations
 

Source: subversion.org.cn

 

This section describes other functions that may be used by the configuration administrator and advanced users:

1. Use the "Lock-edit-unlock" Model

2. Automated attributes

3. Ignore files

4. Keyword replacement

5. External Definition

1. Use the "Lock-edit-unlock" Model

Subversion uses a working model similar to CVS, that is, "copy-Modify-merge", but sometimes it is necessary to use the "Lock-edit-unlock" model, such as for binary files, or other files that are not suitable for merging.

Attribute is also called metadata in "using subversion for Version Control". It is an attribute attached to a file under version control, just as the last modification date is the attribute of a file, you can set custom attributes for files and directories under subversion control. For more information about properties, see http://www.subversion.org.cn/svnbook/1.2/svn.advanced.locking.html#svn.advanced.locking.lock-communication.

In the subversion, the built-in attribute "SVN: needs-locks are used to lock the locks-edit-Unlock model. For example, we have a wordfile example. Doc". It is clear that Word files are in binary format (XML files are said to be used in the future, but they may not be merged ), it is impossible to use the "copy-Modify-merge" model, so we need to use the "Lock-edit-unlock" model. You can set the attribute "SVN: Needs-lock" and submit the file. When others update the file, they will get a read-only file, to modify this file, they must first obtain the lock. The lock process will set the file to writable, and others will find that they cannot get the lock at this time, only those who get the lock give up the lock can get the lock and continue to work. The following describes how to use SVN command line and tortoisesvn to set and use locks.

1) set the "SVN: Needs-lock" attribute

Use the command line to lock. Doc ":

SVN propset SVN: Needs-lock 'X' introduction .doc

After running this command, the "SVN: Needs-lock" has already been set for ".doc", but to make it take effect, Run "SVN commit ", later, other users will find that the file is read-only. Note that the attribute value we set is "X". In fact, any value is acceptable. The Subversion ignores its content.

Setting attributes using tortoisesvn is also easy:

".Doc ", right-click and select-> properties-> subversion option folder-> properties-> Add, and select" SVN: Needs-lock "for the property name in the pop-up window. The value is arbitrary, then select OK. Later, I will submit the document "Introduction .doc.

2) Get the lock

After setting this rule, you must first obtain the lock and use the command line as follows:

SVN lock introduction .doc

In this example, "Introduction .doc" is changed to a writable file, and you can edit and modify it. In this case, if someone expects to get the lock of this file like you, they will get an error message, indicates that the file has been locked.

Using tortoisesvnis still simple, ".doc "right-click and select-> tortoisesvn-> get lock..., then enter the locked comment and select" OK "to complete the lock.

3) release the lock

After you complete the modification and select submit, the lock will be released by default, and others will be able to obtain the lock again. You can also discard the modification and choose to release the lock as follows:

SVN unlock introduction .doc

In this example, ".doc" is changed to read-only, and others can get the lock and modify it.

To use tortoisesvn, right-click "Introduction .doc" and choose "tortoisesvn"> "Release lock". Then, select "OK.

2. Automated attributes

Some people in the forum once asked how to implement the previous question, and then asked how to deal with such settings if there are many files. In this case, you may need the automatic attribute function to set certain attributes for a certain type of files by matching the file name. Take Word documents as an example to set all Word documents to read-only.

Here we use the running configuration area feature of subversion. Many global configuration parameters of subversion are stored in the running configuration area. The running configuration area is actually a directory, in my XP operating system, the directory is "C: \ Documents ents and Settings \ rock \ Application Data \ subversion", where rock is my user name, in UNIX, this directory may be ". subversion ". In this directory, the config file is some properties of client operations, while the servers file is the server-side attribute. We need to use the config file for this part.

Open the config file in the running configuration area and remove the "#" andSpaceIn the "[auto-Props]" section, add the following attributes and save them to automatically add the attributes to be locked to the Word file:

*. Doc = SVN: Needs-lock = x

After this setting is made, you can use "SVN Add" and "SVN import" to add *. the doc file will all have the "SVN: Needs-lock" attribute. If you want to, you can also change the above value to "* = SVN: Needs-lock = x ", in this way, all newly added files enter the "Lock-edit-unlock" model.

Note that these settings are for the client, and other users need to make the same settings.

3. Ignore files

When executing SVN status and other operations, we do not want to see some files, we need to use the setting attribute to ignore them. There are two ways to set subversion. One is to change the global settings, that is, the config file mentioned above, and the other is to use the svn built-in attribute "SVN: Ignore ".

1) Use config's global-ignores Configuration

Assume that ourProgramMany EXE files will be compiled. If the ignore attribute is not used, the results will look like this when we execute "SVN status:

? Admin \ test.exe

M admin \ test.txt

To prevent the EXE file from disturbing us, we only need to find the [miscellany] section of the config file, modify global-ignores, and add the ignore of the exe. The modified line becomes:

Global-ignores = *. O *. Lo *. La # * #. *. rej *. rej .*~ *~ . # *. Ds_store *. exe

Run "SVN status" and the result is as follows:

M admin \ test.txt

2) use the svn built-in attribute "SVN: Ignore"

Sometimes the matching is not so common. For example, a Java project will generate many temporary jar files in the bin directory. We only need. jar, instead of temp. jar affects our line of sight, so we only need to set the bin attribute "SVN: Ignore" to temp. jar. The specific settings are the same as above.

For more information about ignoring, see: http://www.subversion.org.cn/svnbook/1.2/svn.advanced.props.html#svn.advanced.props.special.ignore

4. Keyword replacement

A useful function in CVS is to replace some keywords in the source file, such as the submission time and author. By default, subversion does not process such keywords. You need to set some attributes to achieve this.

For example, to automatically add the name of the last modifier and the submission time on the header of a source file, we first set the attribute SVN: keywords to "Date Author" for this file ", then, add the following field where the author and the submission time need to be added to the file:

$ Lastchangeddate $
$ Author $

After the file is submitted, the corresponding characters are as follows:

$ Lastchangeddate: November 20 22:58:16 + 0800 (Wednesday, 29 August 06) $
$ Author: root $

There is also a problem where the Subversion always replaces text with a UTF-8 and the file must be encoded with a UTF-8. If our file encoding is GBK, And the date display format is the Chinese character format above, the obtained time will be garbled. At present, the most practical solution is that all files use UTF-8 encoding; or try to make the data appear no Chinese characters, such as for the path is to use English, for the region option for time in English (I adjusted the Chinese format but it is invalid ).

This part of the problem can also be implemented through attributes, but the source program needs to be modified and may not be implemented immediately.

For more keywords, see:

Http://www.subversion.org.cn/svnbook/1.2/svn.advanced.props.html#svn.advanced.props.special.keywords

5. External Definition

This feature is also a frequently asked question in the Forum, that is, many people want to have the share feature of VSS, that is, a file has images and modifications in one place in multiple locations of the version library, all other locations can be seen.

Subversion can share directories through external definitions (SVN: externals). However, for files, subversion can only support links in Unix-like environments, this part of the content "using subversion for Version Control" has been clearly stated, so you can read it directly:

Http://www.subversion.org.cn/svnbook/1.2/svn.advanced.externals.html

Software Configuration Management has commented on the "share" function, which is not a good Software Configuration Management habit. If a file can be shared, it also means that this file can become an independent module and needs to be re-planned.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.