Using keyword substitution in Subversion

Posted by Mark Drew on code on January 11, 2008

Tagged under webdev,eclipse

When I previously used CVS, I was able to put in my code some keywords that I wanted to substitue, such as the checkin date, who had checked it in, which version it was etc.

I have had a hell of a time finding out how to do this in Subversion (SVN). Thanks to a link sent to me by Tom Chiverton, I managed to figure out how to do it via Eclipse.

First of, read the manual, especially the svn:keywords section.

So, lets say I want to put the following in my headers: Author: $Author$ Date: $Date$ Revision: $Revision$

So in CFEclipse/Eclipse enter that in a file and check it in to your repository, nothing happens right?

No changes to the file happen, we must first set the properties for that file (or group of files):

  1. Right click on your file and do Team -> Set Property

  2. Select the “svn:keywords” property from the drop down

  3. In the text area add (without the quotes) “Date Author Revision”

  4. Check in the file and reload when it asks if you want to reload the file (since SVN has changed it)

TADDA!!!

Your file should look like this now:

Author: $Author: mark.drew $ Date: $Date: 2008-01-11 15:03:22 +0000 (Fri, 11 Jan 2008) $ Revision: $Revision: 2076 $

</code>

I hope that helps!




comments powered by Disqus