changeset 12079:41e56e07eef5

path_auditor: delegate checking of nested repos to a callback
author Martin Geisler <mg@lazybytes.net>
date Sun, 29 Aug 2010 23:56:19 +0200
parents e03ca36ba9f3
children 5e2216a35839
files mercurial/util.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Sun Aug 29 23:56:19 2010 +0200
+++ b/mercurial/util.py	Sun Aug 29 23:56:19 2010 +0200
@@ -492,12 +492,15 @@
     - starts at the root of a windows drive
     - contains ".."
     - traverses a symlink (e.g. a/symlink_here/b)
-    - inside a nested repository'''
+    - inside a nested repository (a callback can be used to approve
+      some nested repositories, e.g., subrepositories)
+    '''
 
-    def __init__(self, root):
+    def __init__(self, root, callback=None):
         self.audited = set()
         self.auditeddir = set()
         self.root = root
+        self.callback = callback
 
     def __call__(self, path):
         if path in self.audited:
@@ -530,8 +533,9 @@
                                 (path, prefix))
                 elif (stat.S_ISDIR(st.st_mode) and
                       os.path.isdir(os.path.join(curpath, '.hg'))):
-                    raise Abort(_('path %r is inside repo %r') %
-                                (path, prefix))
+                    if not self.callback or not self.callback(curpath):
+                        raise Abort(_('path %r is inside repo %r') %
+                                    (path, prefix))
         parts.pop()
         prefixes = []
         while parts: