Mercurial > hg
changeset 15258:fe9677449331
mq: eliminate explicit checks for file existence
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Fri, 14 Oct 2011 19:51:46 +0200 |
parents | a8555f9908d1 |
children | 1d1f6dff9364 |
files | hgext/mq.py |
diffstat | 1 files changed, 20 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Fri Oct 14 02:50:06 2011 +0200 +++ b/hgext/mq.py Fri Oct 14 19:51:46 2011 +0200 @@ -287,26 +287,31 @@ @util.propertycache def applied(self): - if os.path.exists(self.join(self.statuspath)): - 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(): - msg = _('malformated mq status line: %s\n') % entry - self.ui.warn(msg) - # else we ignore empty lines + 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 + try: lines = self.opener.read(self.statuspath).splitlines() return list(parselines(lines)) - return [] + except IOError, e: + if e.errno == errno.ENOENT: + return [] + raise @util.propertycache def fullseries(self): - if os.path.exists(self.join(self.seriespath)): - return self.opener.read(self.seriespath).splitlines() - return [] + try: + return self.opener.read(self.seriespath).splitlines() + except IOError, e: + if e.errno == errno.ENOENT: + return [] + raise @util.propertycache def series(self):