The CVS Branching Process In Detail
Here are the exact operations to do when working on a branch. For this example, assume that the module you are working in is called "myproj" and you are making a branch called "BRANCH_B1."
Step 1. Create your branch and tag the HEAD where it was made. Then check out a copy of your module that is on the branch.
CVS Command Line:
cvs rtag TAG_CREATE_B1 myproj
WinCVS Operation:
Create | Create a tag by module
New Tag Name: TAG_CREATE_B1
Module to Tag: myproj
CVS Command Line:
cvs rtag -b -r TAG_CREATE_B1 BRANCH_B1 myproj
WinCVS Operation:
Create | Create a branch by module:
New Branch Name: BRANCH_B1
Module to Fork: myproj
Fork from this rev./tag: TAG_CREATE_B1
CVS Command Line:
cvs co -r BRANCH_B1 myproj
WinCVS Operation:
Create | Checkout module...
Checkout settings: Enter the module name and path on the server: myproj
Checkout options: By revision/tag/branch: BRANCH_B1
Step 2. Merge changes in the HEAD the first time. First tag the HEAD to establish a merge point. Then do the merge.
CVS Command Line:
cvs rtag TAG_HEAD_MERGE_TO_B1 myproj
WinCVS Operation:
Create | Create a tag by module
New Tag Name: TAG_HEAD_MERGE_TO_B1
Module to Tag: myproj
CVS Command Line:
cd to myproj that is checked-out on BRANCH_B1
cvs update -jHEAD
WinCVS Operation:
Select myproj that is checked-out on BRANCH_B1
Modify | Update selection
Merge Options: Only this rev./tag: HEAD
Step 3. Correct conflicts and commit. After the commit, tag the branch. Concurrency Issue: This step assumes that no one is making changes on the branch from the time of that update in the past step to the "cvs rtag" operation in this one. If that cannot be assured, tag the working area instead of the repository (that is, use cvs tag instead of cvs rtag).
CVS Command Line:
cvs rtag -r BRANCH_B1 TAG_B1_MERGE_FROM_HEAD myproj
WinCVS Operation:
Create | Create a tag by module
New Tag Name: TAG_B1_MERGE_FROM_HEAD
Module to Tag: myproj
Tag revision/tag/branch: BRANCH_B1
Step 4. Continue working on the branch until you want to merge in changes from the HEAD again.
Step 5. Merge changes in the HEAD that occurred between your last merge and now. This is the important step to understand. Merge from the old tag on the HEAD to the present.
CVS Command Line:
cvs update -jTAG_HEAD_MERGE_TO_B1 -jHEAD
WinCVS Operation:
Modify | Update selection
Merge Options:
Only this rev./tag: TAG_HEAD_MERGE_TO_B1
Plus with this rev./tag: HEAD
Move the tag. The same concurrency issue from Step 3 applies here as well.
CVS Command Line:
cvs rtag -F TAG_HEAD_MERGE_TO_B1 myproj
WinCVS Operation:
Create | Create a tag by module
New Tag Name: TAG_HEAD_MERGE_TO_B1
Module to Tag: myproj
Check: Overwrite existing tags with the same name
Fix conflicts and commit.
Update the tag on the branch:
CVS Command Line:
cvs rtag -F -r BRANCH_B1 TAG_B1_MERGE_FROM_HEAD myproj
WinCVS Operation:
Create | Create a tag by module
New Tag Name: TAG_B1_MERGE_FROM_HEAD
Module to Tag: myproj
Tag revision/tag/branch: BRANCH_B1
Check: Overwrite existing tags with the same name
Step 6. If more work is to be done on the branch, go to Step 4. Otherwise go to the next step.
Step 7. When done with the branch, merge changes from the branch to the HEAD.
CVS Command Line:
cd to myproj that is checked-out on HEAD (not BRANCH_B1)
cvs update -jBRANCH_B1
WinCVS Operation:
Select myproj that is checked-out on HEAD (not BRANCH_B1)
Modify | Update selection
Merge Options: Only this rev./tag: BRANCH_B1
Step 8. Fix conflicts. You will likely see a lot of conflicts here that you dealt with already on the side branch. The second choice conflict is the one that came from the branch and usually is the one you want to choose. This should be straightforward. Fix all conflicts and commit. Advise others that the side branch is no longer to be used.
-- M.D.S.