I’ve used CVS (Concurrent Versions System) for years, and really like the keyword substitution feature. It’s not hard to grok – when a file is committed to CVS, it is first scanned for words that should be replaced. Specifically, if a text file contains the following:
// File name: $HeadURL$ // Revision: $Revison$ // Last modified: $Date$ // Last modified by: $Author$ // // description of the following file...
Then after it is checked in with keyword substitution, it looks like this:
// File name: best-practices.php // Revision: 1.1 // Last modified: 2009-02-26 22:27 // Last modified by: mclark // // description of the following file...
Even better, I usually just use the single line version of “$Id$” that puts all the important information into a single line.
// $Id: best-practices.php 1619 2009-02-26 22:27 mclark $ // // description of the following file...
However keyword substitution is not activated by default from within Eclipse and its SVN module titled Subclipse. Eclipse is the best IDE (Integrated Development Environment) that I’ve ever used (but it won’t be explained here). These are the steps to activate the svn-keyword-substitution feature in Eclipse:
- Install Subclipse into your Eclipse application (you’ve probably already done this if you’re reading this post!)
- Right-mouse-click on your project folder, and choose Team => Set Property from the popup menu
- Enter the property name: svn:keywords
- Enter the text property: Author Date Id Revision HeadURL
- Click the Set property recursively checkbox
- OK
Now keywords are substituted when you commit a file in SVN, just like they were in CVS. Also, you can shorten Revision to Rev and HeadURL to URL.
Tags: cvs, eclipse, subversion
Matt Clark worked in academia, corporate research labs and several technology startup companies prior to GORGES. His expertise is software architecture, database development, and system administration. Matt brings GORGES over 25 years experience developing fast and robust software on a multitude of platforms and languages.



Is it possible to add this also for new files? I don’t want to do this for every new file…
Yes, if you follow these directions then it will work for ALL existing and new files. Note that the setting was applied at the topmost level in the project hierarchy.
Is there a means to state that the properties should only be set on *.java files, because I don’t want to use these keywords on other files.
I don’t think it is possible using set property because it doesn’t allow me to specify a file pattern.
It also doesn’t seem to work when adding *.java = … auto-prop to subversion config file.
Any advice ?
Thanks,
EDH
The answer is YES this can be applied just to *.java files. I see in the latest Eclipse that the menu item is now “Change ASCII/Binary Property”, and the first line says “Filter files by name”. I entered *.java, and only the java source files were listed.
Did I misunderstand your question, or does this help?
Where do you exactly see this option ? In which menu ?
Thanks, EDH
Thanks, this was very helpful.
Enable keywords substitution using Eclipse and Subversion (SVN)…
To enable keywords substitution as I usually have with the CVS, you just need to enable a svn properties on the Eclipse project configuration. These are the steps to activate the svn-keyword-substitution feature in Eclipse: Install …
Thank you !!! It helped me.
Hi,
how can I disable this in eclipse?
There’s no “remove property’ afaics.
Thanks
@Alex: I don’t know how to remove the property. However if you learn how, please post here to teach the rest of us!
Matt,
I followed your instructions here and applied them on eclipse under a directory structure. When I open a file i.e. a pom.xml I don’t see a description anywhere on the file as to who the Author is, Date, ID etc.
Thanks.
Matt
Thanks, this worked for me with Eclipse 3.6 and Subclipse 1.8.
I now have a comment in my java file showing, for example
* $LastChangedRevision: 905 $
* $LastChangedDate: 2012-04-24 14:14:33 -0500 (Tue, 24 Apr 2012) $
What I want though is to be able to use this as a string to generate a version number of the software package. Any suggestions?
Matt,
ignore this. It was trivial
set a Java parameter
public static final String SVN_REV= “$LastChangedRevision: $”;
and after each commit it gets updated