##// END OF EJS Templates
branch: make --force work even when specifying revs...
Manuel Jacob -
r44891:92b7caf4 stable
parent child Browse files
Show More
@@ -961,7 +961,7 b' def findcmd(cmd, table, strict=True):'
961 raise error.UnknownCommand(cmd, allcmds)
961 raise error.UnknownCommand(cmd, allcmds)
962
962
963
963
964 def changebranch(ui, repo, revs, label):
964 def changebranch(ui, repo, revs, label, opts):
965 """ Change the branch name of given revs to label """
965 """ Change the branch name of given revs to label """
966
966
967 with repo.wlock(), repo.lock(), repo.transaction(b'branches'):
967 with repo.wlock(), repo.lock(), repo.transaction(b'branches'):
@@ -979,7 +979,11 b' def changebranch(ui, repo, revs, label):'
979
979
980 root = repo[roots.first()]
980 root = repo[roots.first()]
981 rpb = {parent.branch() for parent in root.parents()}
981 rpb = {parent.branch() for parent in root.parents()}
982 if label not in rpb and label in repo.branchmap():
982 if (
983 not opts.get(b'force')
984 and label not in rpb
985 and label in repo.branchmap()
986 ):
983 raise error.Abort(_(b"a branch of the same name already exists"))
987 raise error.Abort(_(b"a branch of the same name already exists"))
984
988
985 if repo.revs(b'obsolete() and %ld', revs):
989 if repo.revs(b'obsolete() and %ld', revs):
@@ -1338,7 +1338,7 b' def branch(ui, repo, label=None, **opts)'
1338
1338
1339 scmutil.checknewlabel(repo, label, b'branch')
1339 scmutil.checknewlabel(repo, label, b'branch')
1340 if revs:
1340 if revs:
1341 return cmdutil.changebranch(ui, repo, revs, label)
1341 return cmdutil.changebranch(ui, repo, revs, label, opts)
1342
1342
1343 if not opts.get(b'force') and label in repo.branchmap():
1343 if not opts.get(b'force') and label in repo.branchmap():
1344 if label not in [p.branch() for p in repo[None].parents()]:
1344 if label not in [p.branch() for p in repo[None].parents()]:
@@ -355,6 +355,13 b' Changing branch of a merge commit'
355 abort: a branch of the same name already exists
355 abort: a branch of the same name already exists
356 [255]
356 [255]
357
357
358 $ hg branch -r . stable --force
359 changed branch on 1 changesets
360 $ hg branches
361 stable 34:d1c2addda4a2
362 jkl 29:6bc1c6c2c9da (inactive)
363 ghi 28:2f1019bd29d2 (inactive)
364
358 Changing branch on public changeset
365 Changing branch on public changeset
359
366
360 $ hg phase -r . -p
367 $ hg phase -r . -p
General Comments 0
You need to be logged in to leave comments. Login now