bookmarks: add a warning for non empty malformed line
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 05 Jul 2011 10:20:27 +0200
changeset 14846 5097d8b5078c
parent 14845 677339529a53
child 14847 400ba7cccbae
bookmarks: add a warning for non empty malformed line
mercurial/bookmarks.py
tests/test-bookmarks.t
--- a/mercurial/bookmarks.py	Tue Jul 05 10:13:54 2011 +0200
+++ b/mercurial/bookmarks.py	Tue Jul 05 10:20:27 2011 +0200
@@ -28,6 +28,9 @@
         for line in repo.opener('bookmarks'):
             line = line.strip()
             if ' ' not in line:
+                if line:
+                    msg = _('malformed line in .hg/bookmarks: %r\n')
+                    repo.ui.warn( msg % line)
                 continue
             sha, refspec = line.strip().split(' ', 1)
             refspec = encoding.tolocal(refspec)
--- a/tests/test-bookmarks.t	Tue Jul 05 10:13:54 2011 +0200
+++ b/tests/test-bookmarks.t	Tue Jul 05 10:20:27 2011 +0200
@@ -350,3 +350,11 @@
      Y                         2:db815d6d32e6
    * Z                         3:125c9a1d6df6
      x  y                      2:db815d6d32e6
+  $ echo "Ican'thasformatedlines" >> .hg/bookmarks
+  $ hg bookmarks
+  malformed line in .hg/bookmarks: "Ican'thasformatedlines"
+     X2                        1:925d80f479bb
+     Y                         2:db815d6d32e6
+   * Z                         3:125c9a1d6df6
+     x  y                      2:db815d6d32e6
+