# HG changeset patch # User Martin Geisler # Date 1283118979 -7200 # Node ID 41e56e07eef541e455c9786cb38aff1fd6290d58 # Parent e03ca36ba9f3f030358cff682d28a153ee3d6797 path_auditor: delegate checking of nested repos to a callback diff -r e03ca36ba9f3 -r 41e56e07eef5 mercurial/util.py --- 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: