CVS branch: Difference between revisions

From genomewiki
Jump to navigationJump to search
(Basic CVS branch example.)
 
No edit summary
 
Line 22: Line 22:
and specify the branch name.  Manually take care of any merge conflicts and commit the merged code.
and specify the branch name.  Manually take care of any merge conflicts and commit the merged code.
  cvs commit hgTracks/
  cvs commit hgTracks/
[[Category:Technical FAQ]]

Latest revision as of 23:34, 14 August 2006

There are several good reasons to make a CVS branch but the one mentioned here is for the situation where a project is big enough that it may require several commits to get the job done, and it shouldn't break the main code for everyone else while the development is ongoing. In addition, it allows several developers to interact on that project at once and both make commits to the same branch.

Branch Creation and Use

To create the branch, first check out a copy of the code.

cvs co kent/src

then go to wherever it is in the code that you are making significant changes

cd kent/src/hg/hgTracks

make some changes to a few files, say hgTrack.c, hgTracks.h, cds.c, and config.c. Save them. Now for the branching command. It's probably best to branch off just a piece of the source tree and not the whole thing.

cd ../
cvs tag -b Andys_button hgTracks/

So doing that will tag hgTracks/ and all files and subdirectories of that in the repository but oddly not in the currently working directory as well. To start work on the "Andys_button" branch, just

cvs update -r Andys_button -kk hgTracks/

will cause the hgTracks module to update from the repository and put the Andys_button tag in the hgTracks/CVS/Tags file, which means the working copy is now the branched version. One of the main things to remember about branches is that they're sticky. So all future updates and commits will be on that branch. To go back to the main "trunk" of code, use cvs update -A like

cvs update -A hgTracks/

The -kk flag in the update deletes the contents of the rcsid variables put into C files. These variables can be a problem when merging the branch back into the trunk.

Merging The Branch Into The Trunk

When you're done with the project, to put it into the main source tree, start by making sure the working directory is up to date on the branch and all the commits are in (and it compiles fine). Next, update to the main trunk.

cvs update -A hgTracks/

Finally, from the main trunk sandbox, merge using update -j

cvs update -j Andys_button hgTracks/

and specify the branch name. Manually take care of any merge conflicts and commit the merged code.

cvs commit hgTracks/