Using keyword substitution in Subversion
January 11, 2008 ·
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 $
I hope that helps!
Tags: eclipse · webdev
6 responses
1 Randy // Sep 22, 2008 at 4:13 PM
That should allow you to the same thing from the command line.
2 Mark Drew // Sep 22, 2008 at 4:13 PM
MD
3 Rob Wilkerson // Sep 22, 2008 at 4:13 PM
4 Gavin Baumanis // Sep 22, 2008 at 4:14 PM
you don't need the leading Date:"
your example would go from;
Date: $Date$
to;
$Date$
5 Ben Burwick // Sep 22, 2008 at 4:14 PM
6 ck // Sep 22, 2008 at 4:14 PM
This prevents data that happens to look like a keyword from being ‘corrupted’.
Does SVN have an equivalent?