Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Programmer's Toolchest


Oct00: The CVS Branching Process In Detail

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.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.