Patchwork [10,of,11] vfs: use tryunlink

login
register
mail settings
Submitter Ryan McElroy
Date March 21, 2017, 1:54 p.m.
Message ID <ba24c5cdac8654da7d0d.1490104472@devbig314.prn1.facebook.com>
Download mbox | patch
Permalink /patch/19524/
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 ba24c5cdac8654da7d0d510e3643226e69cef187
# Parent  684d201e116b65e6dff5f9494de064591da57b07
vfs: use tryunlink
Yuya Nishihara - March 21, 2017, 2:25 p.m.
On Tue, 21 Mar 2017 06:54:32 -0700, Ryan McElroy wrote:
> # HG changeset patch
> # User Ryan McElroy <rmcelroy@fb.com>
> # Date 1490104228 25200
> #      Tue Mar 21 06:50:28 2017 -0700
> # Node ID ba24c5cdac8654da7d0d510e3643226e69cef187
> # Parent  684d201e116b65e6dff5f9494de064591da57b07
> vfs: use tryunlink
> 
> diff --git a/mercurial/vfs.py b/mercurial/vfs.py
> --- a/mercurial/vfs.py
> +++ b/mercurial/vfs.py
> @@ -401,10 +401,7 @@ class vfs(abstractvfs):
>      def symlink(self, src, dst):
>          self.audit(dst)
>          linkname = self.join(dst)
> -        try:
> -            os.unlink(linkname)
> -        except OSError:
> -            pass
> +        util.tryunlink(linkname)

I tracked history of this code down to 41ad4105dde9, and there seems no
practical reason to suppress all kinds of OSError. Looks good.

Patch

diff --git a/mercurial/vfs.py b/mercurial/vfs.py
--- a/mercurial/vfs.py
+++ b/mercurial/vfs.py
@@ -401,10 +401,7 @@  class vfs(abstractvfs):
     def symlink(self, src, dst):
         self.audit(dst)
         linkname = self.join(dst)
-        try:
-            os.unlink(linkname)
-        except OSError:
-            pass
+        util.tryunlink(linkname)
 
         util.makedirs(os.path.dirname(linkname), self.createmode)