CS121 Software Development
CVS Tutorial (Turing)
Concurrent Version Control (CVS) is a system for managing project files during
development.
You create a central repository for your files. Team members can checkout files, modify them,
then check them back in.
CVS stores your modifed file as the latest version, while preserving the previous one. If need be,
you can restore an old version of the file.
Before using CVS, one member of your team should set up the repository. Instructions
are provided here.
You can access the CVS repository from your Turing account or from a windows box using Tortoise CVS. These
notes describe using CVS on Turing. For more info on Tortoise CVS look here.
You should keep (at least) your source code and documents under CVS. You probably
don't want to keep object and executable files (or visual studio project files) since
they are easily recreated and because CVS doesn't always handle these files correctly.
Before using the repository you need to do two things:
-
You need to declare the repository you'll use. From the command line issue the
command
setenv CVSROOT /cs/cs121/year/semester/teamj/CVS
where year is the current year (e.g. 2004), semester is the current semester (i.e. spring or fall),
and teamj is your team (e.g. team4).
To verify the directory has been declared correctly issue the following command from the command line.
echo $CVSROOT
To avoid having to issue the command every time you logon to Turing you can add the setenv command to
your ~/.cshrc file.
-
The next thing you have to do is create your own copy of the repository files. Suppose your cvs repository contains
a directory called proj1 and you want to copy this directory to your directory ~/cs121. You'd issue the
following commands
cd ~/cs121
cvs checkout proj1
The contents of the directory /cs/cs121/year/semester/teamj/CVS/proj1 will be copied
to ~/cs121/proj1
Once you've followed these steps you can modify your files and check them back in, checkout new versions of
files, and add new files to or remove existing files from the repository. To explain how to do these things, we'll continue with the previous
example.
-
Saving changes: Suppose you've modified one or more files in your ~/cs121/proj1 directory. To save the modifications
do the following:
cvs commit
CVS will drop you into an editor to log your changes. Describe the changes
you've made and exit the editor. Your changes are now stored in the
repository.
Suppose two team members check out a file at the same time, modify their copies, then try
to commit their different versions. CVS will commit the version checked in first. When the second person
tries to check in their version, CVS will try
to reconcile the changes. If it can't, it will complain.
-
Update your files:
To update the files you have checked out, do the following:
cvs update
Files that are out of date with the respository will be overwritten by their latest version.
-
Add new files:
Suppose you've created a new file called tmp.cpp in your ~/cs121/proj1 directory. To add this to
the CVS repository do the following.
cd ~/cs121/proj1
cvs add tmp.cpp
cvs commit
You'll be dropped into an editor to create a log entry documenting the addition. Add the comment "adding tmp.cpp to
proj1" then exit the editor.
If you add several files, you needn't commit them individually but rather can do one commit for all of them. But
it is important to remember that "cvs add" does not create a new file in the repository until a "cvs commit" command is issued.
-
Add new directories:
You can add a new directory in the same way you add a new file. For example,
suppose you've created a new directory called doc in your ~/cs121/proj1 directory. You can add doc to
your CVS/proj1 repository by doing the following:
cd ~/cs121/proj1
cvs add doc
cvs commit
This creates the doc directory in the
repository but does not create files contained in doc.
You need to add those files individually. Alternatively, you can import an entire
directory. Rather than doing the add/commit described above you could have
cd ~/cs121/proj1/doc
import doc yes ok
This will add the doc directory and its contents to the proj1 repository.
-
Removing files: To remove the file tmp.cpp from the proj1 repository do the following:
cd ~/cs121/proj1
cvs remove tmp.cpp
cvs commit
You'll be dropped in an editor to document your changes.