Computer And Technologies

Computer And Technologies: Using CVS Keywords in File Headers(Linux)

Wednesday, 6 May 2009

Using CVS Keywords in File Headers(Linux)

This article provides a brief introduction on how to use CVS Keywords in the file header of files checked into a CVS repository.

One of the most popular keywords in CVS is $Id$. This CVS keyword will expand out to the name of the RCS file (which is the name of the file plus a ,v), the revision number, the last modified date, and the username of the person to last modify the file. I will generally include the $Id$ keyword somewhere in the header of any file I write that's under CVS revision control.

CVS keywords supported by CVS are mostly inherited from RCS. If you have used RCS in the past, these should all be very familiar. Another popular CVS keyword is $Revision$ - it will contain just the revision number. $Date$ will put in just the last modified date. end CVS log entries to the file, and so on. Another popular CVS keyword is $Log$ which will append CVS log entries to the file. I do not recommend using this one since it is just as easy to extract that information out of cvs log.

All examples were run on Sun Solaris 2.8 using CVS Release 1.11.14.


Example File Header

The following is a commonly used file header:
Author   : Name 
Subject : Title of Documentation
Revision : $Id$
When committed to CVS, the above file header will expand out to something like:
/*
* Author : Amaresh Das
* Subject : Demonstrate the Use of CVS Keywords
* Revision : $Id: File2.java,v 1.3 2004/06/02 17:30:42 AmareshCD Exp $
*/

Using CVS Keywords in Other File Types

For Java Source Code Files
/**
* $Id$
*
* Used to test the functionality of using CVS keywords
* in Java source code files.
*
* @author Amaresh Das
* @author avirus_944@yahoo.co.in
* @author www.bangaloreorbits.com
* @version 3.0, 30-JUN-2004
* @since SDK1.4
*/


For Shell Scripts

#!/bin/sh
# Author : Name
# Description : One line description of script.
# $Id$


For Perl Scripts

#!/usr/bin/perl
$ID = q$Id$;
#
# Author : Name
# Description : One line description of script.
# Copyright 2004 iDevelopment.info


For C Source Code Files

/*
* $Id$
*
* Description : One line description of file.
* Author : Name
*
* Copyright 2004 iDevelopment.info
*
* Purpose :
* Long description of what the file is for.
*/


No comments:

Post a Comment