Branch-aware hg merge in a branchy repository

Christopher Nuzum cjn at tractionsoftware.com
Tue Jun 24 18:39:56 CDT 2008


Hi Folks.  My alternate title for this post was, "Splitting a branchy  
repository into multiple repositories/exporting a branch -- OR, why  
doesn't hg merge know what branch I'm on?"  I'm hoping someone out  
there might have some sage advice...

Some background:

We imported a 12-year old CVS repository with a great many branches  
(that was fun), and have been using Mercurial for about a month now.   
We have closed out all but 8 active development and maintenance  
branches--so we always have at least 8 heads in any given repository.

At any given point, each developer has multiple clones of the  
repository, each checked out on a different branch.

The issue:

When a developer pulls and updates and someone else has already  
checked in, a merge is required.  No surprise there.

hg heads [branchname] lists the other heads on the current branch, and  
often there is just one that needs to be merged.

However, hg merge with no parameters doesn't know what to do in this  
situation; from hg merge --help:

>     If no revision is specified, the working directory's parent is a
>     head revision, and the **repository** contains **exactly one  
> other head**,
>     the other head is merged with by default.  Otherwise, an explicit
>     revision to merge with must be provided.

However, in this case, the 8 other heads always require the developer  
to input the output of hg heads [branchname]... which people find  
frustrating.

So, I'm wondering what we can do to make people's lives easier.  The  
two things that have occurred to me are:

1. Export each branch into a separate repository, so that each  
repository will generally have only heads related to that branch of  
development. We would still be able to merge across repositories.  I  
haven't been able to put my finger on instructions for how to do this.

2. In the case where there is only one other head on the current  
branch, is there way to get hg merge to automatically know that that's  
the head it should merge with (rather than getting confused by the  
other branches in the repository)? It seems unambiguous enough. Should  
I log this as an enhancement request, or is there a reason this isn't  
already done, or is there a way to do this that I've overlooked?

The question seems to come up here every day.  I'm curious to hear how  
others deal with it.

Thanks!

Chris






More information about the Mercurial mailing list