Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Always Commit the same file with SVN

Tags:

svn

In my web application I have a file which hold the current revision number via $Rev$. This work fine except, if I don't make any changes to that file, it doesn't get committed.

Is there anyway I can force a single file to always get committed to the SVN server?

I'm using TortoiseSVN for Windows so any code or step-by-step instructions would be helpful.

like image 991
GateKiller Avatar asked Aug 08 '08 13:08

GateKiller


3 Answers

Basically, you want the output of the svnversion command in a file.

Such files are usually kept out of the repository, and automatically created by a build script. I suggest you do the same. If you don't build, but just to a svn up on the server side, just call svnversion after svn up or create a shell script to do both actions.

If you have to keep it in the repository on the other hand, calling svnversion in a pre-commit hook would be your best bet.

like image 144
Can Berk Güder Avatar answered Sep 19 '22 16:09

Can Berk Güder


If you have TortoiseSVN installed, you also have the SubWCRev tool available. Use that tool to get the revision instead of misusing the $REV$ keyword.

  1. create a template file which contains your defines, maybe something like

    const long WC_REV = $WCREV$;

    in a file named version.h.tmpl

  2. on every build, call SubWCRev to create the 'real' file you can use in your application:

    SubWCRev path\to\workingcopy path\to\version.h.tmpl path\to\version.h

This will create the file version.h from version.h.tmpl, with the text $WCREV$ replaced with the revision your working copy is currently at.

The docs for SubWCRev might help too.

like image 28
Stefan Avatar answered Sep 19 '22 16:09

Stefan


I think you may be not understanding how the $Rev$ flag works. The goal of the Rev flag is not to have this revision always committed into the subversion repository. The goal is that on an update, the Rev flag will always be what the revision is. You should not need to put code into subversion that contains the revision. Subversion is very good at keeping track of that information for you.

What you probably missed is that, you need to set a property on the file so that the Revision keyword will be properly processed.

svn propset svn:keywords "Revision" file.txt

This will ensure that whenever you do an update, the $Rev: xxx$ flag will be updated with the current revision. You don't need to worry about how it is committed to the repository.

like image 36
Chris Dail Avatar answered Sep 19 '22 16:09

Chris Dail