mercurial/cmdutil.py
changeset 35746 e5b6ba786d83
parent 35745 3bd8ab4c80a5
child 35853 eeb87b24aea7
child 35914 1bee7762fd46
--- a/mercurial/cmdutil.py	Sun Oct 15 23:08:45 2017 +0530
+++ b/mercurial/cmdutil.py	Fri Jan 19 18:45:20 2018 +0530
@@ -727,6 +727,11 @@
         if len(roots) > 1:
             raise error.Abort(_("cannot change branch of non-linear revisions"))
         rewriteutil.precheck(repo, revs, 'change branch of')
+
+        root = repo[roots.first()]
+        if not root.p1().branch() == label 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):