# HG changeset patch # User Pierre-Yves David # Date 2011-07-05 08:13:54 # Node ID 677339529a53a98e0bfb7b2ddfd715d3ef0f62f5 # Parent 7aaae5466ad35e1c17b0dc72272bbcd719255666 bookmarks: more robust parsing of bookmarks file diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -26,6 +26,9 @@ def read(repo): 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: diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t --- a/tests/test-bookmarks.t +++ b/tests/test-bookmarks.t @@ -342,3 +342,11 @@ create bundle with two heads * 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