Last updated 6 February 2002 (by Emil Ong)
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, add the following command to your ".login" file (note the ".")
cvsgroup cs162-gNNNwhere cs162-gNNN is your group ID, as explained above (for example, if you are in group 99, use cs162-g99). Now logout and log back in. 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-keygen1and then let us know so that we can add you to your group.
CVS often requires you to use an editor to make comments when you interact with the repository. By default, it uses the 'vi' editor. If you are unfamiliar with 'vi', you will probably want to change this. In your ".login" file again, add the following command
setenv CVSEDITOR emacsYou can replace 'emacs' by your favorite editor. Again, to make this change take place, you will have to logout and back in again.
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.
cvs init cvs import nachos groupid startto 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.oldOnly one member of each group should use these commands; all other members will skip this step and continue on.
cvs co nachosThis will create a nachos directory with all of the Nachos code in it.
cvs commitThis 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.
cvs update -dwhich 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:
cvs add filenames...After cvs add you need to cvs commit for the addition to take effect.
rm filenameThen remove it from the CVS repository:
cvs remove filename cvs commit
cvs co -D "yesterday" nachos cvs co -D "1/26/01 8:00" nachosYou 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 working1Later, you can check out the exact version of that code:
cvs co -r working1 nachosYou 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.javaAlso, 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.
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).