Notes on using CVS


What is CVS

CVS (Concurrent version system) is a version control system intended to allow multiple developers to work concurrently on a project. Each developer has a copy of the source tree(s) that they need to do their work. Their copies are checked out of a central repository that keeps track of versions. Various commands are available to keep developers synchronized with the repository and each other. CVS can also operate in a client-server mode that allows remote developers (i.e. not sharing the filesystem) to work with the repository.


Using the 15-612 Repository

The 15-612 afs volume has a CVS repository in:

   /afs/cs/academic/class/15612-s98/repository
If you plan to work with the repository, you must set the CVSROOT environment variable to this directory name.

The class and project directories under 15612-s98 and all their subdirectories are checked-out copies from the repository. If you are using CVS, you should not modify files in these directories. The correct procedure for updating files in the repository is to check out the appropriate files into your home account, update them, then commit the changes. For example:

  setenv CVSROOT /afs/cs/academic/class/15612-s98/repository
  cd ~/cs612
  cvs checkout class/andyb
  cd class/andyb
  cvs edit andyb.html
  vi andyb.html
  cvs commit -m"Updated with ..."

This checks out copy of the files in class/andyb into my cs612 directory. The cvs edit andyb.html command makes the file writable and lets other developers know that I am working on the file. After editing, the commit updates the repository with any changes I have made. I can now update the files in the 15612 directories from the repository, for example:

   cd /afs/cs/academic/class/15612-s98/class/andyb 
   cvs update

Whenever you want to create a new file or directory, create it in your checked out copy of your class directory, tell CVS about it, and it will be stored in the repository next time you commit. For example:

  cd ~/cs612/class/andyb
  touch hobbies.html
  cvs add hobbies.html
  cvs commit -m"Initialised my hobbies page"

Other CVS commands

cvs watch Used to toggle read-only checkout of prjects and to get CVS to send you email when someone else edits a file.
cvs status Reports the current status of files in a project.
cvs log Prints the revision log for a file or files under CVS control.
cvs release Removes the working copy of a project.
cvs diff <file> Compares your version of a file with the current repository version. The "-c" flag gives context diff output which is generally easier to follow.

Why use CVS

For creating your web pages, CVS provides revision control so that you can retrieve old versions of files. It also gives you a structured way of updating your pages and testing them in a private place, then making them public when you are happy with them. You could possibly achieve a similar result, however, with other version control systems and careful file management.

Once you begin your group projects, the advantages of CVS become more obvious. Firstly, each group member can check out their own copy of the source tree and work in a largely independent manner. CVS is available for both Unix and Windows 95/NT environments, so individuals can choose their preferred platform. You can even check out a copy onto your dial-up home PC and work on it at home (although you must be connected to execute cvs commands).

When changes are committed, CVS flags any conflicts with changes by other developers in the source file, inviting you to resolve the conflicts. It will perform some automatic merging of changes, although this is rudimentary and needs to be checked for consistency in the source code.


Caveats

Binary files
Binary files are difficult to manage with CVS. If all developers are using Unix, there are flags you can set for a file that mark it as a binary file and everything works most of the time. If any developers are using Windows 95/NT, then binary file management is flakey and should be avoided.
Security and remote access
Remote access to CVS has some security holes unless you use the kerberos authentication or secure rsh for access to the server. Since most people at CMU can use secure rsh, this will not generally be a problem. If you do not have secure rsh, however, setting up kerberos for the CVS server requires administrative privileges and is non-trivial.

More information

Perhaps the best starting point for information on CVS is the Cyclic home page. The developers there are primarily responsible for the Windows port of CVS, and they have links to many other CVS information sources. The online documentation for CVS is reasonable and includes both Unix man pages (man cvs) and GNU info pages (which require emacs or a standalone info reader). Other questions can be directed to me.


Andrew Berry <andyb+@cs.cmu.edu>