CVS Keyword substitution
http://ximbiot.com/cvs/manual/cvs-1.11.6/cvs_12.html
12.1 Keyword List
This is a list of the keywords:
$Author$
- The login name of the user who checked in the revision.
$Date$
- The date and time (UTC) the revision was checked in.
$Header$
- A standard header containing the full pathname of the RCS file, the revision number, the date (UTC), the author, the state, and the locker (if locked). Files will normally never be locked when you use CVS.
$Id$
- Same as
$Header$
, except that the RCS filename is without a path. $Name$
- Tag name used to check out this file. The keyword is expanded only if one checks out with an explicit tag name. For example, when running the command
cvs co -r first
, the keyword expands to `Name: first'. $Locker$
- The login name of the user who locked the revision (empty if not locked, which is the normal case unless
cvs admin -l
is in use). $Log$
- The log message supplied during commit, preceded by a header containing the RCS filename, the revision number, the author, and the date (UTC). Existing log messages are not replaced. Instead, the new log message is inserted after
$Log:...$
. Each new line is prefixed with the same string which precedes the$Log
keyword. For example, if the file contains:/* Here is what people have been up to: * * $Log: frob.c,v $ * Revision 1.1 1997/01/03 14:23:51 joe * Add the superfrobnicate option * */
then additional lines which are added when expanding the
$Log
keyword will be preceded by `*'. Unlike previous versions of CVS and RCS, the comment leader from the RCS file is not used. The$Log
keyword is useful for accumulating a complete change log in a source file, but for several reasons it can be problematic. See section 12.5 Problems with the $Log$ keyword.. $RCSfile$
- The name of the RCS file without a path.
$Revision$
- The revision number assigned to the revision.
$Source$
- The full pathname of the RCS file.
$State$
- The state assigned to the revision. States can be assigned with
cvs admin -s
---see A.6.1 admin options.
12.2 Using keywords
To include a keyword string you simply include the relevant text string, such as $Id$
, inside the file, and commit the file. CVS will automatically expand the string as part of the commit operation.
It is common to embed the $
Id$ string in the source files so that it gets passed through to generated files. For example, if you are managing computer program source code, you might include a variable which is initialized to contain that string. Or some C compilers may provide a #pragma ident
directive. Or a document management system might provide a way to pass a string through to generated files.
The ident
command (which is part of the RCS package) can be used to extract keywords and their values from a file. This can be handy for text files, but it is even more useful for extracting keywords from binary files.
$ ident samp.c samp.c: $Id: samp.c,v 1.5 1993/10/19 14:57:32 ceder Exp $ $ gcc samp.c $ ident a.out a.out: $Id: samp.c,v 1.5 1993/10/19 14:57:32 ceder Exp $ |
SCCS is another popular revision control system. It has a command, what
, which is very similar to ident
and used for the same purpose. Many sites without RCS have SCCS. Since what
looks for the character sequence @(#)
it is easy to include keywords that are detected by either command. Simply prefix the keyword with the magic SCCS phrase, like this:
static char *id="@(#) $Id: ab.c,v 1.5 1993/10/19 14:57:32 ceder Exp $"; |