Patchwork [08,of,11] dirstate: use tryunlink

login
register
mail settings
Submitter Ryan McElroy
Date March 21, 2017, 1:54 p.m.
Message ID <35955261dc137fbaa702.1490104470@devbig314.prn1.facebook.com>
Download mbox | patch
Permalink /patch/19527/
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 35955261dc137fbaa70240b3f8b63326e769d1d6
# Parent  f0a1b3da14aebe21bb2e5c6f8f9c65e6d2704d28
dirstate: use tryunlink

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -1262,8 +1262,7 @@  class dirstate(object):
 
         backupname = prefix + self._filename + suffix
         assert backupname != filename
-        if self._opener.exists(backupname):
-            self._opener.unlink(backupname)
+        self._opener.tryunlink(backupname)
         # hardlink backup is okay because _writedirstate is always called
         # with an "atomictemp=True" file.
         util.copyfile(self._opener.join(filename),