Questions about branching in Mercurial

Aurelien Jacobs aurel at gnuage.org
Sun May 6 10:56:16 CDT 2007


On Sun, 6 May 2007 10:24:27 +0200
"Sebastien Lucas" <sebastien.lucas at gmail.com> wrote:

> On 5/6/07, Matt Mackall <mpm at selenic.com> wrote:
> > On Sun, May 06, 2007 at 11:30:04AM +1000, Tim Allen wrote:
> > > > There are currently some discussions about strange effects when merging
> > > > two named branches on the mailinglist, so in your case I would consider to
> > > > subscribe to the list.
> > >
> > > I've been checking the mail archive at http://marc.info/ since it was
> > > recommended on the Mercurial wiki, and sadly it doesn't have that thread
> > > yet. The Mailman archives at selenic.com do record it, and gmane does as
> > > well, so I guess I'll be using gmane in future.
> > >
> > > That thread pretty much answers my questions (the consensus seems to be
> > > that named branches aren't useful yet) so I guess I'm done.
> >
> > They've still got a couple rough edges that should be polished up in
> > the next couple months, but I think they're perfectly useful today
> > provided you understand how they work.
> 
> I don't know if the goal is that named branches and "cloned" branches
> have the same functionnalities. By now it's not the case.

It is the case.

> If I have a repo with one head (master) and I clone it to make a new
> branch (dev-branch) then I'll a have two repo with one head in each
> repo. assuming I do not touch master and I add some changeset in
> dev-branch I can push my change from dev-branch to master

Up to there, you're right.

> and merge them.

Here you're wrong ! There is nothing to merge at that point.

> Now if I do the same with named branches I'll have to commit a dummy
> changeset on master so that my repository has two heads and I can
> merge (See this thread for more detail :
> http://article.gmane.org/gmane.comp.version-control.mercurial.general/1352)

I think you misunderstood something. Here are the 2 key points:
 - hg branch *don't* create a branch ! It only give a name to the current
   branch.
 - the only way to create a real branch (named or not) is to commit
   over an older (non-tip) revision. As long as you commit (or push)
   over tip, you can't create a branch.

In your original example, you just had a single branch with 2 names
(default and dev).

Aurel


More information about the Mercurial mailing list