CVS tutorial
From NYU CCPP Wiki
CVS is a version control system that allows multiple users to work on a codebase simultaneously. It is used to keep your working copy of the software up-to-date with those of the other users, and to propagate changes you make back out to the others.
The CVS documentation is pretty good. Use that if you can. If you are getting started on our system:
Contents |
Dotfiles
You ought to grab dotfiles from user "dataman"; at the very least you need the environment variable CVS_RSH set to value "ssh".
Getting started
If you have an account in the CCPP: To "check out" a CVS module, eg, "eplusa":
cvs -d user@howdy.physics.nyu.edu:/usr/local/cvsroot co eplusa
where "user" is your username in the CCPP. This will make a directory "eplusa" in the current working directory, with subdirectories containing code and documentation and papers.
If you do not have an account in the CCPP: Check out with:
cvs -d :pserver:rcvs@howdy.physics.nyu.edu:/usr/local/cvsroot co eplusa
In this case (ie, no account in the CCPP), you can only check out and update, you cannot commit or check in.
Editing a file
Before you edit any file, in the directory where the file resides, "update" to the current version with
cvs up
If no "C" lines appear, everything is cool (if "C" lines appear, you have a "conflict" you need to resolve; see the manual)
After you are finished editing the file, check your changes
cvs diff [filename]
where "filename" is the name of the file you have changed. When you are happy with your change, check it back in to the CVS module with "commit":
cvs commit -m "comments here" [filename]
This propagates your changes back into the CVS repository (that contains the module, and all the previous revisions of all the files therein). For more information, consult the manual.
Adding a file
If you create a new file or directory, you must "add" it with
cvs add [filename]
If it is a directory, it will now be added to the repository. If it is a file, it still needs to be "checked in" or "committed" with
cvs commit -m "start" [filename]
or equivalent. The "-m" prefaces a comment which will be associated with this revision (in this case "start").
Some simple tasks
To get the dates and comments of revisions:
cvs log [filename]
To get an old revision:
cvs co -r [revision] [full filename]
with [full filename] being the full path including the name of the module. This will put this old revision in a subdirectory (which is usually what one wants).
To compare two revisions:
cvs diff -r [rev1] -r [rev2] [filename]
To compare the current state of the repository to your version:
cvs diff
Specifying a filename will look only at that one file.
Starting a new module
If you have files in a directory "wdir" that you want to import into a module called "mname", change directories into "wdir" and type:
cvs import -m "new module" mname mname start
Editorial comments
- Life is a lot easier if you set up SSH keys, so you don't have to type your password endlessly.
- Things get hairy when multiple people are making large edits on the same code simultaneously, so try to make your edits "atomic" and "cvs commit" frequently.
- If you are working on a code base used by others, don't check in code that doesn't compile.
- If your code has limitations, or problems, or bugs, note them in a comment header of the code, not in the CVS log (ie, not in the CVS commit operation), since no-one ever really uses the CVS logs.
- Try not to break "backwards compatibility".
