Patchwork [11,of,11] localrepo: use tryunlink

login
register
mail settings
Submitter Ryan McElroy
Date March 21, 2017, 1:54 p.m.
Message ID <f5d46850f168c1dab9d4.1490104473@devbig314.prn1.facebook.com>
Download mbox | patch
Permalink /patch/19525/
State Accepted
Headers show

Comments

Ryan McElroy - March 21, 2017, 1:54 p.m.
# HG changeset patch
# User Ryan McElroy <rmcelroy@fb.com>
# Date 1490104228 25200
#      Tue Mar 21 06:50:28 2017 -0700
# Node ID f5d46850f168c1dab9d46688e900a22d5ddac05b
# Parent  ba24c5cdac8654da7d0d510e3643226e69cef187
localrepo: use tryunlink

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2025,14 +2025,10 @@  def aftertrans(files):
     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