Enabling keyword expansion with subversion
Facts - Other software technologies
Wednesday, 24 March 2010 20:59

This page has been tested with subversion version 1.6.

Subversion can automatically update file contents with parameters such as the version number, the location in the repository and the date of last checkin. This feature is called keyword expansion or keyword substitution.

In order to enable keyword expansion first add the keywords in your file(s). In a java or C++ file you can add them as comments:

// $HeadURL$ $Revision$ $Date$ $Author$

These four keywords usually provide sufficient (debugging) information. If you are not interested in the full path of the file then you can just use the keyword Id:

// $Id$

The second step is enabling the keywords for expansion on the command line. You can use the subversion propset command with the -R option to do this recursively for all your files:

svn propset -R svn:keywords "HeadURL Revision Date Author Id" *

The last step is to commit your files.