CSC 509 CVS Basics

CSC 509 CVS Basics


1. Defining the CVSROOT environment variable (one time only)

cd ~
emacs (or vi or pico) .cshrc
Go to the end of the file and add the following five lines:
#
# CVS settings
#
setenv CVSROOT ~librarian/projects/CVS
umask 022
Exit the editor
source .cshrc

2. Initial library setup, in the librarian's project directories (one time only)

cd ~
mv projects projects-f99
cd ~509-librarian
tar cf - projects | (cd ~; tar xvf -)
cd www
ln -s ../projects .

3. Initial project checkout, from repository to individual team member directories (one time only)

cd ~
mkdir work
cd work
cvs checkout your-project

4. Checkin new work, from individual team member directory to repository

cd ~/work/your-project/...
edit some-file
cvs add some-file
cvs commit -m "log message" some-file

5. Checkout other team members' work, from repository to individual directory

cd ~/work/your-project
cvs update -d

6. Checkout (by librarian) of team members work, from repository to projects/work directory

cd ~librarian/projects/work/your-project
cvs update -d


7. Removing previous checked in files

To remove a file X that is already in the repository, do the following:

cvs remove -f X
cvs commit -m "..."
The "-f" option to remove tells cvs to force the removal of the file; this will both remove the file from your working directory and schedule it for removal from the repository. The cvs commit, as with add, will actually commit the removal.

8. Viewing the status of individual work files compared to the repository

You can get a short form file status list as follows:

cd ~/work/your-project
cvs -n -q update
The `-n' option means to not actually do the update, but merely to display statuses; the `-q' option avoids printing the name of each directory. When you use cvs update in this way, you will receive a list of files in your work directory that differ from the repository. Each file will be preceded with a one-letter code, described as follows:

Code   Meaning
-----+---------------------------------------------------------
U    | Another team member has checked in a changed version of
     | the file.  Use cvs update without the -n
     | argument to update your version of the file from the
     | repository.
M    | You have modified the file since the last time you
     | checked it in.  Use cvs commit to update the
     | repository from your file.
?    | You have created a new file that is not yet in the
     | repository.  Use cvs add and cvs
     | update to add your file to the repository.
A    | You have added a file (via cvs add) but not
     | yet committed it.  Use cvs commit to commit it
     | to the repository.
R    | You have removed a file (via cvs remove) but not yet
     | committed the removal.  Use cvs commit to
     | commit the removal from the repository.
C    | A conflict exists because someone checked in a file to
     | the repository that you have modified.  This case
     | should never happen given the CSC 509 convention that
     | only one person checks in a given file.  If it does
     | happen, contact the person in your group to resolve the
     | conflict and see Fisher for how to proceed.

You can get a long form file status listing as follows:

cvs status
This presents basically the same information as cvs -n update, plus more and in a more verbose format.

9. Telling cvs to ignore certain files, such as binary executables


Within the directory where the files to be ignored reside, add the names of the
files to a .cvsignore file.  Note that since .cvsignore is a regular
file, it should be added to the repository just like all other files.


10. Fixing permissions after a file is checked in

Whenever a file is checked in, you must ensure that its permissions are world readable. The umask setting of 022 (from Step 1 above) automatically makes all newly created files world readable, so this will be the normal state of your files.

If a file is checked in without world-read permissions, you can go to the repository and change the permissions there. This is possible since cvs retains file ownership to be that of the user who last checked in the file. To change permissions for a checked-in file named X in projects subdirectory D, do the following:

cd ~librarian/projects/work/your-project/D
chmod go+r X


index | lectures | handouts | examples | doc