Branching models (was Re: Suffering from CVS mindset)

Greg Ward greg-hg at gerg.ca
Sun Apr 11 19:28:42 CDT 2010


[we've drifted away from the original topic, so I've edit the subject
and cc list]

On Sun, Apr 11, 2010 at 5:02 PM, Yawar Amin <yawar.amin at gmail.com> wrote:
> IMHO Mercurial's named branches are adequate, as in they simulate the
> ideal (to me) branching mechanism: a branch is simply a named pointer to
> a head. I find that if I use the named pointer mental model while I'm
> dealing with Hg branches, I don't have any trouble. The graphlog
> extension helps a lot too.

Careful: that is an excellent description of git's branch model, but
it's not quite Mercurial's.  In Mercurial, a named branch is a
labelled subset of the graph of changesets, and the branch name is
shorthand for the latest (tipmost) branch head with that label.
Typically, that is a topologically meaningful subset of the graph --
i.e. all changesets on the branch descend from a common ancestor, and
there is a small number of branch heads that are descendants of that
common ancestor.  But technically, that's just convention: you could
construct a bizarre repo where a "named branch" is an arbitrary subset
of changesets scattered throughout the graph with no topological
consistency.

This can surprise people who expect git's model of branching, because
named branches in Mercurial last forever.  You cannot destroy them and
you cannot rename them [1] [2].

So using Mercurial named branches in the way that git users often use
branches -- for as a handy name for a short-lived topic branch -- is
probably a bad idea.

Greg

[1] well, you could play games with repo conversion to destroy/rename
named branches, but that would break changeset IDs -- not generally
desirable

[2] ISTR that someone posted an experimental (?) extension for branch
aliasing, which would have the effect of branch renaming, without
actually renaming branches


More information about the Mercurial mailing list