[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Inserting revision numbers in source

From: DK <dk_at_dsl.pipex.com>
Date: 2006-10-30 23:47:51 CET


I would like to know if anyone has asked for this before and, if so, what
the answer/solution was?

I am a developer on a C++ project hosted on SourceForge.net, which uses
Subversion as its repository. I would like the Subversion repository to
mimic the antics of TortoiseSVN's program "SubWCRev.exe" automatically.

By this I mean that I would have two members in the source ("version.in" and
"version.h") with "version.in" being (less my comments):

        #define FILEVER 3, 4, 0, $WCREV$
        #define PRODUCTVER 3, 4, 0, $WCREV$
        #define STRFILEVER "3, 4, 0, $WCREV$\0"
        #define STRPRODUCTVER "3, 4, 0, $WCREV$\0"

What I would like is that when anyone commits anything to this project,
Subversion copies "version.in" to "version.h" (overwriting it if it exists)
whilst it substitutes the $WCREV$ (or differently named keyword to be
distinct from TortoiseSVN's program) with the current revision number (if
"version.in" is changed during the commit, then it would be copied after the
change has been committed).

During the commit process, the new "version.h" would be sent back to the
user committing his/her change so that their working copy is identical to
that stored in the repository.

This way "version.h" always has the current build number in it should anyone
Checkout the project.

This differs from the current $Rev$ keyword in that the whole field is
replace by a numeric value rather than inserting the revision number after
the "$Rev:" string i.e.:

        #define FILEVER 3, 4, 0, $Rev$:

would become

        #define FILEVER 3, 4, 0, $Rev: nnnn$:

which is not a valid C statement. This would not be a problem for future
updates as the source file ("version.in") was not altered.

It also differs from the SubWCRev program which would, in the process of
updating "version.h" mark the directory as updated and hence now different
from the repository.

I would envision a different keyword associated with the "version.in" file
in the Subversion repository - something like $Rev$ but meaning replacing
the whole keyword string with the revision number and specifying the name of
the file to be replaced (in my case "version.h").

If anyone has an alternative solution, I would be grateful to hear.


Received on Mon Oct 30 23:48:27 2006

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.