Comments
Patch
@@ -1020,11 +1020,15 @@
rename = opts.get('rename')
inactive = opts.get('inactive')
- def checkformat(mark):
+ def stripwhitespace(mark):
mark = mark.strip()
if not mark:
raise error.Abort(_("bookmark names cannot consist entirely of "
"whitespace"))
+ return mark
+
+ def checkformat(mark):
+ mark = stripwhitespace(mark)
scmutil.checknewlabel(repo, mark, 'bookmark')
return mark
@@ -1092,11 +1096,13 @@
raise error.Abort(_("new bookmark name required"))
elif len(names) > 1:
raise error.Abort(_("only one new bookmark name allowed"))
- mark = checkformat(names[0])
+ mark = stripwhitespace(names[0])
if rename not in marks:
raise error.Abort(_("bookmark '%s' does not exist")
% rename)
checkconflict(repo, mark, cur, force)
+ if mark not in repo._bookmarks:
+ scmutil.checknewlabel(repo, mark, 'bookmark')
marks[mark] = marks[rename]
if repo._activebookmark == rename and not inactive:
bookmarks.activate(repo, mark)
@@ -1105,7 +1111,9 @@
tr = repo.transaction('bookmark')
newact = None
for mark in names:
- mark = checkformat(mark)
+ mark = stripwhitespace(mark)
+ if not mark in repo._bookmarks:
+ scmutil.checknewlabel(repo, mark, 'bookmark')
if newact is None:
newact = mark
if inactive and mark == repo._activebookmark:
@@ -1204,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)
@@ -125,3 +125,23 @@
$ hg -q -R branch3 parents
0:5b65ba7c951d
$ rm -rf branch3
+
+numbered branches
+
+ $ hg init numbered
+ $ hg import -R numbered --exact --bypass - << EOF
+ > # HG changeset patch
+ > # User test
+ > # Date 0 0
+ > # Thu Jan 01 00:00:00 1970 +0000
+ > # Branch 100
+ > # Node ID 801033c6cd004d8b51dde9f8e6d7d28a0ac444fe
+ > # Parent 0000000000000000000000000000000000000000
+ > branch 100
+ >
+ > diff --git a/a b/a
+ > new file mode 100644
+ > EOF
+ applying patch from stdin
+ $ hg branch -R numbered 100 --force
+ marked working directory as branch 100