CVS Quick Start Guide for CS162

Matt Welsh, mdw@cs.berkeley.edu

Last updated 9 February 2001

Group IDs and Members

Each project group has a CVS group ID associated with it. This group ID is of the form cs162-gNNN where NNN is a number representing your group. You can find out your group ID by looking up your user ID in this list of users.

In order to use CVS, you should login to your cs162 instructional account. Be sure that your login shell is either csh or tcsh; this should be the case by default, but if you have changed your shell (say, by running chsh), you need to change it back. This is very important.

After logging in, run the command

  cvsgroup cs162-gNNN
where cs162-gNNN is your group ID, as explained above. This command will ask for your SSH passphrase. If you do not have an ssh key, or change your key, you must inform the staff so that we can update your key in the CVS groups database. Some users have not generated a key yet; please run
  ssh-keygen
and then let us know so that we can add you to your group.

Once this command has been issued you can use CVS commands. All commands will automatically refer to your group's CVS repository, which is accessible only through this mechanism. The repositories are located on a different disk from your class directories. This means that you will not have to sacrifice any disk space.

You should not need to set CVSROOT or any other environment variable to use CVS; after running the 'cvsgroup' command everything is set up for you. It probably makes sense to run cvsgroup from your .login script so it's executed every time you login.

Setting up a repository

  1. One group member (ONLY!) should import the Nachos code into the repository. To do this, cd into the Nachos source directory and type
      cvs init
      cvs import nachos groupid start
    
    to import the Nachos files into your CVS repository. Be sure to run these commands from the 'nachos' directory! Otherwise you will recursively import everything in the current directory into CVS, which is probably not what you want.

    Since you just imported this code into the repository, you want to get rid of the original nachos directory, and work on the version you will check out in the next step. So, move the directory nachos out of the way:

      mv nachos nachos.old
    
    Only one member of each group should use these commands; all other members will skip this step and continue on.

Basic CVS Usage

  1. First, check out a local copy of the Nachos code:
      cvs co nachos
    
    This will create a nachos directory with all of the Nachos code in it.

  2. Edit your local copy of the files.

  3. When you are ready to make your changes available to other members of your group, commit the changes back to the repository:
      cvs commit
    
    This will start up an editor for you to enter a log entry describing your changes. It makes a lot of sense enter a descriptive entry of the changes you made -- this will make tracking changes a lot easier.

    Note that you cannot commit changes unless your local files are up to date: that is, that you have been editing the most recent copy. See the next step for details.

  4. For other users to see the changes, they need to do:
      cvs update -d
    
    which will update their local files to be in sync with the repository.

    If there are conflicts (that is, someone else edited the same file while you were in the process of editing it), you will be notified at this point and given a chance to fix the conflict. You will not be able to do a commit until you resolve the conflict. In order to fix a conflict, you edit the conflicting file, which will contain new lines with both the old and new versions. Decide which version you want to keep (or merge them somehow).

    cvs update and cvs commit list all the files they touch preceded by a one-character code signifying the change. Here is a quick key to the code:

  5. To add a file or directory to the repository, just do:
      cvs add filenames...
    
    After cvs add you need to cvs commit for the addition to take effect.

  6. To remove a file, first remove it from your local copy:
      rm filename
    
    Then remove it from the CVS repository:
      cvs remove filename
      cvs commit
    

Other CVS Features

You can check out copy of code as it looked at a given time:

  cvs co -D "yesterday" nachos
  cvs co -D "1/26/01 8:00" nachos

You can tag a version of the file or tree for later use. This allows you to check out (or otherwise refer to) that particular version of the tree later on. For example, if you have a good, working version of the code and want to tag it as such, you can do:

  cvs tag working1
Later, you can check out the exact version of that code:
  cvs co -r working1 nachos

You can also look at a 'diff' of changes from one version of the code to another:

  cvs diff -D "yesterday"
  cvs diff -r 1.3 foo.java
Also, the cvs log command will show you the log entries for each version of files in the tree, so you can eyeball the changes that were made over time.

Type man cvs to get a lot more information on using this wonderful tool.

Important Caveats!

Note that CVS does not allow you to rename files - you need to "remove" the file and then "add" the file under the new name. In general it's best not to rename files, since this loses all of the editing history for that file.

Also note that CVS does not allow you to remove or rename directories once they have been added to the repository. THIS IS VERY IMPORTANT!! Do not add directories to the repository temporarily - you can never get rid of them. This is a real drawback to CVS, but it's something you just have to live with.

Generally it is best to only check in source files to the repository -- anything that can be generated (say, a Java .class file) should not be checked in, since it's redundant (and confusing if the generated .class files don't match up with the source files).