Dynamic inline fields in SVN?

Some release products have a way to insert interesting values ​​into the file as they are pulled from the repository. Typically, you put some kind of magic string in your source file and it gets updated when you checkout. For example, you write "$ revision = xxx", and if you check revision 832, this will be changed to "$ revision = 832". Does SVN have such a feature, perhaps using properties?

+2


source to share


2 answers


Thank you after replacing the keyword , I think.



+4


source


Yes, the reference book description of keyword replacement is authoritative, but here it is quickly shortened.

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

      

If all your perl docs need the $ Revision $ extension take a look at 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 also made sure the perl scripts are executed and the eol style is correct, so users can check on Linux, Windows, or Mac without issue. My most used keywords are included besides Revision.)

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

The biggest drawback of auto lenses is that they are per user, so all committers must have consistent settings. There has been some talk about allowing configuration per repo in future releases.

~ J

+2


source







All Articles