# HG changeset patch # User Boris Feld # Date 2017-07-11 10:27:58 # Node ID 456626e9c3d1b93cd27a0a7a46536b67cae29574 # Parent 9212fd0039938fc41a5232aaf58ae47c303144b7 vfs: allow to pass more argument to audit We want to be able to do more precise check when auditing a path depending of the intend of the file access (eg read versus write). So we now pass the 'mode' value to 'audit' and update the audit function to accept them. This will be put to use in the next changeset. diff --git a/mercurial/pathutil.py b/mercurial/pathutil.py --- a/mercurial/pathutil.py +++ b/mercurial/pathutil.py @@ -46,7 +46,7 @@ class pathauditor(object): else: self.normcase = lambda x: x - def __call__(self, path): + def __call__(self, path, mode=None): '''Check the relative path. path may contain a pattern (e.g. foodir/**.txt)''' diff --git a/mercurial/vfs.py b/mercurial/vfs.py --- a/mercurial/vfs.py +++ b/mercurial/vfs.py @@ -306,7 +306,7 @@ class vfs(abstractvfs): if audit: self.audit = pathutil.pathauditor(self.base) else: - self.audit = util.always + self.audit = (lambda path, mode=None: True) self.createmode = None self._trustnlink = None @@ -360,7 +360,7 @@ class vfs(abstractvfs): r = util.checkosfilename(path) if r: raise error.Abort("%s: %r" % (r, path)) - self.audit(path) + self.audit(path, mode=mode) f = self.join(path) if not text and "b" not in mode: