CS 371 Lab #7: CVS

In this lab you will familiarize yourself with CVS.

  1. Scan the CVS manual at http://www.cvshome.org/docs/manual/
  2. Scan the CVS tutorial at http://www.loria.fr/~molli/cvs/cvs-tut/cvs_tutorial_toc.html. This tutorial has a helpful glossary at its beginning. You do not need to pursue example exercises in this tutorial, just read through it. There are about 12 web pages, most of which are short.
  3. Scan the on-line CVS book at http://cvsbook.red-bean.com/cvsbook.html. You will refer back to specific pages in this book in order to complete later portions of the lab.
  4. Create a CVS repository. This will serve for demonstration purposes during the first few items in this lab, then you can delete it. Several tutorials say to use a program named cvsinit, but we do not have that on our system. Instead, the CVS book chapter "Repository Administration" has a section titled "Starting a Repository", read that and do the following. If you already have a ~/371 directory you may create a different directory for this purpose.
         mkdir ~/371
         cd ~/371
         cvs -d `pwd` init
         ls
         ls CVSROOT
         du CVSROOT
    
    Note the backquotes that are used around pwd to obtain the current working directory; If you use quotes instead of backquotes this command will fail. If you are not using csh your syntax may be different. The first "ls" command should show that cvs created a CVSROOT directory. The "ls CVSROOT" should show you the files CVS creates to build an empty repository structure. Note the number reported by "du CVSROOT". Approximately how many kbytes does an empty CVS repository occupy?
  5. Set your CVSROOT environment variable to the directory you are in. Do a "pwd" command to see the full path name for ~/371, and set CVSROOT to that path. This generally is done in your ~/.cshrc file, e.g. for me it looks like:
         setenv CVSROOT /home/uni1/jeffery/371
    
    For you it will say something different in the middle (replace the uni1/jeffery with your file system and username).
  6. Create a (temporary) CVS project in your repository. To do this, make and cd into a temporary directory, and put a "hello, world" program in a file named (for example) hello.cpp, and a makefile that can compile that program. Such a program directory is inserted into the CVS repository by running:
         cvs import -m "here is a testproj" testproj youruserid start
    
    This will create a copy of your whole directory and any subdirectories, inside the repository. Note that you should make sure you don't have any junk files (.o, .class, .u, etc.) before doing an import.
  7. Test your repository by creating a new copy of your project elsewhere.
         mkdir ~/test371
         cd ~/test371
         cvs checkout testproj
    
    This will create a subdirectory under test371, named testproj, that contains your distribution copy. cd into testproj/ and "make" the program there. Edit the program (add a std:cout << "hello cvs" to its main() function), save your change, and type
          cvs diff main.cpp
          cvs update main.cpp
          cvs commit -m "added hello" main.cpp
    
  8. Delete the new test directories you created, and reset your CVSROOT.
    Set your CVSROOT (in .cshrc and your current shell) with:

    setenv CVSROOT /home/uni1/jeffery/371
    
    On an internet-connected personal machine, you would set it to
    setenv CVSROOT yourid@machine.cs.nmsu.edu:/home/uni1/jeffery/371
    
    or (on bash shells)
    export CVSROOT=yourid@machine.cs.nmsu.edu:/home/uni1/jeffery/371
    
    where yourid is your CS user id, and machine is a CS lab machine. You can't do step 9 from a personal machine so you would skip to step 10.
  9. Run the command
    groups
    
    to verify that you are a member of group cs371 (you should be already) along with your other groups (group ugrads, etc).
  10. Checkout a current copy of the your project. To do this change to your home directory (or a subdirectory of your choosing) and do the checkout, which will create a project subdirectory.

    cd
    cvs checkout FPS
    
  11. Add your name to the credits procedure. The following sequence enters your CVS project checkout directory, launches an editor (in which you add a write() statement with your name in it, and save it), builds the project with "make", runs the project to verify you haven't messed up, and when you are satisfied, you commit your code change via cvs update (which backs in others' changes into your copy), cvs diff (which shows you what you are about to check in), and cvs commit.

    cd FPS
    emacs credits.cpp
    make
    make run
    cvs update credits.cpp
    cvs diff credits.cpp
    cvs commit -m "added youruserid to credits" credits.cpp
    
    By the way, if someone else commits their addition in between your "cvs update" and your "cvs commit" you may need to rerun "cvs update".
  12. Add your instance prototype source file to the project. This was the file you did in lab 6. You will need to give it a .cpp extension if it does not have one already, and then add it to the team CVS repository so your teammates will get a copy. For example, if your file was named event_data.cpp, you would copy that file into your new FPS directory, and then
         cvs add event_data.cpp
         cvs commit event_data.cpp
    
    Note: if someone else worked on this file with you, make sure only one of you tries to add it; the other person should do a cvs update to get the added file, and then insert their instances using a text editor and cvs commit them.
Closing thoughts: there is nothing "else" to turn in for this lab, if you can get your name into my repository, I will be able to see it next time I "cvs update". If you all wanted to work on remote machines over the internet, we would need to go a bit further than this lab, and set up a "cvs server" somewhere. This is a negotiable item, i.e. I am not opposed to you setting up and using a cvs server, but it is nonessential and may be more than we want to mess with. It would allow you to explore the multi-platform aspects, do your work on an internet-connected Windows PC or Macintosh at home, etc.