12.1.2 CVS session examples
The following will set up shell environments for CVS repository access.
12.1.2.1 Anonymous CVS (download only)
Read-only remote access:
$ export CVSROOT=:pserver:[email protected]:/cvsroot/qref
$ cvs login
$ cvs -z3 co qref
12.1.2.2 Use local CVS server
Local access from a shell on the same machine:
$ export CVSROOT=/var/lib/cvs
12.1.2.3 Use remote CVS pserver
Remote access without SSH (use RSH protocol capability in cvs
):
$ export CVSROOT=:pserver:[email protected]:/var/lib/cvs
$ cvs login
This is prone to eavesdropping attack.
12.1.2.4 Use remote CVS through ssh
Remote access with SSH:
$ export CVSROOT=:ext:[email protected]:/var/lib/cvs
or for SourceForge:
$ export CVSROOT=:ext:[email protected]:/cvsroot/qref
You can also use RSA authentication (Connecting with fewer passwords – RSA,
Section 9.5.3), which eliminates the password prompt.
12.1.2.5 Create a new CVS archive
For,
ITEM VALUE MEANING
source tree: ~/project-x All source codes
Project name: project-x Name for this project
Vendor Tag: Main-branch Tag for the entire branch
Release Tag: Release-initial Tag for a specific release
Then,
$ cd ~/project-x # dive into source directory
... create a source tree ...
$ cvs import -m "Start project-x" project-x Main-branch Release-initial
$ cd ..; rm -R ~/project-x
12.1.2.6 Work with CVS
To work with project-x using the local CVS repository:
$ cd # move to the work area
$ cvs co project-x # get sources from CVS to local
$ cd project-x
... make changes to the content ...
$ cvs diff -u # similar to diff -u repository/ local/
$ cvs up -C modified_file # undo changes to a file
$ cvs ci -m "Describe change" # save local sources to CVS
$ vi newfile_added
$ cvs add newfile_added
$ cvs ci -m "Added newfile_added"
$ cvs up # merge latest version from CVS
... to create all newly created subdirectories from CVS, use
... "cvs up -d -P" instead
... watch out for lines starting with "C filename"
... unmodified code is moved to `.#filename.version'
... search for "<<<<<<<" and ">>>>>>>" in filename
$ cvs tag Release-1 # add release tag
... edit further ...
$ cvs tag -d Release-1 # remove release tag
$ cvs ci -m "more comments"
$ cvs tag Release-1 # re-add release tag
$ cd # move back to the work area
$ cvs co -r Release-initial -d old project-x
... get original version to old directory
$ cd old
$ cvs tag -b Release-initial-bugfixes # create branch (-b) tag
... now you can work on the old version (Tag=sticky)
$ cvs update -d -P # don't create empty directories
... source tree now has sticky tag "Release-initial-bugfixes"
... work on this branch
$ cvs up -d -P # sync with files modified by others on this branch
$ cvs ci -m "check into this branch"
$ cvs update -kk -A -d -P
... remove sticky tag and forget contents
... update from main trunk without keyword expansion
$ cvs update -kk -d -P -j Release-initial-bugfixes
... Merge from Release-initial-bugfixes branch into the main
... trunk without keyword expansion. Fix conflicts with editor.
$ cvs ci -m "merge Release-initial-bugfixes"
$ cd
$ tar -cvzf old-project-x.tar.gz old # make archive, -j for bz2
$ cvs release -d old # remove local source (optional)
Nice options to remember (use as first argument(s) to cvs
):
-n dry run, no effect
-t display messages showing steps of cvs activity
12.1.2.7 Export files from CVS
To get the latest version from CVS, use "tomorrow":
$ cvs ex -D tomorrow module_name
12.1.2.8 Administer CVS
Add alias to a project (local server):
$ su - admin # a member of staff
$ export CVSROOT=/var/lib/cvs
$ cvs co CVSROOT/modules
$ cd CVSROOT
$ echo "px -a project-x" >>modules
$ cvs ci -m "Now px is an alias for project-x"
$ cvs release -d .
$ exit # or Ctrl-D to get back from su
$ cvs co -d project px
... check out project-x (alias:px) from CVS to directory project
$ cd project
... make changes to the content ...