CVS Lesson (CBMG688P, Best Practices laboratory, Stoltzfus)
In this lesson, you will learn to use a tool called "CVS" (Concurrent Versioning System) to maintain a repository with versions of code (or other) files.
background
Specifically, you will be the creator and owner of a CVS repository in your
home directory. This approach is easy and it gives you complete control.
However, for future reference, doing things this way is a poor choice if you want to collaborate. In that case, use github or a project hosting site such as sourceforge, or ask your sysadmin to set up a CVS repository that others can access via the internet: you can access that using the same CVS commands we are learning in this exercise (but your sysadmin will give you a CVSROOT that refers to some other computer on the internet).
exercise
hint:use cut & paste, or TAB completion, to save yourselves time!
- first create your own local directory, with some short-cuts (links)
unix_prompt$ mkdir My_BestPractices_CBMG688P
unix_prompt$ cd My_BestPractices_CBMG688P
unix_prompt$ ln -s /afs/glue.umd.edu/class/fall2012/cbmg/688p/0101/public/Lab14 Lab14Link
unix_prompt$ ln -s Lab14Link/Perl class_Perl
- Set up CVS
- init CVS
unix_prompt$ cvs -d ~/cvsroot init
- set your account so that it always knows where to find CVS
unix_prompt$ echo $SHELL
- if you are using tcsh,
- add these lines to ~/.cshrc.mine
# CVS stuff -- change emacs to pico or vi if you like
setenv CVSROOT $HOME/cvsroot
setenv CVSEDITOR emacs
- then do the following
unix_prompt$ source ~/.cshrc.mine
unix_prompt$ echo $CVSROOT
- if you are using bash,
- add these lines to ~/.bashrc.mine
# CVS stuff -- change emacs to pico or vi if you like
export CVSROOT=$HOME/cvsroot
export CVSEDITOR=emacs
- then do the following
unix_prompt$ source ~/.bashrc.mine
unix_prompt$ echo $CVSROOT
- now we are ready to create a project using the class files
- make directory, copy Perl files into it, create cvs module (last command should spit out a list of files in module "my_cvs")
unix_prompt$ cd My_BestPractices_CBMG688P; mkdir my_cvs
unix_prompt$ cd my_cvs; mkdir Perl
unix_prompt$ cp ../class_Perl/*.pl Perl
unix_prompt$ cvs import -m "CBMG688P code" my_cvs `whoami` initial
- In order to test whether it worked, we'll delete the local files and check out the "my_cvs" module
unix_prompt$ cd ..; rm -rf my_cvs
unix_prompt$ cvs checkout my_cvs
- now, lets do some stuff. first we will add a new file to the module
unix_prompt$ cd my_cvs/Perl
unix_prompt$ cp ../../Lab14Link/Materials/stamp_output.pl .
unix_prompt$ cvs add stamp_output.pl
unix_prompt$ cvs commit -m "shows how to stamp output" stamp_output.pl
- now we will edit the file and commit a new version.
- edit the file (emacs, pico, vi) so that
$version = '$Id$'; (single-quotes required)
unix_prompt$ emacs stamp_output.pl
- now we'll "diff", and "commit" the change. Note: we didn't use -m "<revision comments>" so CVS opens text editor
unix_prompt$ cvs diff stamp_output.pl
unix_prompt$ cvs commit stamp_output.pl