[PATCH 4 of 9] bookmarks: disallow bookmarks named 'tip', '.', or 'null'

Kevin Bullock kbullock+mercurial at ringworld.org
Wed Oct 17 22:31:44 CDT 2012


# HG changeset patch
# User Kevin Bullock <kbullock at ringworld.org>
# Date 1350509563 18000
# Node ID 2a50542fd0a2626b1e7bdab5b35d32220f4bbb7f
# Parent  de8aa47d28efd29ecdeaeb03f8cc49dc15650fb9
bookmarks: disallow bookmarks named 'tip', '.', or 'null'

This makes bookmarks reject the same reserved names as tags and branches.

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -15,6 +15,8 @@ def checkvalid(mark):
         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
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -222,6 +222,21 @@ reject bookmark name with newline
   abort: bookmark names cannot consist entirely of whitespace
   [255]
 
+bookmark with reserved name
+
+  $ hg bookmark tip
+  abort: the name 'tip' is reserved
+  [255]
+
+  $ hg bookmark .
+  abort: the name '.' is reserved
+  [255]
+
+  $ hg bookmark null
+  abort: the name 'null' is reserved
+  [255]
+
+
 bookmark with existing name
 
   $ hg bookmark Z


More information about the Mercurial-devel mailing list