Using CVS Triggers to synchronize a checked-out copy of your CVS Tree

Category: Software and Systems Engineering
Author: Sean O'Donnell
Wed, Oct. 18th, 2006 @ 2:23:26 (MDT)

When working with a CVS Server, you can create triggers for (all or specific) CVS Repositories, which allows you to automate certain processes, such as updating a checked-out copy of the CVS Tree on the Server (or NFS/SMBFS share), or create an email-log of the transactions on the server (or specific repository).

This is a common practice for rapid development environments that utilize CVS, and is really a nice way to organize things, in my opinion.

Checking-out the CVS Tree

This example will focus on setting up a trigger that will update a checked-out copy of the CVS Repository on the same machine.

Assuming that you followed my previous guide to setting up a CVS Server, and have all your environment variables set properly, you can then begin by checking-out a project to a path on the server.

For this example, the checked-out copy will be stored under: /www/htdocs/projects/example

mkdir -p /www/htdocs/projects
cd /www/htdocs/projects
cvs co example

You should now have a checked-out copy of the repository 'example' in the '/www/htdocs/projects' directory. (e.g. /www/htdocs/projects/example/)

Synchronizing the Checked-out copy of the CVS Tree using the CVS 'loginfo' Trigger

The trigger example below will update the checked-out copy of the CVS Tree (/www/htdocs/projects/example) everytime a CVS transaction is completed for the 'example' repository.

This trigger is stored in the 'loginfo' file, within the CVS Repository (/home/cvs/CVSROOT)

# file: /home/cvs/CVSROOT/loginfo
^example    (date; cat; (sleep 2; cd /www/htdocs/projects; cvs -q update -d) &) 2> /www/htdocs/projects/cvs.error

If any errors occur, they will be logged to the '/www/htdocs/projects/cvs.error' file.

The purpose of this technique is to allow you to keep a 'live' synchronized checked-out copy of the CVS Tree, which is handy if your CVS Server and Web Server are running on the same machine, or sharing files via NFS/SMBFS, etc.

Copyleft (<) 1998-2019