Author

Christopher Marshall (christopherlmarshall@yahoo.com)

Raw Notes on CVS

# an extended example that shows how to accomplish common tasks in 
# cvs

# point to local repository
export CVSROOT=/home/chris/CVSROOT

# remote repository via ssh
#export CVSROOT=:ext:chris@10.0.0.3/home/chris/CVSROOT
#export CVS_RSH=ssh

# create the repository
cvs init

# create a project directory and import it to the repository
mkdir test_dir
cd test_dir
cvs import -m "log comment" test_dir vtag rtag

# remove original project directory
cd ..
rm -rf test_dir

# and check it out using CVS.
# the -P stands for "prune empty directories"
cvs checkout -P test_dir
# checkout files as they were on 2002-09-01
cvs checkout -D 2002-09-01 test_dir
# checkout a certain symbolic revision
cvs checkout -r rel-1-1 test_dir
# checkout without the CVS sub dirs
cvs export -P test_dir

# checkouts with explicitly names repositories
cvs -d :ext:user@remotehost:/home/user/cvsroot checkout test_dir

# edit,track,commit,track cycle
cd test_dir
vi file1.txt
cvs diff file.txt
cvs commit file1.txt
cvs log file1.txt

# look at repository wide activity
# -e means show all records
# -a means all users (default is self only)
cvs history -ae
# report all modifications since 2006-05-01 for all users
cvs history -a -x M -D 2006-05-01
# inspect version history on a single file 
cvs log file1
# check the status of a working file
cvs status file1

# make sure all changes have been committed
cd ..
cvs release test_dir

# get any new files or directories committed by someone else
cvs update -P -d

# add a new file
echo "1" > file2.txt
cvs add file2.txt
cvs commit

# delete a file
rm file1.txt
cvs remove file1.txt
cvs commit

# retrieving old versions of a single file 
cvs update -p -r 1.3 file1.c > ~/tmp/file1-1.3.c

# updating a file in place to an older version
# this sets a sticky tag on the file
cvs update -r 1.3 file1.c
# reverting the file back to the HEAD of the branch, removing
# the stick tag
cvs update -A file1.c

# tagging
# tag an individual file
cvs tag rel-1-0 file.txt
# tag an entire module (all files in the directory, and
# all subdirs recursively)
cvs tag rel-1-0 test_dir
# this version of the command will check to see if any 
# of the working files differ from the respositry files
# of the same revision, and abort with a warning if they do
cvs tag -c rel-1-0 test_dir
# checkout that release
cvs checkout -r rel-1-0 test_dir
# the rtag command works directly on the respository contents and not
# on anything checked out.  It lets you create tags historically
# by specifying a release date and/or time, or tag
cvs rtag -D "2002-09-10" rel-1-0 test_dir
cvs rtag rel-1-0 test_dir
# I am not sure what this one would do
cvs rtag -r rel-1-0 rel-1-1 test_dir
# this command would delete the tag rel-1-0
# you would not normally do this.  It can be dangerous.
cvs rtag -d rel-1-0 test_dir

# branches
CWD=$(pwd)
mkdir main; mkdir branch
# use a fresh checkout to create the branch
cd main; cvs checkout proj1; cvs tag -b br1 proj1
# checkout the branch
cd ${CWD}/branch; cvs checkout -r br1 proj1; cd proj1; vi, cvs commit, vi cvs commit ...
# merge the changes from the branch into main trunk and commit them to the main trunk
cd ${CWD}/main/proj1; cvs update -j br1; cvs commit

# Group read/write access.  This was one tough nut to crack.
# Here we show how to setup a cvs repository so that only users in the group
# 'develop' have read or write access to it, but normal users do not.
# We start from the chris account already on the system.
su
group add develop 
useradd -m -s /bin/bash -g users -c "chris2 account" -p "password string" chris2
usermod -G develop chris 
usermod -G develop chris2
mkdir /usr/local/cvsroot
chown chris /usr/local/cvsroot
exit
chgrp develop /usr/local/cvsroot
# this is by far the trickiest part of the whole procedure.
# we are setting the group stick bit on the directory
# which means any directories created under it will have 
# the same permissions as the parent (including the stick bit)
# and will be owned by the same group as the parent. Only users in 
# the group develop will be able to do this.
chmod g+srw /usr/local/cvsroot
export CVSROOT=/usr/local/cvsroot
cvs init
cd ~/test_dir
cvs import -m "test project" test_dir vtag rtag
# at this point we have initialized the cvs repository so that users 
# chris and chris2 have read and write premission, but other users
# on the system do not.

# pserver access
# add this line to /etc/inetd.conf and restart inetd (assuming cvs is in /usr/bin,
# and that we want to allow access to /usr/local/cvsroot).
# we do this on machine A:
2401 stream tcp nowait root /usr/bin/cvs cvs -f --allow-root=/usr/local/cvsroot pserver
#
edit CVSROOT/config and add "SystemAuth=yes".  It also seems to work if this option is missing
it doesn't work, however, if "SystemAuth=no".
# "SystemAuth=no" would force cvs on A to get the password from CVSROOT/passwd, instead of /etc/passwd
# from remote machine B
export CVSROOT=:pserver:chris@B:/usr/local/cvsroot
touch ~/.cvspass
cvs login
cvs history -e
# the touch ~/.cvspass step above gets around a bug in cvs where is tries to read .cvspass 
# before creating it.


#binary files should be added with -kb option like this
cvs add -kb file.jpg
cvs commit
# that way, they will not have keywords expanded and no merging will be attempted

hopeless_linux: RawNotes/cvs (last modified 2007-07-01 16:01:00)