views:

1152

answers:

1

I'm using Visual SVN on my Windows Box.

I have Repository Application, which has Framework as an svn:external. All well and good.

When I make a checkout of Application, I'd like to have the version of Application and Framework for inclusion in a footer file. This way I could have something like:

Application Version $ApplicationVersion$, Framework Version $FrameworkVersion$

Ordinarily, I understand I could use svn:keywords and add the revision - but as I understand it, svn:keywords apply on a per-file basis. A few sites have suggested using svnversion to produce the output for each variable, but I'm not entirely sure how to go about this.

Once again, on a Windows Box, using VisualSVN. I also develop on a Mac using Versions.app if it provides a more familiar interface for people to answer :)

Edit - my application is a PHP web application. As such, there is no compiling.

Thanks!

+1  A: 

To use svnversion, you need to integrate it into the build process. If you run it on a subversion checkout, it will output a string like 73597:73598, indicating what version your tree has (notice that different files may have different versions, plus files may have also local modifications). You put something like

CFLAGS+=-DSVNVERSION="`svnversion`"

into your Makefile, and then put

#define VERSION_STRING "Application version" SVNVERSION ", Framework version" FRAMEWORK_VERSION

into the code. If you don't use Make, or cannot readily have your build process run a command whose output produces a compiler command line option, then you can also use the subwcrev utility that comes with TortoiseSVN. You use that as a pre-build step, and have it transform some file with placeholders into a copy of the file with the placeholders replaced with the actual version; then your compilation will compile and link the new file.

Edit: For the PHP case, it is not possible to have the revision written automatically into a file on checkout or update. Instead, you could run svnversion on every PHP access, putting its output into the HTML response. If that gets too expensive, you can cache the svnversion result in a file and only regenerate the file if it is older than one hour (say), leaving it up to the user to remember to delete the file after an update to make it recompute the cache right away.

Martin v. Löwis
My application is a PHP web application. As such, no compiling. If I were to use something like subwcrev, how can I get it to automatically run when it's checked out?
EvilChookie
I haven't been able to find a solution that is acceptable. Either the solutions don't fit my situation (my svn server is just a windows box that hosts VisualSVN. That's it) or the options are far too complex to implement for what should just be a simple operation.
EvilChookie
The fact that you use a VisualSVN server is really irrelevant here. svnversion is just a client-side tool, and doesn't interact with the server at all. Can you get it (or subwcrev) to output version information when you invoke it manually at the command line?
Martin v. Löwis