diff --git a/hgext/bookmarks.py b/hgext/bookmarks.py --- a/hgext/bookmarks.py +++ b/hgext/bookmarks.py @@ -136,6 +136,9 @@ def bookmark(ui, repo, mark=None, rev=No 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()) diff --git a/tests/test-bookmarks b/tests/test-bookmarks --- a/tests/test-bookmarks +++ b/tests/test-bookmarks @@ -100,4 +100,7 @@ hg bookmark echo % revision but no bookmark name hg bookmark -r . +echo % bookmark name with whitespace only +hg bookmark ' ' + true diff --git a/tests/test-bookmarks.out b/tests/test-bookmarks.out --- a/tests/test-bookmarks.out +++ b/tests/test-bookmarks.out @@ -74,3 +74,5 @@ abort: a bookmark of the same name alrea * 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