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 z
the last letter of your actual
group name (the one that I will give you after you send me your group membership request).
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 /projects/instr/08au/cse451/z/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=/projects/instr/08au/cse451/z/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. The cvs repository initialization should be done only once for all projects, but you will need to import the sources for each project).
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 /projects/instr/08au/cse451/z
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. Suppose you want to import the sources for project1 and suppose you already have a project directory in your home directory: call this directory project1. Then:
cd into the project1 directory
cvs import project1 PROJECT1 PROJECT1_1_10
cd ..
rm -rf project1
We can now checkout a sandbox (local copy) to work on. CVS will create a directory named project1/, and put a copy of all the source files that already existed in your project1 folder in the new directory. CVS will also add a CVS/ directory where it stores data about what you've checked-out. Do not delete that directory!
Cd to the location where you want to keep your project sources in your home directory and type:
cvs checkout project1
cd project1
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 project1 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 forkbomb; you just need to tell it where the repository is. Use a slightly different CVSROOT:
setenv CVSROOT forkbomb.cs.washington.edu:/projects/instr/08au/cse451/z/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.)