Questions about branching in Mercurial

Tim Allen tim at commsecure.com.au
Sat May 5 09:40:15 CDT 2007


My employer currently uses CVS internally for all its version-control
needs, and we're now sufficiently annoyed that we're looking for
a replacement. For the record, our CVS repository is similar to the
Linux Kernel in terms of number of files and number of change sets,
however it currently has about 150 branches and nearly 6000 tags.

The branching model we'd like to use runs something like this:

 - The trunk contains the latest stable version, usually whatever is in
   production plus any low-risk bugfixes or well-tested and complete
   features (that is, it should be safe to package this branch up and
   roll it out to production at any time).
 - Every time we need to patch production and the trunk is not fit to be
   rolled out (say, if there's complete and stable features we don't
   want to release yet), we branch from the last stable version, apply
   the patch to the branch, and roll it out. These maintenance branches
   should be stored centrally so that when a new patch needs to be
   rolled out, you don't have to figure out who made the last patch six
   months ago so you can pull from their repository.
 - Development is to be done in separate branches until stable, when
   they can be merged into the trunk.

Because of various bad experiences with CVS and developers messing
around with repositories on the server, I've been avoiding version
control systems whose solution to centrally-stored branches is
'developers should ssh to the server and clone off a new branch there'.
Hence, I've been concentrating on Mercurial's "named branches" which it
seems can be administered nicely with "hg push" and "hg pull".
Unfortunately, named branches aren't documented very well in "hg help",
and the wiki page isn't much better.

My questions are as follows:

 - Is it possible to implement the above branching model with
   Mercurial's named branches?
 - Does Mercurial have a special name for the branch you're on when you
   don't explicitly make a branch (see git's 'master' and CVS's 'HEAD')?
 - I have read scary things about interactions between Mercurial's
   notion of 'tipmost' and branches, such as this thread:

	http://marc.info/?t=117156850700004&r=1&w=2

   Are these issues likely to crop up terribly often?
 - How does one merge named branches (the following uses v0.9.3)? 

    # Create a repo
    $ mk hg-testing
    $ cd hg-testing
    $ hg init
    $ hg branch default
    $ hg commit -m "creating a default branch"

    # Add stuff to the trunk
    $ echo 'foo' > a
    $ hg add a
    $ hg commit -m "Added 'a'"

    # Make a new branch and add stuff
    $ hg branch dev
    $ hg commit -m "Added a development branch"
    $ echo 'bar' > a
    $ hg commit -m "A new, improved 'a'"

    # Switch back to the trunk
    $ hg update default
    1 files updated, 0 files merged, 0 files removed, 0 files unresolved

    # Merge the development branch onto the main branch
    $ hg merge dev
    abort: there is nothing to merge, just use 'hg update' or look at 'hg heads'

    # What now???

(Note: I'm not subscribed to the list, please Cc me on replies)


More information about the Mercurial mailing list