Last modified 7 years ago Last modified on 2013-01-04 16:43:14

Is it really important to have the svn version of the programs used for processing in the history attribute of the data files. It helps track down the cause of any data issues found after (sometimes LONG after) the processing was done.

Subversion has functionality that allows substitution of certain keywords with their values. The possible keywords (at the moment) are Date, Revision, Author, HeadURL and Id (which combines the others). If a keyword surrounded by '$' (ie $ Revision $) is found in the file, the value of the keyword is added before the second $. In order for the replacement to occur, the svn:keywords property must be set, and of course this varies by architecture and software. The setting of properties cannot be done to directories- only to files.

Using the command line in linux, set the properties of the file by: svn propset svn:keywords "Revision" myFilename

On PC (using TortoiseSVN) you right click on the file, select properties then click the Subversion tab. From there click properties (again) and you may add, edit or delete any properties associated with the file.

This allows you to put $Revision$ in a program (m-file), and svn on the server will replace it with $Revision ###$ where ### matches the subversion revision of the file. For instance, I had a .m file that I wanted to contain the revision info. I added these lines to the code:

% get the current SVN version- the value is automatically obtained in svn % is the file's svn.keywords which is set to "Revision" rev_info = 'SVN $Revision: $';

I added the SVN prefix because it made a more descriptive string in the rev_info variable. The $keyword$ must be surrounded by single quotes in Matlab programs to avoid errors.

Then commit the file (as appropriate for the software) with the $keyword$ in it, and the every time the file is subsequently updated it returns with the value of the keyword inside the $'s, as shown below.

rev_info= 'SVN $Revision: 856 $';

Once the property is set, all updates of the file have the substitution made, and the behavior applies to all users of the repository. What this allows is assembly of a nice long provenance string like this:

hist_new = ['Sonar data written to NetCDF by ', mfilename, ', ', rev_info, ', using Matlab ', version, '; ',ori_hist];

When executed, the line above produces a history entry like the one below without ever having to edit the filename or version again.

nc.history = ncchar('Sonar data written to NetCDF by mkrawcdf, SVN $Revision: 852 $, using Matlab 7.4.0.287 (R2007a); Sonar data downloaded from instrument');