diff mercurial/util.py @ 7523:e60aaae83323

hgweb: recurse down collections only if ** in [paths] collections: direct child repos only paths *: direct child repos only (like collections) paths **: recursive discovery When ** is used, the mq repository (if any) is also shown.
author Benoit Allard <benoit@aeteurope.nl>
date Thu, 18 Dec 2008 22:32:48 +0100
parents 85dc88630beb
children 6a49fa7674c1 9a962209dc28
line wrap: on
line diff
--- a/mercurial/util.py	Mon Dec 15 12:02:18 2008 -0800
+++ b/mercurial/util.py	Thu Dec 18 22:32:48 2008 +0100
@@ -1876,7 +1876,7 @@
     else:
         return "%s..." % (text[:maxlength-3])
 
-def walkrepos(path, followsym=False, seen_dirs=None):
+def walkrepos(path, followsym=False, seen_dirs=None, recurse=False):
     '''yield every hg repository under path, recursively.'''
     def errhandler(err):
         if err.filename == path:
@@ -1901,11 +1901,16 @@
         _add_dir_if_not_there(seen_dirs, path)
     for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler):
         if '.hg' in dirs:
-            dirs[:] = [] # don't descend further
             yield root # found a repository
-            qroot = os.path.join(root, '.hg', 'patches')
-            if os.path.isdir(os.path.join(qroot, '.hg')):
-                yield qroot # we have a patch queue repo here
+            if recurse:
+                # avoid recursing inside the .hg directory
+                # the mq repository is added in any case
+                dirs.remove('.hg')
+                qroot = os.path.join(root, '.hg', 'patches')
+                if os.path.isdir(os.path.join(qroot, '.hg')):
+                    yield qroot # we have a patch queue repo here
+            else:
+                dirs[:] = [] # don't descend further
         elif followsym:
             newdirs = []
             for d in dirs: