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.

1 comment:

jayshao said...

You should be able to use autopropsets to set keywords. Some ugliness though:

1. It's controlled by local client config, which makes it less than ideal to enforce standard behavior

2. It's basically by file type. I don't think you can do it by something like repo path, so it's a one-size fits all.

Also, while I generally use keywords (since they make merging in vendor branches smoother) I had a number of issues with spurious line ending warnings when keywords were turned on -- have you seen anything like that?