views:

22

answers:

3

I have a revision.txt file in my SVN project.

Basically I want that this file is updated automatically when I call svn ci with the revision number the working copy will have after the commit.

For example:

  1. revision.txt contains "10"
  2. I make some change to my working copy (other files, not revision.txt)
  3. svn ci
    • launch hook script
    • read next revision number
    • update revision.txt
    • commit changes (also revision.txt)
  4. now revision.txt is already committed with revision number 11

I've tried without success with an hook script. I cannot retrieve the next revision number and update the transactione before committing.

Then try with "auto-props", but they are working only with modified files. The preferable solution is using only hook script and not using a wrapper script which check the revision and update.

Is possible ? Examples are welcome

A: 

As you already mentioned based on svn:keywords it's only possible to change modified files. But i think what you need is a build system which handles such kind of information (may be a build server / continous integration server).

khmarbaise
A: 

Keyword substitution comes closest to what you want, but that doesn't really work either because it gives you the last modification of the file, not of the project. From the subversion FAQ on this issue:

The information you want (the revision of your working copy) is available from the command svnversion; it gives you information on the revision level of a working copy given a path (see svnversion --help for details).

You can incorporate it into your build or release process to get the information you need into the source itself.

Wim Coenen
+1  A: 

You can't guess the next revision number before commit due to race conditions - you can't guarantee, until after the fact, that someone else hasn't got in ahead of you. It's also extremely bad form to change files in a svn commit hook - working copies get all out of date and messy, as they only get a "it worked" or "it failed" from the server, never a "it worked, but by the way that file now has these contents ..."

What do you need this for? Perhaps there's another way to get what you're trying to achieve.

You could auto-generate the revision.txt file just before it's needed by using "svn info", and filtering the "Revision: " line into the file.

Jim T
I have a central repository with multiple users (uh..SVN! :)) and that file is read directly by the software to show the last revision near the version when is delivered. People never remember to update the number and we haven't yet a deploy system. So we export the project and copy it manually on the final server.OK... I need a serious deploy strategy...
yuri
As I said in my own answer, you should use `svnversion` for this, not `svn info`.
Wim Coenen