changeset 33435:456626e9c3d1

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.
author Boris Feld <boris.feld@octobus.net>
date Tue, 11 Jul 2017 12:27:58 +0200
parents 9212fd003993
children 9bb4decd43b0
files mercurial/pathutil.py mercurial/vfs.py
diffstat 2 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/pathutil.py	Wed Jul 12 10:11:02 2017 +0200
+++ b/mercurial/pathutil.py	Tue Jul 11 12:27:58 2017 +0200
@@ -46,7 +46,7 @@
         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)'''
 
--- a/mercurial/vfs.py	Wed Jul 12 10:11:02 2017 +0200
+++ b/mercurial/vfs.py	Tue Jul 11 12:27:58 2017 +0200
@@ -306,7 +306,7 @@
         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 @@
                 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: