[PATCH 1 of 3 V2] vfs: allow to pass more argument to audit

Boris Feld boris.feld at octobus.net
Tue Jul 11 14:36:59 UTC 2017


# HG changeset patch
# User Octobus <contact at octobus.net>
# Date 1499768878 -7200
#      Tue Jul 11 12:27:58 2017 +0200
# Node ID b780af8186e280e459365533133ea6bbad5c6ae2
# Parent  4672db164c986da4442bd864cd044512d975c3f2
# EXP-Topic vfs.ward
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'
and 'atomictemp' value to 'audit' and update the audit function to accept them.

This will be put to use in the next changeset.

diff -r 4672db164c98 -r b780af8186e2 mercurial/pathutil.py
--- a/mercurial/pathutil.py	Sat Jun 24 15:29:42 2017 -0700
+++ 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, atomictemp=None):
         '''Check the relative path.
         path may contain a pattern (e.g. foodir/**.txt)'''
 
diff -r 4672db164c98 -r b780af8186e2 mercurial/vfs.py
--- a/mercurial/vfs.py	Sat Jun 24 15:29:42 2017 -0700
+++ 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, atomictemp=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, atomictemp=atomictemp)
         f = self.join(path)
 
         if not text and "b" not in mode:


More information about the Mercurial-devel mailing list