diff mercurial/cmdutil.py @ 40707:69268a13ffa5

branch: allow changing branch of merge commits with --rev Tests show that changing branch of merge commits works fine with evolution and without, so let's allow it. Other safeguards should prevent users from shooting themselves in the foot.
author Anton Shestakov <av6@dwimlabs.net>
date Fri, 09 Nov 2018 13:57:13 +0800
parents 824b687ff6af
children 79f8f032c706
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Thu Nov 15 22:28:38 2018 -0500
+++ b/mercurial/cmdutil.py	Fri Nov 09 13:57:13 2018 +0800
@@ -732,11 +732,10 @@
         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"))
 
-        if repo.revs('merge() and %ld', revs):
-            raise error.Abort(_("cannot change branch of a merge commit"))
         if repo.revs('obsolete() and %ld', revs):
             raise error.Abort(_("cannot change branch of a obsolete changeset"))