diff hgext/mq.py @ 18143:242d2f4ec01c

util: fold ENOENT check into unlinkpath, controlled by new ignoremissing flag Refactor a common pattern.
author Mads Kiilerich <madski@unity3d.com>
date Fri, 28 Dec 2012 11:55:57 +0100
parents 569091b938a9
children 46cc3b74e1c5
line wrap: on
line diff
--- a/hgext/mq.py	Fri Dec 28 11:55:45 2012 +0100
+++ b/hgext/mq.py	Fri Dec 28 11:55:57 2012 +0100
@@ -1329,11 +1329,7 @@
                 # created while patching
                 for f in all_files:
                     if f not in repo.dirstate:
-                        try:
-                            util.unlinkpath(repo.wjoin(f))
-                        except OSError, inst:
-                            if inst.errno != errno.ENOENT:
-                                raise
+                        util.unlinkpath(repo.wjoin(f), ignoremissing=True)
                 self.ui.warn(_('done\n'))
                 raise
 
@@ -1442,11 +1438,7 @@
                 self.backup(repo, tobackup)
 
                 for f in a:
-                    try:
-                        util.unlinkpath(repo.wjoin(f))
-                    except OSError, e:
-                        if e.errno != errno.ENOENT:
-                            raise
+                    util.unlinkpath(repo.wjoin(f), ignoremissing=True)
                     repo.dirstate.drop(f)
                 for f in m + r:
                     fctx = ctx[f]