Development

HowToUseTheSubversionIdTag

You must first sign up to be able to contribute.

Note: Most of this information is applicable to any OS, but some of the commands are specific to Linux - our OS of choice.

When I was started working with symfony, I wanted to include the cool "SVN: $Id" tags that Fabien had in his phpdoc DocBlocks at the head of each file. I did some google searching to find out how to get this working, but I didn't find any helpful information, and I eventually just gave up. Yesterday, the revision number suddenly "just worked" for one of my svn commits, much to my surprise - so I did some more investigation into what was going on, and thought I'd share what I found.

Here's a typical file-level DocBlock for our project (note: we are using the symfony alternative action class syntax ):

/**
 * @package    qubit
 * @subpackage repository
 * @author     David Juhasz <david@a*********l.com>
 * @version    svn:$Id$
 */ 
class RepositoryListAction extends sfAction
{

The $Id$ bit is an svn keyword, which tells subversion to replace $Id$ with information about the current version of the file in the subversion repository. The gotcha is that you need to make sure that the "svn:keywords" property "Id" is set for the file in question, or else it won't work!

If you have a file where the $Id$ tag is not getting replaced, use "svn propget svn:keyword <filename>" (at the commandline) to get the current keywords for the file in question. If the "Id" keyword is not in the list of returned values (or if you have no returned values) you can use "svn propset" or "svn propedit" to add the "Id" tag to the list of keywords (See: http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.advanced.props.manip).

You can also setup your "~/.subversion/config" file "auto-props" setting so that all new files added or imported into your repository automatically have the "svn:keyword" property set (See: http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.advanced.confarea.opts.config)

The replaced $Id$ looks something like this:

/**
...
 * @version    svn:$Id: listAction.class.php 1360 2008-09-10 00:21:46Z david $
...

Hope that saves someone some time and frustration!