diff mercurial/cmdutil.py @ 44460:d543ef183eb8

merge with stable
author Augie Fackler <augie@google.com>
date Thu, 05 Mar 2020 10:52:51 -0500
parents f5c006621f07 92b7caf4cb9e
children 9d2b2df2c2ba
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Wed Mar 04 14:21:23 2020 -0500
+++ b/mercurial/cmdutil.py	Thu Mar 05 10:52:51 2020 -0500
@@ -961,7 +961,7 @@
     raise error.UnknownCommand(cmd, allcmds)
 
 
-def changebranch(ui, repo, revs, label):
+def changebranch(ui, repo, revs, label, opts):
     """ Change the branch name of given revs to label """
 
     with repo.wlock(), repo.lock(), repo.transaction(b'branches'):
@@ -979,7 +979,11 @@
 
         root = repo[roots.first()]
         rpb = {parent.branch() for parent in root.parents()}
-        if label not in rpb and label in repo.branchmap():
+        if (
+            not opts.get(b'force')
+            and label not in rpb
+            and label in repo.branchmap()
+        ):
             raise error.Abort(_(b"a branch of the same name already exists"))
 
         if repo.revs(b'obsolete() and %ld', revs):