Deprecated: Assigning the return value of new by reference is deprecated in /f2/blendedtechnologies/public/wp-content/plugins/pmetrics.php on line 1192
Blended Technologies » Blog Archive » Get Subversion revision information into your source code files

Get Subversion revision information into your source code files

Here is a Python script I wrote which will look at all of the files in the script’s directory and update the Subversion revision information.

Download the Code

View the Code Online

It makes use of TortoiseSVN’s SubWCRev.exe. Thus it most likely will only work on Windows computers. This script is a simple alternative to the SVNRev product. And it is nice because it’s easy to customize to fit your needs.

Usage:
Just download the code, Put the two files into a folder within your Subversion working copy (what you checked out from Subversion). Then add the patterns shown in insert_revision_info.py to your source files (eg $Revision: $, etc) and then run insert_revision_info.py whenever you want your files to be updated. (I put a call to insert_revision_info.py in my build script so that the version info will always be updated right before a build.)

Let me know how it works out for you or if you have any questions.

-

del.icio.us |  Digg |  FURL |  Yahoo! My Web 2.0 |  Reddit

2 Responses to “Get Subversion revision information into your source code files”

  1. John Burkhard Says:

    Interesting tip, but perhaps I’m missing something: How is this different/better/worse than setting the svn:keywords property to “Rev” for the file(s) in question, and let svn automatically expand the $Rev$ token when the file is committed?

  2. Administrator Says:

    John, I’m glad you mentioned that. Using the $Rev$ token is good alternative depending on your needs. I prefer my method because it updates every file to the latest revision number. Using the Rev keyword will only update $Rev$ in a file when it is committed. Suppose someone sends me just one file from multi-file app I wrote, and that one file wasn’t commited since revision 1. The $Rev: 1$ in the file wouldn’t really give me much information. But if every file he had, had the latest revision number, then just from that one file, I could get the whole app from my repository and start debugging.

    “Interesting tip, but perhaps Im missing something: How is this different/better/worse than setting the svn:keywords property to Rev for the file(s) in question, and let svn automatically expand the $Rev$ token when the file is committed?”