Closed branch push behavior?

Matt Mackall mpm at selenic.com
Tue Dec 6 11:41:36 CST 2011


On Tue, 2011-12-06 at 11:38 +0100, Angel Ezquerra wrote:
> On Dec 5, 2011 10:48 PM, "Matt Mackall" <mpm at selenic.com> wrote:
> >
> > On Mon, 2011-12-05 at 16:09 -0500, Chuck.Kirschman at bentley.com wrote:
> > > I tried to push some changes from one repo to another and it
> > > complained that it would create new branches, even though the branch
> > > in question is closed.  Is that the expected behavior?  "Hg branches"
> > > doesn't show it, so it is pretty confusing to figure it out, and it
> > > isn't creating an open branch.  I'm using 1.9.3.
> > >
> > > [D:\foo]hg --debug push
> > > pushing to http://foo.bar.com/foo
> > > searching for changes
> > > abort: push creates new remote branches: wip_unicode!
> > > (use 'hg push --new-branch' to create new remote branches)
> > >
> > > [D:\foo]hg branches
> > > default                     3187:fa2769398873
> > >
> > > [D:\foo]hg branches -c
> > > default                     3187:fa2769398873
> > > wip_unicode                 3108:2426340ca7ae (closed)
> >
> > I think this is the intended behavior. The message:
> >
> >  abort: push creates new remote branches: wip_unicode!
> >
> > ..is correct in that a branch that only exists locally will be pushed to
> > the remote server. Since Mercurial's branches become permanent
> > components of history, this serves to make sure you don't inadvertently
> > publish permanent history that you don't intend to. Whether or not it's
> > "closed", it's still published by push. So you should either simply use
> > --new-branch as hinted, or destroy the unwanted branch locally and not
> > do that again.
> 
> Matt,
> 
> I have a related question that hopefully you can also address.
> 
> I wonder whether it makes sense for mercurial to complain that you'll
> create a new head when you close a branch and push the resulting new head.
> 
> Technically mercurial is right in that you are indeed pushing a new head,
> but isn't it obvious that this new head is not meant to be developed
> further?

Sure, but that's not what push cares about here. Push cares about
whether or not the history should be transmitted. If, for instance,
you're Chuck's coworker, the answer here is a big fat "no": you
shouldn't have created the branch in the first place and now this
warning is your last chance to avoid publishing it.

> Actually, I believe that mercurial will happily let you commit on top of a
> "close branch commit", which would be weird (I can't test this from my
> phone). You should have to use the --force option for that...

You've already got to jump through a hoop to check out a closed head:
you have to find it.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial mailing list