Mercurial > hg-stable
comparison mercurial/vfs.py @ 31548: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 | 8908f985570c |
children | 18b9d9b95719 |
comparison
equal
deleted
inserted
replaced
31547:bd9daafbf87c | 31548:fad440db3565 |
---|---|
220 def stat(self, path=None): | 220 def stat(self, path=None): |
221 return os.stat(self.join(path)) | 221 return os.stat(self.join(path)) |
222 | 222 |
223 def unlink(self, path=None): | 223 def unlink(self, path=None): |
224 return util.unlink(self.join(path)) | 224 return util.unlink(self.join(path)) |
225 | |
226 def tryunlink(self, path=None): | |
227 """Attempt to remove a file, ignoring missing file errors.""" | |
228 util.tryunlink(self.join(path)) | |
225 | 229 |
226 def unlinkpath(self, path=None, ignoremissing=False): | 230 def unlinkpath(self, path=None, ignoremissing=False): |
227 return util.unlinkpath(self.join(path), ignoremissing=ignoremissing) | 231 return util.unlinkpath(self.join(path), ignoremissing=ignoremissing) |
228 | 232 |
229 def utime(self, path=None, t=None): | 233 def utime(self, path=None, t=None): |