Tracking Changes in CVS
Pages: 1, 2
log
The cvs log command displays information about the file or files in the argument list. If no files are listed, it displays log information about all files in the current working directory and its subdirectories.
The options to cvs log reduce the amount of information it shows. By default, log displays all its information.
Example 6
$ cvs log cvs_changes.html
RCS file: /home/cvs/oreilly/articles/cvs/cvs_changes.html,v
Working file: cvs_changes.html
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
----------------------------
revision 1.3
date: 2002/05/15 15:41:54; author: jenn; state: Exp; lines: +53 -0
history mostly done. needs example.
----------------------------
revision 1.2
date: 2002/05/15 15:04:47; author: jenn; state: Exp; lines: +8 -2
Adding a history file
----------------------------
revision 1.1
date: 2002/05/15 14:54:54; author: jenn; state: Exp;
Initial entry for both files. Also includes cvs annotate for changes.
=============================================================================
Example 6 shows the early log history for this article.
Revision 1.1 occurred when I created two files, forgot to check-in the empty templates, and tried to commit the annotate section of this article.
User-defined Logging
CVS has customization files that define scripts to be called when certain actions occur. The loginfo, modules, and taginfo files can be used to call logging scripts.
These files can be found and configured in the CVSROOT directory in the CVS repository. The files are run on the computer that hosts the repository, but some module scripts are run from the client machine. See that section for more detail.
Use CVS when editing these files -- they are in the module CVSROOT. Simply cvs -d repository checkout CVSROOT to check out all these files.
loginfo and taginfo
The loginfo file controls where log information for cvs commit is sent. Potential uses include keeping a project leader informed of changes her team makes, and maintaining a central log of a project's progress.
taginfo does the same, but for the tag and rtag commands. It has the same syntax as loginfo.
Each line of the file should contain a regular expression that matches a directory, followed by the address of a script, which expects log information as the standard input (stdin).
The special lines start with 'ALL' and 'DEFAULT'. ALL runs cumulatively with any other line that applies. Otherwise, only the first matching regular expression is run, or DEFAULT if none match.
The loginfo file in example 7 would log every commit through a script called logscript, run cvsscript if any file under $CVSROOT/oreilly is committed, and would mail any other commits to cvsadmin.
Example 7
ALL /usr/local/bin/logscript
^oreilly /home/jenn/scripts/cvsscript
DEFAULT Mail -s "CVS commit" cvsadmin
modules
The file CVSROOT/modules records each module and its directories and files. The file also takes options, and some of the options are scripts to be run when CVS actions occur.
-e script- run the script when the module is exported.
-i script- run when the module is committed.
-o script- run when the module is checked out.
-u script- run when the module is updated.
-t script- run when
rtagis used on the module. This does NOT run whentagis used. Thetaginfofile is a better way to log tags.
Please read the manual and info files for CVS if you are changing this file. CVS uses this file every time a user interacts with a module.
Scripts called from a commit or an update are run from the local machine, and scripts called from the rest are run from the server.
Example 8 would run /home/jenn/scripts/cvsscript when the oreilly module is checked out, from the directory oreilly. It also defines the module CVSROOT, with no special options.
Example 8
CVSROOT CVSROOT
oreilly -o /home/jenn/scripts/cvsscript oreilly
Final Words
Change-tracking is a useful part of CVS, but I've rarely seen it used in the field. I discovered it when I started using CVS on my own, and had one of those, "Why have I never used this before?" moments.
Try it. I hope you find it as useful as I do.
Further Reading
man cvsinfo cvs- Introduction to CVS
Jennifer Vesperman is the author of Essential CVS. She writes for the O'Reilly Network, the Linux Documentation Project, and occasionally Linux.Com.
Return to the Linux DevCenter.