Develop common, cross-platform scripts for UNIX, Linux, and Windows, from a single Windows desktop - using the power of more than 350 command-line utilities, and CGI scripts. - Click here

Get a FREE Evaluation
06.24.03


By Jennifer Vesperman

CVS is a useful version control tool. Version control is not the only aspect of building a project or maintaining a service, though. This article is about the hooks CVS includes to allow you to expand it and integrate it with other tools.

Five files in the CVSROOT directory of the repository enable you to run arbitrary scripts when a file is committed or tagged. Common uses for these files include interfacing CVS to a bug management system, a change tracker, or another tool; enforcing compliance with a project policy; and triggering processes such as automated export programs.

CVS uses one file during tagging and four files during committing:
  • commitinfo before the files in a directory are committed.
  • loginfo after the files in a directory are committed.
  • verifymsg after the log message is entered, but before files are committed.
  • rcsinfo for the template for the log message in a commit.
  • taginfo before each tag or rtag operation.

Resources for Linux Programmers
Trials, Software, Downloads, and More.

Syntax

Each line of these files should contain a rule with the following syntax: name_pattern action. name_pattern should match a directory in the repository, and CVS will apply this rule to all files in that directory. The pattern used is a regular expression, described in info cvs. CVS tests the pattern against the directory's relative path, starting at the repository root directory.

There are two special patterns, ALL and DEFAULT. An ALL rule is used on files in any directory. A DEFAULT rule is used if no other patterns (excluding ALL) match.

action is a command-line template for the path to a script (or commit message template), plus any parameters required for that script or template. The script or template must be able to read from standard input (stdin). CVS will append its own parameters to actions.

Lines in scripting files that start with the hash symbol (#) are comments and are ignored.

commitinfo

commitinfo scripts are often used to verify whether checked-in files conform to company standards or to enforce exclusive development. CVS passes the relative directory path and a list of all files in that directory involved in the commit as parameters. If the action of the rule returns a non-zero value, the commit does not proceed.

CVS makes a set of normal-format files from the data it receives from the CVS client, storing them in a temporary directory. If the action reads (or tries to modify) the file, it reads the file in the temporary directory. Any modifications are discarded after the action is processed.

loginfo

The loginfo file is most often used to control where (aside from the RCS files) the log information from a commit is sent. It can also be used to trigger actions, such as notifying all developers of changes, maintaining a file that logs a record of changes, or exporting the changed files to a file server.

CVS passes the log message from the commit as well as the repository path being committed to, followed by an expanded format string, all on standard input. The format string is part of the action and controls the information that CVS passes to the script or command. The string consists of a % followed by a space, a single variable, or a set of variables enclosed in braces {}. The variables are:
s
Expands to the name of the current file being processed.
V
Expands to the file's revision number prior to the commit.
v
Expands to the file's revision number after the commit.
When CVS process the format string, the output is in the form variable_expansion [variable_expansion...]. CVS will generate a variable expansion for each file that was committed, consisting of a comma-separated set of strings. %{sV} would be expanded to a string like main.c,1.3. Dollar signs ($), backticks (`), backslashes (), and quotation marks (") in the repository path or filename will be escaped with backslashes.

verifymsg

The scripts in the verifymsg file often either check or modify the log message you enter when you commit files. CVS passes the path to a temporary file containing the commit log message and copies the log message on standard input (stdin). If the script returns a non-zero value, the commit does not proceed.

The script can modify the log message. The RereadLogAfterVerify option in the config file in the repository's CVSROOT directory determines whether the original or the modified log message is used.

The ALL pattern is not supported in the verifymsg file.

Click Here to Read the Full Article


About the Author:
Jennifer Vesperman is the author of Essential CVS. She writes for the O'Reilly Network, the Linux Documentation Project, and occasionally Linux.Com. As a programmer and system administrator, she currently works with Cybersource, an Australian IT consulting firm. She is the current Coordinator for LinuxChix, an advocacy and support group that focuses on women who use and develop open source programs (especially Linux). cover

 

 

 

 



 

 

 

 

-- LinuxProNews is an iEntry, Inc. publication --
2003 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal