Update 2008-05-08: Please note that this post was written before I started using svninfo, and I highly recommend it if you are dealing with multiple source files. You still need to set the
Id keyword property on each source file, but the double dollar trick is not really needed. See the
For each file in a Subversion repository, we can specify a list of name-value pairs which are called “properties”. Properties can be used for any purpose (useful for automation scripts), and they are versioned just like the content of the files.
Some properties, however, have special meanings in Subversion. For example, the automatic end-of-line conversion feature relies on the
svn:eol-style property. And in this post, we will look at another one:
To use the
svn:keywords feature, you insert special tags like
$keyword$ into your file. There are currently five keywords in Subversion:
Date, Rev, Author, URL, Id. The idea is when you commit a file, Subversion will automatically expand the keywords inside the file.
To use this feature, first add the
svn:keywords property to the files that you want keyword expansion. For example,
svn propset svn:keywords "Date Rev" *.tex will add two keywords to all the TeX files in the current directory.
Then, inside the TeX files, you can insert text fragments like:
Last committed as $ $Rev$ $ on $ $Date$ $
(The extra pairs of dollar signs are added to “eat” the dollar signs that surround Subversion keywords.)
The five keywords are more or less self-explaining. But if you want to dig deeper into advanced features like fixed-width keywords, you can read it here.
P.S. Again it is very convenient to have the properties set automatically for all TeX files in your repository. To do so, here is an example config file that you can use. Any file added after you changed the config file will automatically have their properties set.