views:

273

answers:

3

Is there a way to have a file that is modified / touched whenever the WC is updated to a new revision? Or, as the second-best option, whenever svn update is executed?

Here's the motivation: I want to have the SVN revision number inside my executable. So I have to run SubWCRev as part of the build. The output file of SubWCRev is re-created every time, even if the revision number has not changed. This means that the exe is linked on every build, even if nothing has changed. I want it to be linked only as needed.

+3  A: 
  1. Get the SubWCRev output into a temporary file
  2. Compare this file to the current revision-number file
  3. Overwrite it with the temp file only if the two are different
  4. Delete the temporary file

You might even be able to do this with a .bat file (using fc). Something like...

REM ***UNTESTED***
FC temp.rev curr.rev | FIND "FC: no dif" > nul 
IF NOT ERRORLEVEL 1 COPY /Y temp.rev curr.rev
DEL temp.rev

Edit: As an aside, you can do this in Mercurial by making the rev-number-file depend on .hg/dirstate.

A: 

My answer will probably be too short, but might give you some direction.

SVN has hooks. They are scripts that get executed everytime code is commited.

Maybe?

Jeff MacDonald
No. I want to know when the WC has been updated, not the repository.
Lev
+1  A: 

This sounds like a duplicate of this discussion here: http://stackoverflow.com/questions/151299/embedding-svn-revision-number-at-compile-time-in-a-win32-app#151445

My approach, described in that question, works across platforms and can output to whatever format you program so it will work in any situation where including a file is a viable solution.

In your case, you want to watch for the M modifier in svnversion's output: that will let you know that your WC has been modified.

antik