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.
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.
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.
create a template file which contains your defines, maybe something like
const long WC_REV = $WCREV$;
in a file named version.h.tmpl
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With