changeset 17816:19388ba75a06

bookmarks: disallow bookmarks named 'tip', '.', or 'null' This makes bookmarks reject the same reserved names as tags and branches.
author Kevin Bullock <kbullock@ringworld.org>
date Wed, 17 Oct 2012 16:32:43 -0500
parents be1467342038
children b17be267b59c
files mercurial/bookmarks.py tests/test-bookmarks.t
diffstat 2 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Wed Oct 17 17:03:01 2012 -0500
+++ b/mercurial/bookmarks.py	Wed Oct 17 16:32:43 2012 -0500
@@ -15,6 +15,8 @@
         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
--- a/tests/test-bookmarks.t	Wed Oct 17 17:03:01 2012 -0500
+++ b/tests/test-bookmarks.t	Wed Oct 17 16:32:43 2012 -0500
@@ -222,6 +222,21 @@
   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