[PATCH] path_auditor: eliminate local function 'check' in __call__

Adrian Buehlmann adrian at cadifra.com
Mon Apr 11 08:34:21 CDT 2011


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1302509217 -7200
# Node ID 42170981477ac7e7fd8fd38ce198b074fbd241d0
# Parent  61ba09d8d118e4f59666332c4abb937d66c76af4
path_auditor: eliminate local function 'check' in __call__

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -555,6 +555,9 @@
         self.callback = callback
 
     def __call__(self, path):
+        '''Check the relative path.
+        path may contain a pattern (e.g. foodir/**.txt)'''
+
         if path in self.audited:
             return
         # AIX ignores "/" at end of path, others raise EISDIR.
@@ -574,7 +577,13 @@
                     base = os.path.join(*parts[:pos])
                     raise Abort(_('path %r is inside nested repo %r')
                                 % (path, base))
-        def check(prefix):
+
+        parts.pop()
+        prefixes = []
+        while parts:
+            prefix = os.sep.join(parts)
+            if prefix in self.auditeddir:
+                break
             curpath = os.path.join(self.root, prefix)
             try:
                 st = os.lstat(curpath)
@@ -592,13 +601,6 @@
                     if not self.callback or not self.callback(curpath):
                         raise Abort(_('path %r is inside nested repo %r') %
                                     (path, prefix))
-        parts.pop()
-        prefixes = []
-        while parts:
-            prefix = os.sep.join(parts)
-            if prefix in self.auditeddir:
-                break
-            check(prefix)
             prefixes.append(prefix)
             parts.pop()
 


More information about the Mercurial-devel mailing list