Wednesday, February 27, 2008

Subversion Keywords

I finally got around to putting in SVN keywords in some of the files for the Evaluation System project. It took me a little while to figure this out but they don't start working automatically. You have to take the extra step of telling Subversion (via properties) that you want it to actually do the keyword substitution. Luckily the steps are pretty easy once you figure it out.

1) Add some keywords to your files like so:
$Id$
$URL$

2) Run this command from the base directory of your project (this will add all the keywords, just remove the ones you don't want from the string):
svn propset -R svn:keywords "Date Revision Author URL Id" .
3) Commit the code (this will take awhile because it is going to commit a new revision of every file in your project). The keywords will be replaced and look more like this:
$Id: EvalConstants.java 46025 2008-02-27 13:01:48Z aaronz@vt.edu $
$URL: https://source.sakaiproject.org/contrib/evaluation/trunk/$


Disappointingly this will not work for all files going forward so you will have to reapply this for new files or just do the whole set every once in awhile.