[PATCH 2 of 5] commands: delay checknewlabel until after aborts
timeless
timeless at mozdev.org
Sun Jan 10 12:57:49 CST 2016
# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1451185999 0
# Sun Dec 27 03:13:19 2015 +0000
# Node ID b15de606bd509eba76554071d9e4e40b1a9bb879
# Parent 81f7508339fc28775b31ab1724c88eda6d11e85e
commands: delay checknewlabel until after aborts
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1030,7 +1030,6 @@
if not mark:
raise error.Abort(_("bookmark names cannot consist entirely of "
"whitespace"))
- scmutil.checknewlabel(repo, mark, 'bookmark')
return mark
def checkconflict(repo, mark, cur, force=False, target=None):
@@ -1102,6 +1101,8 @@
raise error.Abort(_("bookmark '%s' does not exist")
% rename)
checkconflict(repo, mark, cur, force)
+ if not mark in repo._bookmarks:
+ scmutil.checknewlabel(repo, mark, 'bookmark')
marks[mark] = marks[rename]
if repo._activebookmark == rename and not inactive:
bookmarks.activate(repo, mark)
@@ -1111,6 +1112,8 @@
newact = None
for mark in names:
mark = checkformat(mark)
+ if not mark in repo._bookmarks:
+ scmutil.checknewlabel(repo, mark, 'bookmark')
if newact is None:
newact = mark
if inactive and mark == repo._activebookmark:
@@ -1209,13 +1212,15 @@
repo.dirstate.setbranch(label)
ui.status(_('reset working directory to branch %s\n') % label)
elif label:
- if not opts.get('force') and label in repo.branchmap():
- if label not in [p.branch() for p in repo[None].parents()]:
- raise error.Abort(_('a branch of the same name already'
- ' exists'),
- # i18n: "it" refers to an existing branch
- hint=_("use 'hg update' to switch to it"))
- scmutil.checknewlabel(repo, label, 'branch')
+ if label in repo.branchmap():
+ if not opts.get('force'):
+ if label not in [p.branch() for p in repo[None].parents()]:
+ raise error.Abort(
+ _('a branch of the same name already exists'),
+ # i18n: "it" refers to an existing branch
+ hint=_("use 'hg update' to switch to it"))
+ else:
+ scmutil.checknewlabel(repo, label, 'branch')
repo.dirstate.setbranch(label)
ui.status(_('marked working directory as branch %s\n') % label)
More information about the Mercurial-devel
mailing list