[PATCH] branch: allow changing branch of merge commits with --rev
Yuya Nishihara
yuya at tcha.org
Sun Nov 18 02:28:33 UTC 2018
On Sat, 17 Nov 2018 22:45:16 +0800, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov <av6 at dwimlabs.net>
> # Date 1541743033 -28800
> # Fri Nov 09 13:57:13 2018 +0800
> # Node ID 353bb16507d9824888ba0abb4d35a4ed75189303
> # Parent b93157f69f46a1359726be32bde4afb1e5af4384
> # EXP-Topic branch-rev
> branch: allow changing branch of merge commits with --rev
Queued, thanks.
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -732,11 +732,10 @@ def changebranch(ui, repo, revs, label):
> rewriteutil.precheck(repo, revs, 'change branch of')
>
> root = repo[roots.first()]
> - if not root.p1().branch() == label and label in repo.branchmap():
> + rpb = {parent.branch() for parent in root.parents()}
> + if label not in rpb and label in repo.branchmap():
> raise error.Abort(_("a branch of the same name already exists"))
Generally a merge commit inherits the p1 branch, but it's allowed to change
the wdir branch to p2 while merging. So it should be fine to allow using
p2 branch here.
$ hg merge
$ hg branch <p2-branch> # I didn't know this is allowed
More information about the Mercurial-devel
mailing list