views:

111

answers:

3

I'm maintaining a homebrew web-based CRM that I version-control with Subversion. What I want is to have the revision number written into a file after I do an export to the production server so that I can display it in the CRM's status page for debugging reasons.

Is there any way to do this with command-line tools?

+2  A: 

You can use keyword substitution to always have the information present in a file.

Lukáš Lalinský
+4  A: 

Technically, you can't be sure after doing the export, because another commit might have happened just in-between. Practically, you can get the information with svn info <URL>. You could of course do the svn info first, extract the revision and export that revision to make sure both correspond.

If you do a checkout instead of an export, the information is available through svn info <path>.

Another way to do that is to use keywords in one of your exported file (let's call it script.h), like this:

#define VERSION_STRING  "r$Revision$"
// ... rest of the file

If you give the svn:keywords property to your file (and commit it), the $Revision$ will be substituted at checkout or export:

svn propset svn:keywords "Revision" script.h

(there are other substitutions, check the SVN documentation for further details)

RedGlyph
+1  A: 

If you use Ant as your build tool, you can write a custom Ant task to grab the information from a remove Subversion server, store them into the Ant project's properties and use substitution to place these values into some properties/class.

Since you're certainly building you production application from a Subversion tags, you will not have the risk to display a wrong information (like RegGlyph mentioned)

Vladimir