The version control system Subversion offers a nice feature called keywords. Keywords are a mechanism which allows to replace certain markers/placeholders in versioned text files with SVN metadata (author, last modified date, last modified revision, etc.). By default, keywords are disabled and may be activated with a specific SVN property called svn:keywords. The corresponding chapter in the SVN book lists the available Keywords.
Keywords (in the example, the last modified date and revision) may either be activated for a single file:
svn propset svn:keywords "Date Revision" testfile.txt
or for a whole directory tree
svn propset svn:keywords "Date Revision" -R .
As of the next commit of the files, all occurrences of $Date$ and $Revision$ placeholders will be updated with the up-to-date metadata every time you commit the file:
$Date: 2013-05-01 10:08:40 +0200 (Wed, 01 May 2013) $
$Revision: 11 $
If you want to disable all keywords for a file/tree you use the propdel command:
svn propdel svn:keywords testfile.txt
svn propdel svn:keywords -R .
For disabling certain keywords there exists the propedit command which fires up a text editor:
svn propedit svn:keywords testfile.tx
Note that propedit only works for a single file/directory and has, by nature, no recursive option. A recursive alternative is to use propset svn:keywords -R with a new list of SVN keywords.
The following is a list of my favorite keywords:
Keyword| |
Placeholder| |
Example |
Date |
$Date$ |
$Date: 2013-05-01 10:08:40 +0200 (Wed, 01 May 2013) $ |
Revision |
$Revision$ |
$Revision: 11 $ |
Author |
$Author$ |
$Revision: svenlogan $ |
Links
- [1] SVN Keyword Substitution (Svnbook)