[PATCH 2 of 2] bookmarks: Add a warning for non empty malformated line
pierre-yves.david at logilab.fr
pierre-yves.david at logilab.fr
Tue Jul 5 04:51:46 CDT 2011
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1309854027 -7200
# Branch stable
# Node ID bc187cbdf4efb51f7ee83df798aa679c9aff0d2d
# Parent a59f9d94beba02c92c7c37b7c0d8034873fca580
bookmarks: Add a warning for non empty malformated line.
diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -26,10 +26,13 @@ def read(repo):
bookmarks = {}
try:
for line in repo.opener('bookmarks'):
line = line.strip()
if ' ' not in line:
+ if line:
+ msg = _('malformated line in .hg/bookmarks: %r\n')
+ repo.ui.warn( msg % line)
continue
sha, refspec = line.strip().split(' ', 1)
refspec = encoding.tolocal(refspec)
try:
bookmarks[refspec] = repo.changelog.lookup(sha)
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -348,5 +348,13 @@ test wrongly formated bookmark
$ hg bookmarks
X2 1:925d80f479bb
Y 2:db815d6d32e6
* Z 3:125c9a1d6df6
x y 2:db815d6d32e6
+ $ echo "Ican'thasformatedlines" >> .hg/bookmarks
+ $ hg bookmarks
+ malformated line in .hg/bookmarks: "Ican'thasformatedlines"
+ X2 1:925d80f479bb
+ Y 2:db815d6d32e6
+ * Z 3:125c9a1d6df6
+ x y 2:db815d6d32e6
+
More information about the Mercurial-devel
mailing list