changeset 31550:66c3ae6d886c

localrepo: use tryunlink
author Ryan McElroy <rmcelroy@fb.com>
date Tue, 21 Mar 2017 06:50:28 -0700
parents 18b9d9b95719
children f97e90fa5ad7
files mercurial/localrepo.py
diffstat 1 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Tue Mar 21 06:50:28 2017 -0700
+++ b/mercurial/localrepo.py	Tue Mar 21 06:50:28 2017 -0700
@@ -2025,14 +2025,10 @@
     renamefiles = [tuple(t) for t in files]
     def a():
         for vfs, src, dest in renamefiles:
-            try:
-                # if src and dest refer to a same file, vfs.rename is a no-op,
-                # leaving both src and dest on disk. delete dest to make sure
-                # the rename couldn't be such a no-op.
-                vfs.unlink(dest)
-            except OSError as ex:
-                if ex.errno != errno.ENOENT:
-                    raise
+            # if src and dest refer to a same file, vfs.rename is a no-op,
+            # leaving both src and dest on disk. delete dest to make sure
+            # the rename couldn't be such a no-op.
+            vfs.tryunlink(dest)
             try:
                 vfs.rename(src, dest)
             except OSError: # journal file does not yet exist