No announcement yet.

Can SVN automatically modify source code after we do the "SVN commit"

  • Filter
  • Time
  • Show
Clear All
new posts

  • Can SVN automatically modify source code after we do the "SVN commit"

    We have a project which maintains C source code by SVN
    There is source file named "version.c" and a line of code as follows
    #define VERSION_NUMBER "001"

    Usually, we manually increase the version number in the source code every time we commit it into SVN

    Does any one know how SVN auto modify the version string when we commit the source code

    For example
    When we commit the source code, and the revision will be 112 in SVN
    Can SVN auto-modify following line in "version.c"
    #define VERSION_NUMBER "112"


  • #2
    kinda have a similar problem, anybody?


    • #3
      I embed the keyword Revision into my source code, in the midst of a character string, rather than a comment as usual. Then my code will parse the character sting, and print the version string to the terminal, or a log file to record the version of the source code used, at run time. Below is sample code in PERL. The comments explain the code so you can expand the concept to another language.

      my $null = "" ;
      my $Revision = "" ;
      my $Rev_str = "$Revision: 39 $null" ;
      # The previous values $null and $Revision were crafted so $Rev_str would have a value like ": 27 ", or ": 36 "
      $Rev_str =~ s/^:\s*// ; # Drop the leading colon and any white space.
      $Rev_str =~ s/\s+$// ; # Drop the trailing white space.