[PATCH 12 of 14] bookmarks: Correctly reject newlines in bookmark names

Joel Rosdahl joel at rosdahl.net
Sat Oct 25 10:18:45 CDT 2008


# HG changeset patch
# User Joel Rosdahl <joel at rosdahl.net>
# Date 1224947621 -7200
# Node ID a732a6b872d696c46a8477e6dcc4c6906c00aa05
# Parent  28cd751bd3c3a9ae0ef696c154765daaf766edc6
bookmarks: Correctly reject newlines in bookmark names

Without this fix, a single newline is a valid bookmark name since
strip() removes it.

diff --git a/hgext/bookmarks.py b/hgext/bookmarks.py
--- a/hgext/bookmarks.py
+++ b/hgext/bookmarks.py
@@ -98,8 +98,8 @@
         return
 
     if mark != None:
-        if mark.strip().count("\n") > 0:
-            raise util.Abort(_("bookmark cannot contain newlines"))
+        if "\n" in mark:
+            raise util.Abort(_("bookmark name cannot contain newlines"))
         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())


More information about the Mercurial-devel mailing list