bookmarks: more robust parsing of bookmarks file
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 05 Jul 2011 10:13:54 +0200
changeset 14845 677339529a53
parent 14844 7aaae5466ad3
child 14846 5097d8b5078c
bookmarks: more robust parsing of bookmarks file
mercurial/bookmarks.py
tests/test-bookmarks.t
--- a/mercurial/bookmarks.py	Wed Jul 06 19:25:53 2011 -0500
+++ b/mercurial/bookmarks.py	Tue Jul 05 10:13:54 2011 +0200
@@ -26,6 +26,9 @@
     bookmarks = {}
     try:
         for line in repo.opener('bookmarks'):
+            line = line.strip()
+            if ' ' not in line:
+                continue
             sha, refspec = line.strip().split(' ', 1)
             refspec = encoding.tolocal(refspec)
             try:
--- a/tests/test-bookmarks.t	Wed Jul 06 19:25:53 2011 -0500
+++ b/tests/test-bookmarks.t	Tue Jul 05 10:13:54 2011 +0200
@@ -342,3 +342,11 @@
    * Z                         3:125c9a1d6df6
      x  y                      2:db815d6d32e6
 
+test wrongly formated bookmark
+
+  $ echo '' >> .hg/bookmarks
+  $ hg bookmarks
+     X2                        1:925d80f479bb
+     Y                         2:db815d6d32e6
+   * Z                         3:125c9a1d6df6
+     x  y                      2:db815d6d32e6