15

Is it possible, via TortoiseSVN, to know the SVN rev number you are about to get prior to a commit so that I can put that rev# into the source code comment section?

Perhaps there is a special keyname/variable that I can put into my file that TortoiseSVN will automatically replace with the rev# it's about to commit to?

The motivation behind this is that I can take the latest build and see what SVN rev's it was comprised of by just looking at the source code. It also gives management warm fuzzies.

SiegeX
  • 135,741
  • 24
  • 144
  • 154

5 Answers5

14

Subversion does support keyword expansion, but you may want to read here before choosing to implementing it.

There are a number of reasons why it's generally a good idea to avoid modifying your committed files with content that is already in SVN. The second link above provides more detail on why this can be a bad idea. But basically, diffs and patches can become problematic.

You also don't need to duplicate the information that Subversion captures because this can be easily obtained via the log command.

LBushkin
  • 129,300
  • 32
  • 216
  • 265
  • On the other hand, if you want to store that revision number as part of something like a verification system, then the log does you no good since you have no idea what the revision was when you ran the verification. – simpleuser Jun 27 '16 at 17:17
6

SVN Special keywords - specifically: "$Revision$"

RedPandaCurios
  • 2,264
  • 12
  • 20
0

If you're using some sort of build tool to package your code, like Ant, you could include an SVN property query in the build process.

Since I only have experience doing this in Ant, it goes like this:

<svn svnkit="true" javahl="false">
    <status path="." lastChangedRevisionProperty="svn.lastRev"/>
</svn>

Once the svn.lastRev property is set, you can inject it into your code comments - maybe via token replacement. I'm not sure if this is exactly what you're looking for. I agree though, it's nice to look at your code and know what SVN rev. it came from.

0

It's not important to store the SVN revision number in each source file of the project.

One can add, for example, file "svn.c" to its project and have SVN write the following line at each commit:

size_t svn_revision = n;        /* n is the revision number written by SVN */

After that, one can printf() the svn_revision variable at boot, for example.

Roberto Caboni
  • 7,252
  • 10
  • 25
  • 39
Enrico Migliore
  • 201
  • 3
  • 9
0

you might also use the keyword substitution feature of SVN.

Example:

Add the following comment in your C source file:

/* SVN revision number = $Revision */

$Revision will be replaced by the actual commit revision number:

/* SVN revision number = 123 */

Take a look here: http://svnbook.red-bean.com/en/1.7/svn.advanced.props.special.keywords.html

Ciao, Enrico Migliore

Enrico Migliore
  • 201
  • 3
  • 9