next up previous
Next: Defining Project Modules Up: Simple Project Management Using Previous: Remote Repository Access

Using RCS Keywords

CVS is based on an older source code management system called the Revision Control System, or RCS. RCS defines a number of keywords you can imbed in the comments or code of your source file (with a ``$'' at each end) which will get updated with the corresponding types of information whenever the file is committed to the repository. For example:

/*********************************************************************
 * frob.c
 *
 * This code is Copyright (c) 2000 Mike Bland.  All rights reserved.
 * This code may be freely distributed provided that this copyright notice
 * is preserved.
 *
 * Feel free to use this code and modify it to suit your own purpose, but
 * note that it comes with no warranty and with the understanding that you
 * make use of it at your own risk.  If this code is used commercially or
 * distributed in a commercial product, I would appreciate knowing about it.
 *
 * Author:        Mike Bland <mbland@pcs.cnu.edu>
 *                http://www.pcs.cnu.edu/~mbland/
 * Creation date: Friday, July 14, 2000
 *
 * Revision:      $Revision:$
 * Checked in by: $Author:$
 * Last modified: $Date:$
 *
 * $Log:$
 *********************************************************************/

static const char rcsid[] = "$Id:$";

After committing a file containing these keywords to the repository, the keywords are expanded to contain extra information about the file and its history:

/*********************************************************************
 * frob.c
 *
 * This code is Copyright (c) 2000 Mike Bland.  All rights reserved.
 * This code may be freely distributed provided that this copyright notice
 * is preserved.
 *
 * Feel free to use this code and modify it to suit your own purpose, but
 * note that it comes with no warranty and with the understanding that you
 * make use of it at your own risk.  If this code is used commercially or
 * distributed in a commercial product, I would appreciate knowing about it.
 *
 * Author:        Mike Bland <mbland@pcs.cnu.edu>
 *                http://www.pcs.cnu.edu/~mbland/
 * Creation date: Friday, July 14, 2000
 *
 * Revision:      $Revision: 1.5 $
 * Checked in by: $Author: mbland $
 * Last modified: $Date: 2000/07/17 17:58:44 $
 *
 * $Log: frob.c,v $
 * Revision 1.5  2000/07/17 17:58:44  mbland
 * "Added RCS keywords and copyright notice"
 *
 *********************************************************************/

static const char rcsid[] = "$Id: frob.c,v 1.5 2000/07/17 17:58:44 mbland Exp $";

While all of this information is accessible via the cvs log command, having this information embedded in the source file in a format tailored to your personal tastes may prove convenient for both you and your fellow project team members.

Special notice should be taken with the static const char rcsid[] variable; by embedding this string of information in the compiled code, you may find out which revision of a module was used to compile a binary executable or object file by using the ``ident'' command, which is a part of the RCS suite:

mbland@defender
/home/student/mbland/projects/class_proj -> ident frob.c frob.o
frob.c:
     $Revision: 1.5 $
     $Author: mbland $
     $Date: 2000/07/17 17:58:44 $
     $Log: frob.c,v $
     $Id: frob.c,v 1.5 2000/07/17 17:58:44 mbland Exp $

frob.o:
     $Id: frob.c,v 1.5 2000/07/17 17:58:44 mbland Exp $

As you can see, ident works on both text and binary files. You can even use declarations such as ``public static final String rcsid = "$Id:$;" '' in Java class definitions and use ident on compiled .class files.

For more information on RCS, refer to the rcs man page. For more information on ident and RCS keywords, refer to the ident man page. Bear in mind, however, that CVS does not depend on a separate installation of RCS in order to function, and therefore ident and other RCS tools may not be available on any given system just because CVS is present.


next up previous
Next: Defining Project Modules Up: Simple Project Management Using Previous: Remote Repository Access
Michael S. Bland
2000-11-22