Mercurial > public > mercurial-scm > hg-stable
diff hgext/mq.py @ 13507:375ba42f3cda stable
mq: gracefully handle malformated status file
This patch prevent mq to crash when .hg/patches/status contains Malformed lines
(without ":"). Blank lines are ignored and other malformed lines issue a
warning.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Fri, 11 Feb 2011 13:10:39 +0100 |
parents | 9e5df8719ad4 |
children | 0396ca8015be |
line wrap: on
line diff
--- a/hgext/mq.py Thu Feb 24 00:47:49 2011 +0100 +++ b/hgext/mq.py Fri Feb 11 13:10:39 2011 +0100 @@ -282,11 +282,17 @@ @util.propertycache def applied(self): if os.path.exists(self.join(self.status_path)): - def parse(l): - n, name = l.split(':', 1) - return statusentry(bin(n), name) + def parselines(lines): + for l in lines: + entry = l.split(':', 1) + if len(entry) > 1: + n, name = entry + yield statusentry(bin(n), name) + elif l.strip(): + self.ui.warn(_('malformated mq status line: %s\n') % entry) + # else we ignore empty lines lines = self.opener(self.status_path).read().splitlines() - return [parse(l) for l in lines] + return list(parselines(lines)) return [] @util.propertycache