vfs: add tryunlink method
authorRyan McElroy <rmcelroy@fb.com>
Tue, 21 Mar 2017 06:50:28 -0700
changeset 31542 fad440db3565
parent 31541 bd9daafbf87c
child 31543 d5758760c0f4
vfs: add tryunlink method Thoughout hg code, we see a pattern of attempting to remove a file and then catching and ignoring any errors due to a missing file in the calling code. Let's unify this pattern in a single implementation in the vfs layer.
mercurial/vfs.py
--- a/mercurial/vfs.py	Tue Mar 21 06:50:28 2017 -0700
+++ b/mercurial/vfs.py	Tue Mar 21 06:50:28 2017 -0700
@@ -223,6 +223,10 @@
     def unlink(self, path=None):
         return util.unlink(self.join(path))
 
+    def tryunlink(self, path=None):
+        """Attempt to remove a file, ignoring missing file errors."""
+        util.tryunlink(self.join(path))
+
     def unlinkpath(self, path=None, ignoremissing=False):
         return util.unlinkpath(self.join(path), ignoremissing=ignoremissing)