tags:

views:

86

answers:

1

I'm putting this thing in my source(s)... (right, for now it's just one, plus the test scripts).

REVISION = (function(x) substring(x, first=7, last=nchar(x)-2))("$Rev: 8727 $")

but how do "real" R programmers do?

+1  A: 

That is a pretty good solution. A regular expression may be more robust in case you fewer or more digits: swap the beginnning $Rev : and the trailing $ for empty strings and you should have the revision left.

The only problem with the per-file properties is that they only update when this file itself is updated by subversion.

For that reason (and many others), consider making a local package. Your DESCRIPTION file will a) change often enough for the new version number and b) can simply be extended by new fields you simply add e.g.

Revision: $Rev$

You can read the content from R via read.dcf() after which you can then do your trick of stripping the dollar signs and colon, or use a regular expression.

Dirk Eddelbuettel
did not yet know the read.dcf function. quite useful, thanks!
mariotomo
the problem "which is the highest revision number in this subdirectory" is probably best solved with a script that will put the highest number into a variable (defined in a file not under version control). but allow me to extend the question...
mariotomo
not really extended, it's a different question... http://stackoverflow.com/questions/1888151
mariotomo
about reg.ex and my solution. I tested it for un-substituted "$Rev$" as well as for less or more digits.
mariotomo
Does `svnversion` in the directory give the revision of the directory itself? If and when you run `svn update`, that should be the current revision. Or am I misunderstanding what you are after?
Dirk Eddelbuettel
in Python I got used to having a __version__ variable in each module. so after importing a module x.y, I can ask x.y.__version__ and have an idea of whether I'm using the latest version of the module. I'm after something similar in R. so: is there a way to associate a library to its version, so that this association is visible in the environment when I loaded the library?
mariotomo