Using Revision Control Software

rcs and cvs are revision control software that is available on our system. rcs is most useful for managing your private projects and cvs is useful for managing group projects.

cvs allows you and your group members to create a repository for your project source, to each check out your own working copies of your project's source, to commit changes to the repository, to checkout previous committed versions of your code from the repository, to automatically merge in changes made by your project partner(s) into your working version, and to create labeled versions of your code, which is useful when using a stable, labeled, previous version as a starting point for other code (you can check out this labled "starting point" version of your repository code even after more changes have been committed to the repository).


RCS Basics

Create a subdirectory named RCS in your private working directory:
% mkdir RCS
Check in files you want to add to the repository (this moves them into the RCS repository):
% ci foo.c
% ci blah.c
Check out file you want to work on (-l locks the file so only you can check it out to modify it):
% co -l foo.c
% co -l blah.c
Subsequent check-ins create a new version of the file, and you can revert to older versions by using the -r flag with co (see the man pages for co and ci for more details).

CVS Basics

(see the on-line reference for a more complete explanation)

To use cvs you first need to (this is actually quite easy even though it looks like a lot of instructions):

  1. Create a repository for your shared code

    1. you will need to request from local-staff a unix group for you and your project partners so that you can set permissions for your repository
    2. One of you will have to store the repository in his/her home directory. From his/her homedirectory run the cvs init command to create your repository (here I'm calling it CVS):
        % cd 
        % cvs -d /home/yourusername/CVS
      
      Next, set permissions on your CVS repository so that only you and your partner(s) can access it:
       % chgrp yourgroupname CVS
       % chmod 770 CVS
      
    3. You can import files into your cvs directory using the import command, but first you need to set some environment variables:
      # for bash (you can put these in your .bashrc file):
      CVSROOT=/home/yourusername/CVS
      export CVSROOT
      CVS_RSH=/usr/local/bin/ssh
      export CVSROOT
      
      # for tcsh (you can put these in your .cshrc file):
      setenv CVSROOT /home/yourusername/CVS
      setenv CVS_RSH /usr/local/bin/ssh
      
      To import existing files into your repository:
      # from the subdirectory containing the files and directories you want to import:
      % cvs import -m "Imported sources" csproject tia_and_jeff start
      
      # -m is the message written to the log
      # tia_and_jeff is the vender name (you can choose your vender name)
      # start is the release number
      
      This will import all files and subdirectories from your current directory into the repository as a directory tree named csproject (csproject will be a directory you can checkout from your CVS repository). At this point you can remove the your local copies of the files you just imported into the repository, and then checkout new copies from the repository (this way they are under CVS control).

    4. Later, you can use cvs add (followed by cvs commit) to add new directories and files to your csproject directory tree, or you can use cvs import to add a new directory trees to your repository.

  2. Check out your own copy of the shared code to your private working directory, from which you can make changes without interfering with your partners' simultaneous changes.

    1. set your CVSROOT and CVS_RSH environment variables. In bash, for example (you can add this to your .bashrc file):
      CVSROOT=/home/partner_w_repository/CVS
      CVS_RSH=/usr/local/bin/ssh
      
    2. then from your private subdirectory into which you will put your checked-out version:
      % cd ~/private/csX/project
      % cvs co csproject
      

Once the repository is set up and you have checked-out your private copy, here are some common cvs operations:

# (1) from your working subdirector(ies) to see if any changes have been 
#     committed to the repository
% cvs -n update
M foo.c	      # your copy of this file differs from the repository version
U blah.c      # a change has been committed to this file, and your version is out of date 
C grr.c	      # you have change your copy of this file & a change was committed

# (2) to have cvs merge the committed changes into your working versions 
#     (its a good idea to make a copy of any files that you have changed
#      and have been committed so that if cvs's auto-merging fails you can
#      more easily fix the file by hand)
#     
% cvs update
C grr.c	        # this may indicate that cvs's auto-merge couldn't completely
                # merge the committed changes into this file and you may
                # need to fix this by hand

# (3) to commit your changes to the repository
#
% cvs commit filename.c   # commit just this file
% cvs commit              # commit all your changes to files in the current directory

On-line references

CVS wiki
CVS Manual
RCS Mini-HowTo