Picture of Me at Yarmouth Lighthouse

Aaryn Tonita, B.Sc.

Department of physics and Astronomy

6224 Agricultural Rd.

Vancouver BC

V6T 1Z1

 

 

Office phone: 1-604-822-2095

atonita@physics.ubc.ca

Home Links References

 

Creating a CVS tree

  • First decide upon a location to store the CVS tree. For instance:
    • ~/code/cvs
  • Next set the environment variable CVSROOT to point to this directory (for tcsh users):
    • $ setenv CVSROOT ~/code/cvs
    • You should add this command into your .cshrc or .bashrc file also.
  • Next, we initialize the CVS tree:
    • $ cvs init
    • The CVS tree is now ready to be used

Creating a Project

  • Enter the directory in which your code resides. For instance, I have a directory of subroutines located at "/home/atonita/code/mysubroutines" that I will enter into the CVS tree, so:
    • $ cd /home/atonita/code/mysubroutines
  • Next we will enter all of the contents of the current directory into a project residing in the CVS tree. All files will have version number 1.0. You will probably want to delete all temporary files and recompilable binaries.
    • ~/code/mysubroutines]$ cvs import -m "title" mysubroutines "project" start
    • The code is entered with this import statement. The -m "title" flag sets a log message of "title" into the first version of the project. The next flag, mysubroutines, gives the directory in the CVS tree that the code will reside in. It does not have to reflect the current directory, and it can be nested. The "project" title groups this code with other projects of the same project title. The start signifies that it is the first version.
  • Since the code now resides in the CVS tree, we could delete the directory and go home for the day. First I re commend checking that there were no errors.

Exporting a Project

  • At this point we want to check that the code exists in the CVS tree or we want to work on the code. We go to a working directory and then export the code:
    • ~]$ cd tmp
    • tmp]$ cvs checkout mysubroutines
  • There should now be a directory named mysubroutines in the current directory:
    • tmp]$ ls

mysubroutines

  • If the code that was inside of the original directory resides in that directory, everything worked properly.

Adding a File to an Existing Project

  • We first must checkout the code(see above) and then enter the created directory:
    • ~]$ cd mysubroutines
  • Next we create the file in one way or another. I find it useful to create the file and then immediately add it to the CVS tree before editing, so that I do not forget to add it later. So we create the file with the touch command:
    • mysubroutines]$ touch newfile
  • Then we add the file to the CVS tree:
    • mysubroutines]$ cvs add newfile
  • If everything is in order, cvs returns the following information:
    • cvs add: scheduling file `newfile' for addition
  • The file has been added to the CVS project. After committing the changes (see below) it will become a "permanent" part of the project.

Removing a File

  • This is somewhat unusual, but can occur. First, delete the file from the working directory:
    • mysubroutines]$ rm newfile
  • Then remove it from the CVS tree:
    • mysubroutines]$ cvs remove newfile
  • After committing the changes (see below) it will be removed from the project.

Committing Changes

  • Changes are committed quite easily:
    • mysubroutines]$ cvs commit
  • A log will open up in your preferred editor (set by editor environment variable) outlining the files added, removed or altered. They will initially be commented out. You should uncomment these lines so that if you check the CVS log you will know when files were altered. You can also add comments about which files are unfinished or how long you worked on it, or whatever you wish to add to your log. When you are done you should save and exit the editor.
    • In vi push ":wq".

Other Comments

  • Although these commands are necessary to obtain a working CVS tree, they might not be sufficient for all purposes. For further information, check the man pages or the CVS home page.
  • When you are done working on the project for the day and you have committed all your changes, there is a very simple way to clean up the working directory:
    • tmp]$ rm -rf mysubroutines
My work is funded by NSERC/CRSNG.
NSERC/CRSNG logo