[PATCH] mq: eliminate explicit checks for file existence
Idan Kamara
idankk86 at gmail.com
Fri Oct 14 12:52:18 CDT 2011
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1318614706 -7200
# Node ID e7d083d4b3f805f9b69687888e01b5cb882f1b01
# Parent 153279c7035c37f8a287377c1ea1d48b8985a595
mq: eliminate explicit checks for file existence
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -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):
More information about the Mercurial-devel
mailing list