Previous Section  < Day Day Up >  Next Section

Recipe 18.18. Creating Stable and Development Branches for a Project

18.18.1 Problem

You want to divide a programming project into two branches: one that is stable, in maintenance mode, and one that is under active development. This way you'll have a reliable, stable branch that is ready for production use, and a wild and crazy development branch where improvements and new features will be developed and tested. When features from the development branch are ready for prime-time, you can merge them back into the stable branch.

18.18.2 Solution

To create the wild and crazy development branch from the nice, stable project module, first make all your commits and have your sandbox up-to-date. Then run this command:

$ cvs rtag -b projectbranch project

Name the new branch first, and the module for which it is created second. This command operates directly on the repository, not on the sandbox.

You can also create a branch from tagged files, which were discussed in Recipe 18.17:

$ cvs tag -r rel_1.0_3dgame -b rel_1.0_3dgame_branch

To check out the branch files you'll need to create a separate sandbox. Create a new directory for the new sandbox, then check out the branch files:

$ cvd -r projectbranch project

Committing files back to the branch requires no special options:

$ cvd commit

Someday, you will want to merge your branches. This is how (the -j means "join"):

$ cvs checkout project

$ cvs update -j projectbranch

How do you know if you're working in a branch, or on the main trunk? Read the sticky tag:

$ cvs status

=  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  

=  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =

File: somefile  Status: Up-to-date

   

   Working revision:    1.2     Wed Jul 28 06:08:54 2003

   Repository revision: 1.2     /home/foober/cvsroot/project/somefile,v

   Sticky Tag:          project (branch: 1.2.6)

   Sticky Date:         (none)

   Sticky Options:      -kkv

18.18.3 Discussion

Creating a CVS branch is no small thing. You must keep track and pay attention to what you are doing. It's rather pointless if the files get all mixed up and you lose track of the branches you've created.

After branches are merged, the individual branches will still remain in the CVS repository. Remember, CVS is designed to never forget anything.

CVS is pretty good at merging branches, and the majority of the merges succeed without incident. However, it's not magical; the various people working on the project will still need to have manners, communicate progress with each other, and have something in the way of project goals to aim for.

18.18.4 See Also

  • Chapter 4 of Essential CVS, which goes into detail on branching, merging, and keeping track of everything

  • Local documentation—"Branching and Merging" (/usr/share/doc/cvs/html-info/cvs_5.html)

    Previous Section  < Day Day Up >  Next Section