[PATCH 6 of 9] bookmarks: use scmutil.checknewlabel
Kevin Bullock
kbullock+mercurial at ringworld.org
Wed Oct 17 22:31:46 CDT 2012
# HG changeset patch
# User Kevin Bullock <kbullock at ringworld.org>
# Date 1350512619 18000
# Node ID e4083c2811721ad7f408b9540c325e4b97d38ecf
# Parent 614653e8d2896effe42c94c196f2de9a1b333a5f
bookmarks: use scmutil.checknewlabel
Validation is pulled up into the commands module to avoid an import
cycle.
diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -10,14 +10,6 @@ from mercurial.node import hex
from mercurial import encoding, error, util, obsolete, phases
import errno, os
-def checkvalid(mark):
- for c in (':', '\0', '\n', '\r'):
- if c in mark:
- raise util.Abort(_("bookmark '%s' contains illegal "
- "character" % mark))
- if mark in ['tip', '.', 'null']:
- raise util.Abort(_('the name \'%s\' is reserved') % mark)
-
def read(repo):
'''Parse .hg/bookmarks file and return a dictionary
@@ -81,8 +73,6 @@ def write(repo):
if repo._bookmarkcurrent not in refs:
setcurrent(repo, None)
- for mark in refs.keys():
- checkvalid(mark)
wlock = repo.wlock()
try:
@@ -113,7 +103,6 @@ def setcurrent(repo, mark):
if mark not in repo._bookmarks:
mark = ''
- checkvalid(mark)
wlock = repo.wlock()
try:
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -794,6 +794,11 @@ def bookmark(ui, repo, mark=None, rev=No
if not mark:
raise util.Abort(_("bookmark names cannot consist entirely of "
"whitespace"))
+ for c in (':', '\0', '\n', '\r'):
+ if c in mark:
+ raise util.Abort(_("bookmark '%s' contains illegal "
+ "character" % mark))
+ scmutil.checknewlabel(repo, mark)
return mark
def checkconflict(repo, mark, force=False):
More information about the Mercurial-devel
mailing list