diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -282,11 +282,17 @@ class queue(object): @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 diff --git a/tests/test-mq.t b/tests/test-mq.t --- a/tests/test-mq.t +++ b/tests/test-mq.t @@ -917,6 +917,25 @@ bad node in status copy to copy $ cd .. +empty lines in status + + $ hg init emptystatus + $ cd emptystatus + $ hg qinit + $ printf '\n\n' > .hg/patches/status + $ hg qser + $ cd .. + +bad line in status (without ":") + + $ hg init badstatus + $ cd badstatus + $ hg qinit + $ printf 'babar has no colon in this line\n' > .hg/patches/status + $ hg qser + malformated mq status line: ['babar has no colon in this line'] + $ cd .. + test file addition in slow path