hgwebdir: show nested repositories (issue1336)
authorBenoit Allard <benoit@aeteurope.nl>
Wed, 22 Oct 2008 18:23:32 +0200
changeset 7201 b1aea76f7001
parent 7200 ca5ac40949dc
child 7202 268c582bd42a
hgwebdir: show nested repositories (issue1336)
mercurial/util.py
tests/test-walkrepo.py
--- a/mercurial/util.py	Wed Oct 22 13:14:52 2008 +0200
+++ b/mercurial/util.py	Wed Oct 22 18:23:32 2008 +0200
@@ -1852,7 +1852,7 @@
         _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
+            dirs.remove('.hg') # don't recurse inside the .hg directory
             yield root # found a repository
             qroot = os.path.join(root, '.hg', 'patches')
             if os.path.isdir(os.path.join(qroot, '.hg')):
--- a/tests/test-walkrepo.py	Wed Oct 22 13:14:52 2008 +0200
+++ b/tests/test-walkrepo.py	Wed Oct 22 18:23:32 2008 +0200
@@ -12,6 +12,12 @@
 mkdir('subdir')
 chdir('subdir')
 hg.repository(u, 'sub1', create=1)
+chdir('sub1')
+hg.repository(u, 'inside_sub1', create=1)
+chdir('.hg')
+hg.repository(u, 'patches', create=1)
+chdir(os.path.pardir)
+chdir(os.path.pardir)
 mkdir('subsubdir')
 chdir('subsubdir')
 hg.repository(u, 'subsub1', create=1)
@@ -22,12 +28,12 @@
 
 def runtest():
     reposet = frozenset(walkrepos('.', followsym=True))
-    if sym and (len(reposet) != 3):
+    if sym and (len(reposet) != 5):
         print "reposet = %r" % (reposet,)
-        raise SystemExit(1, "Found %d repositories when I should have found 3" % (len(reposet),))
-    if (not sym) and (len(reposet) != 2):
+        raise SystemExit(1, "Found %d repositories when I should have found 5" % (len(reposet),))
+    if (not sym) and (len(reposet) != 4):
         print "reposet = %r" % (reposet,)
-        raise SystemExit(1, "Found %d repositories when I should have found 2" % (len(reposet),))
+        raise SystemExit(1, "Found %d repositories when I should have found 4" % (len(reposet),))
     sub1set = frozenset((pjoin('.', 'sub1'),
                          pjoin('.', 'circle', 'subdir', 'sub1')))
     if len(sub1set & reposet) != 1: