# HG changeset patch # User Ryan McElroy # Date 2017-03-21 13:50:28 # Node ID 66c3ae6d886cae0e3a3cff6a0058e2d2a866fd9d # Parent 18b9d9b95719ae59c64c47f4f7e405349106fed8 localrepo: use tryunlink 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