Development

HowToUseTheSubversionIdTag (diff)

You must first sign up to be able to contribute.

Changes from Version 1 of HowToUseTheSubversionIdTag

Show
Ignore:
Author:
djjuhasz (IP: 216.113.200.202)
Timestamp:
09/16/08 22:38:25 (9 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • HowToUseTheSubversionIdTag

    v0 v1  
     1Note: Most of this information is applicable to any OS, but some of the commands are specific to Linux - our OS of choice. 
     2 
     3When 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. 
     4 
     5Here's a typical file-level !DocBlock for our project (note: we are using the symfony [http://www.symfony-project.org/book/1_1/06-Inside-the-Controller-Layer alternative action class syntax] ): 
     6 
     7{{{ 
     8/** 
     9 * @package    qubit 
     10 * @subpackage repository 
     11 * @author     David Juhasz <david@a*********l.com> 
     12 * @version    svn:$Id$ 
     13 */  
     14class RepositoryListAction extends sfAction 
     15{ 
     16}}} 
     17 
     18 
     19The $Id$ bit is an [http://svnbook.red-bean.com/en/1.0/svn-book.html#svn-ch-7-sect-2.3.4 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! 
     20 
     21If 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). 
     22 
     23You 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) 
     24 
     25The replaced $Id$ looks something like this: 
     26 
     27{{{ 
     28/** 
     29... 
     30 * @version    svn:$Id: listAction.class.php 1360 2008-09-10 00:21:46Z david $ 
     31... 
     32}}} 
     33 
     34 
     35Hope that saves someone some time and frustration!