www.thornleyware.com

Providing customized source code control with CVS

The CVS edit facility

Description:

CVS is the "Concurrent Versioning System", and generally allows multiple people to be working on the same file concurrently, without bothering each other. This generally works very well, but in some cases it is necessary to restrict this facility, or to avoid using it altogether. For these purposes, CVS has the ability to mark files as being edited by one or more developers, and this can be used to implement locks as part of the development process.

For each file, CVS will maintain a list of editors (people who have specified that they are changing the file) and a list of watchers (people who want to know if anybody is editing the file). In order for this to work, it is necessary to remind people to "cvs edit" the file before they begin working on it. The CVS solution is to make the files read-only, and make them read-write when an edit is performed.

All this, of course, depends on the idea that developers will conform to the process, and not wilfully subvert it. This is not a big problem, since all software development depends on that. The voluntary lock system has generally been successful, whether the lock consists of writing in the master listing book, setting a CVS edit, a red flag, or a stuffed macaw.

Decisions:

How do you wish to use this facility? CVS has been shown to work fine for source code without such restrictions, since usually different developers do not work on the same parts of the same files. For binary files that cannot be merged, you might well want to make sure only one person is working on the file at a time. Alternately, you may want to permit multiple developers to work on the same file as long as everybody knows who else is working there.

Process:

The prerequisite to using this facility is to do cvs watch on at the highest CVS-controlled directory or directories, and this will cause CVS to make files read-only when added to a user's workspace. Without this, the users are going to forget to use the edit facility. (Malicious users can easily defeat this system, but malicious users can defeat any locking system, and must be dealt with by management.)

If it is desired to do this only to certain files, such as binaries, these should be flagged when added to the repository. This is best done with the loginfo files, which will run whatever programs you want after files are checked in. The specific process:

  1. Check out CVSROOT, and go to that directory.
  2. Put the cvs_watch_binary.pl program in CVSROOT.
  3. Add it with cvs add cvs_watch_binary.pl.
  4. Edit the file "checkoutlist" to include a line cvs_watch_binary.pl
  5. Edit the file "loginfo" to include the line
    ALL cvs_watch_binary.pl %s
  6. Check in your changes with cvs commit -m "Add cvs_watch_binary.pl"

All contents of these pages Copyright 2002 by David H. Thornley.
Permission granted for verbatim copying and use within an organization.


Contact: webmaster@thornleyware.com