changeset 17818:5023027240a1

bookmarks: use scmutil.checknewlabel Validation is pulled up into the commands module to avoid an import cycle.
author Kevin Bullock <kbullock@ringworld.org>
date Wed, 17 Oct 2012 17:23:39 -0500
parents b17be267b59c
children ec892050f3c7
files mercurial/bookmarks.py mercurial/commands.py
diffstat 2 files changed, 5 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Wed Oct 17 16:34:46 2012 -0500
+++ b/mercurial/bookmarks.py	Wed Oct 17 17:23:39 2012 -0500
@@ -10,14 +10,6 @@
 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 @@
 
     if repo._bookmarkcurrent not in refs:
         setcurrent(repo, None)
-    for mark in refs.keys():
-        checkvalid(mark)
 
     wlock = repo.wlock()
     try:
@@ -113,7 +103,6 @@
 
     if mark not in repo._bookmarks:
         mark = ''
-    checkvalid(mark)
 
     wlock = repo.wlock()
     try:
--- a/mercurial/commands.py	Wed Oct 17 16:34:46 2012 -0500
+++ b/mercurial/commands.py	Wed Oct 17 17:23:39 2012 -0500
@@ -794,6 +794,11 @@
         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):