Using CVS to Submit Projects


CVS is a popular free revision control system. It is designed to allow one or more people to work on the same project, keeping checked in versions of files in a common repository. Its main use is for managing source code in projects with multiple developers, and it includes some pretty nifty support for merging independent changes to text files. In fact, using some sort of revision control is almost required for any reasonably complex software project. The revision tracking features are pretty handy even when working alone. You can go back to any revision of your files that was ever checked into the repository, either by revision number or date.

In our case, you will be checking in your project files, and the TAs will be checking them out for radeng. We encourage you to check in changes often, but in the end you just need to make sure the required files are checked in for each project by the deadline.

Initial checkout

First, you must check out your directory for the current project from the repository. This will give you your own working copy of any files supplied by the instructors for the project as well as files needed by CVS to manage your code properly. Do not attempt to work directly in the repository, CVS will get quite confused if you do this, and we probably won't be able to check out your code to grade it. On the GL systems, you'd use a command like this:

cvs -d /afs/ 
checkout -d directory_name_of_your_choice your_umbc_login

For example, if your username is jones5 you might use the following command line to check out project 0:

linux2[6]% cvs -d /afs/ checkout -d MyProj0 jones5

This will create a directory called MyProj0 containing everything you need to start using CVS for the project. This is the only time you need to tell CVS where the repository is located. After the intial checkout, once you cd into your newly created directory (in this case, MyProj0), CVS can figure out which repository to use. All of the major CVS commands apply to the current directory and all directories under it.

Create the directory structure

After checking out your repository,

Write and Test your code

In your src/package directory

Commit your Java files to CVS to save your changes for the next time your work on your project.

Submit your code

Once you're ready to submit your code for grading

Do not submit your .class files or any files used by Eclipse.

CVS Utilities

You are strongly encouraged to verify that your files have been submitted properly by using the CVS utility scripts. These scripts mimic the building and testing of your code in the same way as the scripts used to grade your code. These scripts are provided for CMSC 341 students and are not CVS commands. Thanks to Dan Hood.

CVS Details

All CVS operations are performed with the cvs command followed by the operation name and/or arguments for the operation. Descriptions of the most common CVS operations are given below. See for the complete on-line CVS manual including a complete set of CVS commands.

Adding and removing files from CVS control

When you create new files for your project, such as a new .java file or directory, you need to tell CVS about it by adding the file or directory to CVS.

linux2[7]% cvs -d /afs/ add filename

To tell CVS you're removing a file (so it won't come back next time you update — see below):

linux2[4]% cvs -d /afs/ remove -f filename

Checking in your changes

Your changed or added files are not copied to the CVS repository until you check them in. You must do this for us to be able to check out and grade your work, but you can do it as many times as you want before then.

linux2[5]% cvs -d /afs/ commit -m "A change message" filename

You should only commit your build.xml file and the contents of your src/package directory (i.e. .java files) for grading. Directories are not committed, only added. Please DO NOT commit the contents of your bin/ or doc/ directory. These will be recreated by the grading scripts.

If you do not use the -m flag an editor will pop up, showing you a listing of what will be checked in. You can enter a log message here to say what was changed. Be sure to EXIT the editor properly after entering your message. ABORTING the editor will result in your file being locked in CVS. If this occurs, use the cvsreset utility to clear your repository. Note that it will be necessary to "add" and "commit" all of your files to your repository in order to replace them. Be sure to read the cvsreset documentation carefully before proceeding.

We will not look at the log messages for grading, but it can be useful if you want to look back at old versions later. You can change editors by setting the EDITOR environment variable (the default editor is vi).

Getting updates

If we make any changes to files we supply (or add some for the later assignments), you can get new versions of these files using the cvs update command. This command pulls down new versions of files from the repository to your local directory. You can also use this operation to get a copy of a file that you accidentally deleted.

cvs -d /afs/ update -d
The cvs update command is used by the CVS utility scripts or can be performed manually to validate your submittal.

If all files have been added and committed to CVS, cvs update is quiet.

linux3[101]% cvs -d /afs/ update -d
cvs update: Updating .
If there is a file in your working directory that has not been added to CVS, its name will be prefixed with '?'. Add and commit the file to CVS.
linux3[104]% ls  build.xml  CVS
linux3[105]% cvs -d /afs/ update -d
cvs update: Updating .
If there is a file in your working directory that has not been added to CVS, its name will be prefixed with 'A'. Commit the file to CVS.
linux3[106]% cvs add
cvs add: scheduling file `' for addition
cvs add: use 'cvs commit' to add this file permanently
linux3[107]% cvs -d /afs/ update -d
cvs update: Updating .
Files which are pulled down from the CVS repository to your working directory are prefixed with 'U'.
linux3[117]% cvs -d /afs/ update -d
cvs update: Updating .


In each of the command examples above, we used the -d switch to specify the location of the CVS repository … e.g.
-d /afs/
This switch can be omitted from your CVS commands if you have set the CVSROOT environment variable.

To set CVSROOT for your current login session, use the unix command

linux2[12]% setenv CVSROOT /afs/
Note that you must issue the setenv command each time you login and use the path that is appropriate for the current project unless you set CVSROOT permanently.

You can set CVSROOT permanently by addng the setenv command above to your 
.cshrc file (found in your home directory … note the leading "dot").  
Be sure to change the command in your .cshrc file for each project.

In either case, you can verify that CVSROOT is set properly by using the echo command to display its current value.
Note the "$".

linux2[3]% echo $CVSROOT

Learning more

General CVS manuals, downloads, etc.: