What is a branch?

Yao Zhang yaoz39 at gmail.com
Mon Feb 11 12:34:26 CST 2008


On Mon, Feb 11, 2008 at 09:38:15AM -0500, Chris Morgan wrote:
 
> Presumably it would look like :
> 
> P -> C1 -> C2
> 
> with branch properties of default, branch-1 and branch-2 for each
> element respectively?

Yes.

> As a CVS user currently., this makes sense to me. From the CVS user's
> point of view, C1 and C2 are branch points, but there are only single
> checkins "on the branch" for C1 and for C2 (although C2 is a change
> "on the branch" C1). A user can now checkin to multiple branches,
> right? e.g.
> 
> P -> C1 -> C2
> |
>  -> C3

Yes.  Suppose P, C1, C2, and C3 above are changeset IDs.  Now the
current working directory corresponding to C2, for example.  In
order to create C3 as shown, we can do

hg update -C P                      # checkout changeset P
# Or equivalently,
# hg update -C default              # checkout tip of default branch which is P
                                    # modify working directory
hg commit -m "Another child of P."  # create another child of P

Now changeset C3 will inherit branch name from P, which is
"default".  If we want to assign branch name "branch-3" to
C3, then the steps could be

hg update -C P                      # checkout changeset P
                                    # modify working directory
hg branch branch-3                  # start another branch name
hg commit -m "Another child of P."  # create another child of P

Since Mercurial branch name is an attribute associated with a
changeset, it leads to the following observations (correct me
if I am wrong):
1. There is only one branch name per changeset;
2. Once assigned, the branch name of a changeset can not be modified;
3. New branch name can be started anywhere in history.

(Mercurial branch name behaves very differently from tag name.)

Regards.

-- 
張堯

Lake Erie died for your sins.


More information about the Mercurial mailing list