Using CVS to submit assignments

Overview

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 assignment files, and I will be checking them out to grade. I encourage you to check in changes often, but in the end you just need to make sure the required files are checked in by the deadline.

Initial checkout

First, you must check out your directories from the repository. This will give you your own working copy of the files. Do not work directly in the repository, CVS will get quite confused, and I won't be able to check out your code to grade it.

GL systems

Ideally, you will check out a working copy on the system where you will be developing. As a fallback, you can check out a copy on the GL systems and copy your files there to check in. To check out a copy on the GL systems, you'd use a command like this

cvs -d /afs/umbc.edu/users/o/l/olano/pub/gfg checkout -d new_directory_name your_umbc_login
For example, I might do this:
cvs -d /afs/umbc.edu/users/o/l/olano/pub/gfg checkout -d cs491work olano

This will create a directory called cs491work containing a new working copy of my files. This is the only time you need to tell it where the repository is. After the intial checkout, once you cd into your working directory, CVS can figure out which repository to use. All of the major CVS commands apply to the current directory and all directories under it.

Remote with command-line UNIX/Mac CVS

For other UNIX systems, including the Mac, you can access the repository remotely using SSH. First, set an environment variable to tell CVS you want to use SSH. How you do this depends on what shell you use. If you don't know, type echo $SHELL at a command prompt. If it says bash, sh or something similar, type this:

export CVS_RSH=ssh

If it says tcsh, csh, or something similar, type this:

setenv CVS_RSH ssh

Then, follow the GL systems instructions, but adding linux.gl.umbc.edu: to the front of the repository path

cvs -d linux.gl.umbc.edu:/afs/umbc.edu/users/o/l/olano/pub/gfg checkout -d directory_name your_umbc_login

Remote using Windows or Mac GUI

There are graphical user interfaces for using CVS on both Windows (WinCVS or TortoiseCVS) and Mac (MacCVS). The exact instructions for using them with SSH depends on which you choose, but instructions are easily found online. The general idea is to set up a SSH client (you probably already have one if you ever remotely log into the GL systems), tell your CVS client how to find it, then tell it where the repository is.

If you are using a GUI client, of course you will also be using the GUI to perform the commands described below.

Editing

Edit away... No need to do anything special

Adding, removing, and ignoring files

If you add files, you need to let CVS know so they'll be checked in:

cvs add file

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

cvs remove -f file

To tell CVS to ignore a file add it to the list in the .cvsignore file in that directory (you should do this for any generated file including executables and images we'll generate by running your program) .

Checking in your changes

Your changed or added files are not copied to the 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. First do this:

cvs -q update

Files CVS doesn't know about will be listed with a '?'. Next, tell CVS to add or ignore each of them, then try the update again. It's good practice to make sure CVS knows about every file before you commit any check in.

Now check them into the repository:

cvs commit

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 in the checkin. This message is for you: I 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), but whatever editor you use must not normally return to a prompt right away, and you must quit that instance of the editor after writing your log message for the commit to complete. (CVS tells that you're done editing the log message when the editor returns)

Now check to make sure it worked:

cvs -q update

This time, it shouldn't list any files. If it does, something went wrong. Make sure you've told CVS to add or ignore if necessary, and try again, or ask for help. The first time you check in, you may want to follow the checkout directions to make a second copy (under a different name), just to see what we'll get.

Getting updates and previous revisions

If I make any changes to the initial sample files (or add some for the later assignments), you can get these using

cvs update -d

You can compare your current file with any previous version (dates are GMT; for a local date, use something like '1/1/05 13:15 EST')

cvs diff -D date file

To figure out which revision is which (reasonable log messages when you commit help), do

cvs log file

Learning more

List of all CVS commands (in particular, in case you want to get back an old version of a file)

cvs help

Help on any one CVS command

cvs --help command

General CVS manuals, downloads, etc.: www.cvshome.org