# HG changeset patch # User Idan Kamara # Date 1318614706 -7200 # Node ID fe967744933108e272f17d49085f9ceadc2ab5f7 # Parent a8555f9908d1df1e9fe25deb739fddb9095e9ae7 mq: eliminate explicit checks for file existence diff -r a8555f9908d1 -r fe9677449331 hgext/mq.py --- 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):