These notes borrow heavily from Bradley Kuszmaul's CVS instructions.
CVS uses a special directory, called a repository, in which it keeps all versions of each file. The repository can have subdirectories, which correspond to subdirectories that you have.
You work in your own directory, distinct from the repository. We'll call your own directory the sandbox.
When you are working on files, you can easily get the latest versions from CVS into your sandbox. When you're ready to check in your changes from your sandbox, CVS will determine whether your changes conflict with changes to the same file(s) made by others and give you an opportunity to resolve the changes.
The main thing you should find is that, after a little bit of initial setup, CVS is pretty easy to use and very nice to have around.
You can get detailed information about CVS from the CVS man pages.
You inform CVS that you're putting bozo.cc under its control with the
command
CVS can control entire directories. If you want to put a directory
under CVS's control, you create it and add it. For example, if we're
in ~vezina/cs23/sandbox,
When you create a subdirectory, CVS immediately updates the
repository. It deals with directories a little differently than
files.
If you need an entire directory, and you were not the one who added it
to the repository, and you are about to use it for the first time, you
need to check it out. You can do so in one of two ways.
Once you've checked out what you need for the first time, there's a
really good way to get the latest version of everything in the current
directory and all subdirectories beneath it:
The way that
When you run
If all goes correctly, when you use
Anyway, once you run
By the way, if you want to, you can check out individual files rather
than all the files (as
First, you run
Next, you run
Unfortunately, CVS seems to use a different /tmp file each time you do
a
I would recommend not using
By default,
The file names you list in .cvsignore may include * and ?, which
expand in the usual way that the shell matches file names.
For example, when I work on revisions for Introduction to
Algorithms, I work on my machine at Dartmouth, but the repository
is on the machine theory.lcs.mit.edu in the directory
/a/clr/repository. I just have to set the following environment
variables:
Jan reports that he needed to do both of these settings in his
.cshrc file rather than his .environset file. I'm not sure why
he found that to be the case.
man cvs will tell you more than you want to know.
Perhaps a better source is the info function of emacs. You can get
all sorts of information about CVS in emacs by the following sequence:
C-h i g (cvs) How to set up a repository and start using
CVS
M-x
gnuserv-start and M-x set-var gnuserv-frame t,
and from regular emacs enter
M-x server-start.
In fact, you may find that the "server" shuts itself
down automatically every now and then, and you'll need to
M-x gnuserv-start or
M-x server-start occasionally to restart it, even
though you have the (gnuserv-start) or
(server-start) line in your
.emacs file. I have no idea why this happens.
How to make changes to files that are under
control
Adding a new file or directory
Suppose you want to put a brand new file under CVS's control. First
you create it, presumably using emacs. Let's say that you have
created ~vezina/cs23/sandbox/bozo.cc, and let's assume that your
current directory in the shell is ~vezina/cs23/sandbox.
cvs
commit command.
Getting ready to make changes
Before you make changes to a file, you need to get the most recent
copy from the repository.
cvs update command is definitely your friend. You'll
also use it to check in changes. In this situation, where you want
the latest version of everything before you start working, it modifies
the files in your sandbox to reflect the changes that others have made
behind your back.
cvs update modifies your files is a little
weird sometimes, but it also keeps the original, unmodified file
around, but under a different name (see below).
cvs update, you'll get a list of the files
it has updated, along with an indication to the left of each one.
cvs update doesn't know whether you're trying to get the
latest version of everything or you're trying to check in changes.
Interpret the indications as follows:
A filename
filename.
U filename
filename.
M filename
filename.
? filename
filename exists in the sandbox,
but you never told CVS about it.
C filename
filename, and
so did someone else. The file has been modified using the
rcsmerge command to bring in the changes that they
made. The format that shows the changes is rather confusing.
However, the original, unmodified file is stored in the same
directory as the original under the name
.#filename.version, where
version is the version number of the file
you started from.
cvs update to check
out your files, you should not see the M and
C indications. Seeing the M indication
isn't so bad; it just means that you hadn't checked in the file.
Seeing the C indication can be bad, however, since it
means that two of you are editing the same file. It's a good idea to
stop and coordinate at this point.
cvs update, you should have the
latest version of everything you've told CVS about, and you are ready
to edit.
cvs update does). If you want to
check out bozo.cc from the repository, just type
Checking in your changes
Checking in your changes is the same as putting your files back
into the repository.
cvs update to make sure you're coordinated
with everyone else. Watch out for those C indications,
though.
C-x
# (control-x pound) to indicate that you're done. Emacs will
ask whether to save a file whose name starts with /tmp. (All files in
the directory /tmp are considered temporary files by UNIX and are
removed periodically.) Just type a "y". The commit procedure will
proceed from there.
cvs commit, and the buffers for these files don't
automatically go away in emacs. But you can get rid of these buffers
safely any time after you save them. (From emacs, C-x C-b gives you a
list of all your buffers. Type a "d" next to each one you want to get
rid of, then type "x" to "expunge" them, i.e., actually get rid of
them. Then you can click on the name of whichever buffer you want to
go back to.)
Change logs
You can put a change log directly in your file. It's really easy.
All you have to do is put a comment whose contents is
$Log$ in your file. In a .h or .cc file, put a line
Changing file names
If you want to change a file name, e.g., bozo.cc to clown.cc, the best
way is to simply rename the file, remove the old file from CVS's
control, and add the new file:
cvs commit command. To get back a removed file, say
bozo.cc, type
cvs commit following a cvs
remove command, you'll find it tough to get the file back. (It
can be done, but it's a pain, so don't do it.)
cvs remove during your
project.
Ignoring files
If you create a file named .cvsignore (note the dot in front) that
contains a list of file names, the cvs update command
will ignore these files. Of course, if any of these files have been
added via a cvs add command, then cvs update
will not ignore them.
cvs update ignores files whose names end in ~
(backup files produced by emacs) and .o (object files). Strangely
enough, cvs update does not know enough to ignore the
.cvsignore file! So you will probably want to include .cvsignore as
one of the files listed in .cvsignore.
Using CVS remotely
You won't need to use CVS remotely for this project, but it's nice to
know that you can. What I mean is that your repository can be on a
machine at some other site.
Using CVS from OS X on a Mac
A CS 23 student, Jan Wellford, reports that after some effort, he was
able to use CVS from his Mac running OS X. He said that he needed to
do the following:
CVSROOT environment variable to
tahoe.cs.dartmouth.edu:/u/gump/cs23/repository ,
where the repository is in the directory ~gump/cs23/repository .
Note that you must use the /u/gump form of gump's
home directory, rather than the ~gump form.
CVSEDITOR environment variable to
emacsclient .
CVS_RSH
environment variable.
topliff-dhcp-238.dartmouth.edu wellford
How to avoid typing in your password every time when
using ssh
If you use ssh as your way to login to another machine, you can set it
up so that you don't have to type in your password each and every
time:
As long as you're on CS department machines, you won't need to type in
your password any more when connecting via ssh. If you're connecting
to a remote machine, copy ~/.ssh/authorized_keys to a file by the same
name in your account on the remote machine.
Thomas H. Cormen <thc@cs.dartmouth.edu>
Last modified: Fri Feb 15 09:13:41 2002