Reputation: 8556
I have a project into which I'd like to embed the revision number automagically.
In this case, it's a multi-file perl script. In the main file, I have a line that looks like this:
my $revision = '$Revision: 24 $';
When I make a release, I checkout the project to my release dir.
The revision number does change whenever I check-in a change to THAT FILE. The $Revision$ attribute is updated on check-in, but not check-out.
The thing is, the main file doesn't change that often, so even though the other files in the project are now at 27, the main still has 24.
Is there a way that I can get the main file to reflect the latest rev number? The one that svn prints out at the end of the checkout, ie "Checked out revision 27."
Upvotes: 2
Views: 255
Reputation: 412
It is similar to CVS, you can use $Revision$ you just have to set the keyword property for that file for SVN to know it is supposed to do a keyword replace.
From the manual:
"With no svn:keywords property set on that file, Subversion will do nothing special. Now, let's enable substitution of the LastChangedDate keyword. $ svn propset svn:keywords "Date Author" weather.txt property 'svn:keywords' set on 'weather.txt' $ "
http://svnbook.red-bean.com/en/1.5/svn-book.pdf
Upvotes: 2
Reputation: 120714
if (! -e '.version')
{
open VERSION, '>.version';
print VERSION `svnversion -n | cut -f1 -d:`;
close VERSION;
}
my $revision = '$Revision: ' . `cat .version` . ' $';
(Note: a puppy will die if you use this code as-is)
Upvotes: 0