[PATCH] named branches: --newbranch option to allow intial push of new branches

Henrik Stuart henrik.stuart at edlund.dk
Tue Jul 7 14:04:07 CDT 2009

Matt Mackall wrote:
> On Sat, 2009-06-20 at 10:22 +0000, Sune Foldager wrote:
>> # HG changeset patch
>> # User Sune Foldager <sune.foldager at edlund.dk>
>> # Date 1245491231 -7200
>> # Node ID 8fcc4eacbf961f09b6820d9d0c397905e99a926b
>> # Parent  b30775386d4064a22a52b35cd5449a2623cec27a
>> named branches: --newbranch option to allow intial push of new branches
>> Compare this to --force which allows anything to be pushed. With --newbranch,
>> only changesets to named branches not present on the remote are allowed.
> Still not convinced here. I see a few different ways to go:
> a) Consider new branches to be the same as new heads for the purposes of
> new heads -> require force. This shouldn't be a frequently required
> operation with the new branch push smarts.

Consider the case where the developer has made changes to both an
existing branch as well as created a new branch. Requiring --force means
that he might, inadvertedly, create multiple heads on the first branch,
not just the new branch, needlessly complicating things by requiring the
user to both specify -r and --force.

> b) Allow explicitly-specified heads/branches (ie -r) to be pushed
> without force. Compare hg revert and hg revert foo. People might be
> surprised if they misdirect their push though and be surprised to see
> they shot themselves in the foot so it's not perfect.

I'm not really in favour of this approach.

> c) Add a new option. This is a pretty obscure use case and people might
> also misdirect their push here too.

Creating named branches is a very common occurrance for us, and before
we introduced the --newbranch option in our internal version of
Mercurial, we saw frequent occurrences of multiple heads.

This is really about simplifying the use of named branches to be more

In case there is interest for including it in 1.4, we have an updated
version with some of the repeated code refactored away.

Kind regards,
  Henrik Stuart

More information about the Mercurial-devel mailing list