tags:

views:

69

answers:

2

Some versioning products have a way to embed interesting values into a file as it is checked out of the repository. Typically you put some magic string in the source file and it gets updated at checkout. Like, you write "$revision=xxx" and if you check out revision 832 this gets changed to "$revision=832". Does SVN have a feature like this, maybe using properties?

+4  A: 

You're after keyword substitution, I think.

Rob
Ah, sometimes there's a simple answer. I searched the documentation but I just couldn't think of the right keywords (no pun intended) to search for.
Jay
+1  A: 

Yes, the redbean book description of keyword substitution, is authoritative, but here's the quick rundown.

In foo.pl:

# Nifty perl trick to get just number and not "$Revision:" string.
our $revision = '1.0-' . qw$Revision: 0 $ [1];

Then run:

svn propset 'svn:keywords' 'Revision' foo.pl

Should all your perl documents need $Revision$ expanded, look into auto-props.

Set in your ~/.ssh/config file:

enable-auto-props = true
*.pl = svn:eol-style=native;svn:executable;svn:keywords=Id LastChangedBy LastChangedRevision Revision Author

(Here, I've also made sure perl scripts are executable, and the eol-style is correct so users can checkout on Linux, Windows, or Mac without issues. My most often used keywords are included, in addition to Revision.)

This even works for Windows clients like TortoiseSVN (see the Settings page for a button that will open the config file in an editor).

The biggest downside of auto-props - they are per user, so all committers must have consistent settings. There has been some talk of allowing per-repo configuration in future versions.

~J

jmanning2k
Thanks! .......
Jay