views:

2405

answers:

5

Notice in the bottom right hand corner of this page it has the SVN revision id? I'm assuming that's dynamic.

I'd love to add that to some of my sites, just as a comment in the source to make sure code pushes are going through.

NOTE: You can also assume that the working directory of the site in question is an svn checkout of the repo in question.

Edit: I'm looking for the global revision number, not the revision number of the file I'm looking at.

+2  A: 

Read up on Keyword substitution. See

http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.keywords.html

JeffFoster
That's the right idea, but I'm less looking for the last rev that file changed, and more of what the current HEAD revision is.This is definitely an answer though, if nobody else comes up with anything better, i'll give it to you. Thanks!
UltimateBrent
+7  A: 

You can use the svnversion CLI utility to get a more specific look at the revision, including the highest number. You could then use regular expressions to parse this.

Subversion has no concept of a global revision; rather, you'd have to recursively look through the working copy to find the highest revision number. svnversion does that for you.

Sören Kuklau
+3  A: 

The keyword subsitution method isn't reliable because it will provide the revision of the file rather than the whole codebase that you're deploying, which I presume is what you're after.

Typically I use ANT to deploy from subversion, and in the build script I'd use the replace task to substitue a revision token in a layout template or common header file with the revision number of the codebase that I'm deploying - see below. Although if anyone has a better method I'd love to hear it!

 <svn username="${svn.username}" password="${svn.password}" javaHL="${svn.javahl}">      
   <status path="${dir.build}" revisionProperty="svn.status.revision" />
 </svn>

 <replace dir="${dir.build}" token="%revision%" value="${svn.status.revision}">
   <include name="**/*.php" />
 </replace>
Brian Sadler