Horas and konnichiwa untuk semua


CVS Revision string
September 9, 2004, 11:19 am
Filed under: notes/General

Revision string as comment

Often it is convenient to see who has made waht change and when, just by looking at the source file. In order to do this, just put the string $Id$ anywhere in a source file, and when you commit the file to CVS, it’s converted to something of the form :

$Id: mysource.c,v 1.8 2000/07/21 20:31:40 asiboro Exp $

The String here consists of:

-The Name of the RCS file, and path in the repository.
-The Version number of the file.
-The date and time the file was last committed.
-The last CVS user to commit changes to the file.

So, the above string says the name of this file is ‘mysource.c’, it’s in version 1.8, and the user ‘asiboro’ was the last to commit it. This will be updated on every commit.

Here’s a list of other keywords that can be included in files, similar to $Id$ above.

$Author$ – The last CVS user to commit the file.
$Date$ – The date of the last commit.
$Name$ – The tag name
$Log$ – All Log Messages from commits to this file (note: old log messages are kept as well as the latest one).
$RCSfile$ – The RCS name of the file (without a path).
$Revision$ – The Revision (or Version) number.
$Source$ – The full pathname of the RCS file in the repository.

Any number of these can be included in any file. Please note that the ‘Log’ keyword appends the log message, and doesnt replace the old substitution like the others. Like so:

$Log: mysource.c,v $
Revision 1.8 2000/07/21 20:31:40 asiboro
This is the comment

Revision 1.7 2000/07/21 20:06:46 asiboro
Here is another comment

Revision 1.6 2000/07/09 18:03:04 asiboro
Here is yet another comment

Revision string as variable

If revision string is put into the source as variable, we can easily determine which source file an executable originated from by using “ident”.

For C define like below:
static const char rcs_id[] __attribute__ ((unused)) = “$Id$”;

For C++ use this:
namespace { const char rcs_id[] = “$Id$”; }