Author

Christopher Marshall (christopherlmarshall@yahoo.com)

Raw Notes on CVS: complete branching example

#!/bin/bash
# cvs merge example
# 2004-10-05 Chris Marshall (christopherlmarshall@yahoo.com)
#
# initial project, p1, has 3 files, A B C.
#
# from there, the main trunk, and the branch, go through various changes: adding files, deleting files, 
# or changing files.  Removing C and adding E on the branch is written branch(-C,+E) (the changes from br1-root to br1-1)
# for the purposes of reading the comments in this example.  Changing D from its initial empty contents
# to containing a "1" is written (D2), which simply means file D gets it's second set of unique
# contents in this script.
#
# The initial project state, from which the trunk and the branch split off, is tagged as both mt1-root, and br1-root.
# Changes to the trunk are then tagged mt1, mt2, mt3, ...
# Changes to the branch are then written br1-1, br1-2, br1-3.
#
# This is probably not the best notation for practical use, but it does help make this example easy to follow.
#
# summary of branching cvs commands
# 1  cvs tag tagname proj-name
# 2  cvs tag -b branch-name proj-name
# 3  cvs checkout -r branch-name proj-name
# 4  cvs update -j tag1 -j tag2
#
# 1,2, and 3 are all done from the directory containing (one above) the sandbox
# 4 is done from within the sandbox.
# 2 creates the new branch
# 1 is used to name states of both the trunk and branches
# 4 merges all changes from tag1 to tag2 into the sandbox it is executed from.

CWD=$(pwd)

# create a repository
mkdir CVSROOT
export CVSROOT=${CWD}/CVSROOT
cvs init

# create a project
cd $CWD
mkdir p1
cd ${CWD}/p1
touch A B C
cvs import -m "" p1 vtag rtag
cd $CWD
rm -rf p1

# checkout main working copy, create branch
# br1 is the branch name
# and br1-1 is the name of the tag at the branch point (the branchbasetag)
cd ${CWD}
mkdir main; cd main; cvs checkout p1;
cvs tag -b br1 p1
cvs tag br1-root p1
cvs tag mt1-root p1

# checkout branch working copy
cd ${CWD}
mkdir branch; cd branch; cvs checkout -r br1 p1

   # branch(-C,+E), tag br1-1
   echo ">>> creating br1-1"
   cd ${CWD}/branch/p1
   rm C; cvs remove C;
   touch E; cvs add E;
   echo "CVS COMMIT"
   cvs commit -m "1"
   cd ${CWD}/branch/
   cvs tag br1-1 p1

   # main(+B,+D), tag mt1
   echo ">>> creating mt1"
   cd ${CWD}/main/p1
   rm B; cvs remove B;
   touch D; cvs add D;
   echo "CVS COMMIT"
   cvs commit -m "1"
   cd ${CWD}/main/
   cvs tag mt1 p1

   # merge main->branch, branch(D2), tag br1-2
   echo ">>> creating br1-2"
   cd ${CWD}/branch/p1
   echo "CVS UPDATE"
   cvs update -j br1-root -j mt1
   echo "CVS COMMIT"
   echo "1" > D
   cvs commit -m "1"
   cd ${CWD}/branch/
   cvs tag br1-2 p1

   # main(+F,D2), tag mt1
   # make more changes to main
   echo ">>> creating mt2"
   cd ${CWD}/main/p1
   touch F; cvs add F; echo "1" > D
   echo "CVS COMMIT"
   cvs commit -m "1"
   cd ${CWD}/main/
   cvs tag mt2 p1

   # merge main->branch, tag br1-3
   echo ">>> creating br1-3"
   cd ${CWD}/branch/p1
   echo "CVS UPDATE"
   cvs update -j mt1 -j mt2
   echo "CVS COMMIT"
   cvs commit -m "1"
   cd ${CWD}/branch/
   cvs tag br1-3 p1

   # merge branch->main, tag mt3
   echo ">>> creating mt3"
   cd ${CWD}/main/p1
   echo "CVS UPDATE"
   cvs update -j br1-root -j br1-3
   echo "CVS COMMIT"
   cvs commit -m "1"
   cd ${CWD}/main/
   cvs tag mt3 p1



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