path_auditor: eliminate local function 'check' in __call__
authorAdrian Buehlmann <adrian@cadifra.com>
Mon, 11 Apr 2011 10:06:57 +0200
changeset 13928 155d2e17884e
parent 13927 518344d02761
child 13929 cff56a0ed18e
path_auditor: eliminate local function 'check' in __call__
mercurial/util.py
--- a/mercurial/util.py	Mon Apr 11 07:34:40 2011 -0500
+++ b/mercurial/util.py	Mon Apr 11 10:06:57 2011 +0200
@@ -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()