After having read a bit more about the various subversion properties I decided
to use the
svn:keywords property to solve my problem: inserting
automatically a timestamp in program code I publish on my website. Until recently,
the Perl program that generates (almost) all pages on this site read the timestamp
from the source code files it includes. A feature I broke by dumping the Subversion
repository on my old development machine, loading it back on my new one - a Dell
Vostro 200 ST - and checking out the files again. The good news was that making
my sites from 70+ XML files now just took about 35 seconds instead of over 300
seconds. The bad news was that the timestamps got lost. Not a problem for most
files, except for the ones I included in web pages with the timestamp added
to reflect the time the program code was last updated.
After I discovered this;
svn diff showed that some HTML files, which
I also keep under version control for exactly this reason: to verify if the same
XML files still generate the same HTML 4.01 strict pages, didn't match the output
I expected, I considered at first to use
touch to set the timestamps
back. Not only did that sound as quite some work, but also it would mean that
as soon as I checked out source code on a different computer, I had to fix
the timestamp of each file on that computer as well.
Anyway, after some reading, mostly in the online Subversion manual, I decided to
svn:keywords property, which would substitute the keyword
specified (keyword substitution) for dynamic information in the file itself.
I decided to use the Id keyword because the dynamic information not only included
a timestamp but also the filename, revision number, and author.
So I opened a file, in this example
https-test.pl using the vi editor
and added the following at line 5 of the Perl program file:
The first character is a comment character (in Perl), and
is the magic keyword which Subversion will replace with the filename, the
revision of the file, the date and time in UTC, and the author. In order
to get this behavior,
svn:keywords property must be set to Id:
$ svn propset svn:keywords "Id" https-test.pl property 'svn:keywords' set on 'https-test.pl'
Note: the second line is a message reported by Subversion.
Next, I comitted the file as follows:
svn ci https-test.pl -m "Set svn:keywords property to Id" Sending https-test.pl Transmitting file data . Committed revision 1081.
After this the file https-test.pl got magically updated to (only the first 8 lines are shown):
# https-test.pl - HTTPS GET example # # (c) Copyright, 2004-2005 By John Bokma, http://johnbokma.com/ # # $Id: https-test.pl 1081 2008-09-30 19:03:23Z john $ use strict; use warnings;
And from now on - hopefully more drastic changes than just adding a $Id$ - each time the file is commited to the Subversion repository, the revision number and timestamp will be updated. Looks like a feature I should have learned about much earlier on. But it's never too late to learn, as my mother would say.
On the Compaq SR1505LA I mostly used (and still use) TortoiseSVN as a Subversion client. So when I
had modified all source files from the command line on Linux, I decided to check out how easy the
svn:keywords property could be set via TortoiseSVN.
And it turned out to be quite easy. If you want to give it a try, follow the following instructions:
svn:keywordsin the Property name combobox and type
Idin the Property value text entry field.
This looks like quite some more steps compared to the command line version. Remember that you can install a command line client on Windows XP as well.