Java Reference
In-Depth Information
before, you have the option of switching to the branch once it's created, allowing
you to begin working on that branch. It's good practice to include the word
branch
in your branch tag's name to distinguish it from regular tags.
You should always create a tag to identify the root of the branch you're
creating. Doing so gives you an easy point of reference for viewing and
merging back into the trunk the changes made along the branch.
TIP
Working on a branch
If you need to work on a branch—to fix bugs on an earlier release of your prod-
uct, for example—you must update your working directory to work under that
branch's context. Using the
CVS
| Update Project
command, select the branch
tag you want to work on from the
Use Version
option group (the second option,
By tag
). Note that
CVS
doesn't distinguish between branches and tags when per-
forming an update, so both appear in the list. You can also create a separate
project for the branch version, if you find you're switching between the trunk and
the branch often. In this case, you can specify the branch at checkout time.
Once you check out or update your working directory against a branch, all
future commits will be applied to that branch rather than the trunk. This is
because of something
CVS
calls the
sticky
tag. Updating to a branch is a sticky
operation: The branch name is automatically included as an option when com-
mitting your files to make sure all changes are applied to the branch. To go back
to working on the trunk, you need to perform an update and select the
Reset
sticky data
option from the
Update
dialog. Doing so removes the sticky tag from
your working directory and performs all operations against the default version,
which is the trunk.
Merging files between branches
In many cases, you should merge changes made on a branch back into the trunk.
After all, a bug fix against an earlier version could very well apply to its descen-
dants. You can make the change manually in both the branch and the trunk, but
it's often easier and less error prone to use the
CVS
merge function.
You perform a merge through the
Update
dialog, either for an individual file
or for the entire project. To perform a merge, select one or two early tags or
branches in the
Branch Merging
options at the top of the
Commit Directory
dia-
log. If you select a single branch to merge against,
CVS
applies the differences
between the latest files on the branch (the tip of the branch) and your local files.
If you select two versions or branches,
CVS
applies the differences between those