CVS is a very useful, and widely used, tool for source control. Basically, it manages the sharing of your source files between multiple programmers, leaving you to just do the actual work.
There is a lot of good information on CVS available from other sources (including, for example, a tutorial and cvs(1)). This tutorial is intended to be short and cover material unique to CSE 451.
Throughout the examples, replace cse451z
with your actual
group (as given by the group registration tool).
We need to tell CVS where to find your repository. We could do that every time we run cvs using the -d flag, but instead, we'll set an environment variable that will be implicitly passed to all programs run by this shell.
setenv CVSROOT /cse451/projects/proj2/cse451z/cvs
(The above example assumes you are using csh or
tcsh, the default on instructional systems. If you are using
bash, the equivalent command is
export CVSROOT=/cse451/projects/proj2/cse451z/cvs
).
You only need to set the CVSROOT variable when using cvs
init
, cvs import
, or cvs checkout
.
The other cvs
sub-commands know what repository to use based on the
information in the CVS/ directory in your working directory,
which is created automatically by cvs checkout
.
(Only one person in each group needs to initialize the repository and import the source.)
First, we need to create a directory in your group's shared project space to hold the master copy of the code, or repository.
cd /cse451/projects/proj2/cse451z
mkdir cvs
Next, initialize the repository.
cvs init
(I suggested in section that you might need to update the
permissions on the new repository. It appears cvs init
sets the permissions correctly.)
You now have an empty repository. We need to import the simplethreads
distribution. First get a copy of the source, then use cvs
import
to add it to the repository.
tar -xvzf /cse451/projects/simplethreads-1.10.tar.gz
cd simplethreads-1.10
cvs import simplethreads SIMPLETHREADS SIMPLETHREADS_1_10
cd ..
rm -rf simplethreads-1.10
We can now checkout a sandbox (local copy) to work on. CVS will create a directory named simplethreads/, and put a copy of all the source files in the repository in that directory. CVS will also add a CVS/ directory where it stores data about what you've checked-out.
cd ~
cvs checkout simplethreads
cd simplethreads
As you make changes, you'll want to merge your changes with those other people make to the repository. From within your sandbox copy (ie your simplethreads directory):
cvs update
To commit your changes to the repository, so other people can use them:
cvs commit
For a quick list of cvs sub-commands:
cvs --help-commands
To add a file to the repository (you should only add source files, such as .c and .h files, not output files, like .os):
cvs add newfile.c
To check the status of a file, use:
cvs status file.c
Or to see the differences between your copy of a file and that in the repository:
cvs diff file.c
You can also specify a particular revision number to compare against:
cvs diff -r 1.1 file.c
Or to see the log entries about a file:
cvs log file.c
cvs commit
(and cvs import
) will prompt
you to enter a log message describing your changes (or import). They
do this by launching the process specified by the VISUAL
environment variable, or vi(1) if that is not set. So, if
you'd rather use emacs(1) to edit your logs, you just need to
set that environment variable (bash users see above):
setenv VISUAL emacs
You can also use CVS from a machine besides spinlock/coredump; you just need to tell it where the repository is. Use a slightly different CVSROOT:
setenv CVSROOT coredump.cs.washington.edu:/cse451/projects/proj2/cse451z/cvs
And set the CVS_RSH variable so CVS knows how to access the repository (in our case, using ssh(1)):
setenv CVS_RSH ssh
Note that, unlike CVSROOT, you need to set CVS_RSH for all (well, almost all) cvs sub-commands, so you might want to consider adding that line to your ~/.login file (or, for bash, add the equivalent line to your ~/.profile).
There may be problems with the Windows version of the cvs tool. I recommend avoiding running cvs on Windows (login to a UNIX/Linux box and run it there). (The cvs on Mac OS X is fine.)