changeset 11704:18c47562d331 stable

bookmarks: don't allow name to contain whitespaces only
author Idan Kamara <idankk86@gmail.com>
date Sat, 24 Jul 2010 11:20:21 +0300
parents 5ed6802e6bcb
children e95bacedae12 13d79a7bf5b7
files hgext/bookmarks.py tests/test-bookmarks tests/test-bookmarks.out
diffstat 3 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/bookmarks.py	Thu Jul 22 21:43:45 2010 +0200
+++ b/hgext/bookmarks.py	Sat Jul 24 11:20:21 2010 +0300
@@ -136,6 +136,9 @@
         if "\n" in mark:
             raise util.Abort(_("bookmark name cannot contain newlines"))
         mark = mark.strip()
+        if not mark:
+            raise util.Abort(_("bookmark names cannot consist entirely of "
+                               "whitespace"))
         if mark in marks and not force:
             raise util.Abort(_("a bookmark of the same name already exists"))
         if ((mark in repo.branchtags() or mark == repo.dirstate.branch())
--- a/tests/test-bookmarks	Thu Jul 22 21:43:45 2010 +0200
+++ b/tests/test-bookmarks	Sat Jul 24 11:20:21 2010 +0300
@@ -100,4 +100,7 @@
 echo % revision but no bookmark name
 hg bookmark -r .
 
+echo % bookmark name with whitespace only
+hg bookmark ' '
+
 true
--- a/tests/test-bookmarks.out	Thu Jul 22 21:43:45 2010 +0200
+++ b/tests/test-bookmarks.out	Sat Jul 24 11:20:21 2010 +0300
@@ -74,3 +74,5 @@
  * x  y                      2:0316ce92851d
 % revision but no bookmark name
 abort: bookmark name required
+% bookmark name with whitespace only
+abort: bookmark names cannot consist entirely of whitespace