Mercurial > hg
changeset 31542:fad440db3565
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.
author | Ryan McElroy <rmcelroy@fb.com> |
---|---|
date | Tue, 21 Mar 2017 06:50:28 -0700 |
parents | bd9daafbf87c |
children | d5758760c0f4 |
files | mercurial/vfs.py |
diffstat | 1 files changed, 4 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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)