Subversion keywords on Java files
Subversion has the ability to substitute keywords—pieces of useful, dynamic information about a versioned file—into the contents of the file itself. The list of keywords available for substitution are:
- Date – describes the last time the file was known to have been changed in the repository.
- Revision – describes the last known revision in which this file changed in the repository.
- Author – describes the last known user to change this file in the repository.
- Id – is a compressed combination of the other keywords.
Now combine svn-keywords with JavaDoc of a Java Class. A tipically header template can be:
/** * CLASS DESCRIPTION * * @author Pasquale Marcoccia * @version $Revision$ on $Date$ by $Author$ */
or:
/** * CLASS DESCRIPTION * * @author Pasquale Marcoccia * @version $Id$ */
To tell Subversion whether or not to substitute keywords on a particular file, we can use propset subcommand. The svn:keywords property, when set on a versioned file, controls which keywords will be substituted on that file. The value is a space-delimited list of the keyword names.
svn propset svn:keywords "Date Revision Author Id" MyClass.java
We can set keywords on all java files in a directory:
find myProject/ -type f -name '*.java' -exec svn propset svn:keywords "Date Revision Author Id" {} \; -print
Instead, for files added later, we can automatically set keywords changing svn config file (~/.subversion/config):
[miscellany] enable-auto-props = yes [auto-props] *.java = svn:keywords=Date Revision Author Id
Buzz This Post
Delicious
Digg This Post
Ping This Post
Add comment 5 April 2009 at 11:10 AM