[ros-dev] Re: Build number: a proposal

Martin Fuchs martin-fuchs at gmx.net
Sun Jan 23 17:12:25 CET 2005


Hi,

> >The biggest obstacle I see is actually getting the SVN revision number in
> >our source somewhere. Maybe our local SVN guru, aka Casper, has an idea how
> >to do this?
> >  
> The information is stored in the .svn folder, and would not be hard to 
> extract procedurally.

Just execute "svnversion ." in any directory of the working copy.
This prints the current revision number to standard output.
Here is the online help for this tool:

===============

svnversion: invalid option: --help
usage: svnversion [OPTIONS] WC_PATH [TRAIL_URL]

  Produce a compact "version number" for the working copy path
  WC_PATH.  TRAIL_URL is the trailing portion of the URL used to
  determine if WC_PATH itself is switched (detection of switches
  within WC_PATH does not rely on TRAIL_URL).  The version number
  is written to standard output.  For example:

    $ svnversion . /repos/svn/trunk
    4168

  The version number will be a single number if the working
  copy is single revision, unmodified, not switched and with
  an URL that matches the TRAIL_URL argument.  If the working
  copy is unusual the version number will be more complex:

   4123:4168     mixed revision working copy
   4168M         modified working copy
   4123S         switched working copy
   4123:4168MS   mixed revision, modified, switched working copy

  If invoked on a directory that is not a working copy, an
  exported directory say, the program will output "exported".

Valid options:
  -n [--no-newline]        : do not output the trailing newline
  -c [--committed]         : last changed rather than current revisions
  --version                : show version information

===============


The output contains some more information as just the revision number.
For example get see a trailing "M" after the number if any file in the WC
is modified. To strip it, one might use a command like:

svnversion doc | sed s/[A-Z]// > svnrevision.inc

(or write another little tool that does this job and put it into the "tools" folder)


Regards,

   Martin



More information about the Ros-dev mailing list