mercurial/hgweb/hgwebdir_mod.py
changeset 32004 bd3cb917761a
parent 31489 da7d19324b1e
child 32808 eede022fc142
--- a/mercurial/hgweb/hgwebdir_mod.py	Fri Apr 14 00:03:30 2017 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py	Fri Mar 31 23:00:41 2017 -0400
@@ -257,7 +257,7 @@
 
             repos = dict(self.repos)
 
-            if not virtual or (virtual == 'index' and virtual not in repos):
+            if (not virtual or virtual == 'index') and virtual not in repos:
                 req.respond(HTTP_OK, ctype)
                 return self.makeindex(req, tmpl)
 
@@ -269,8 +269,17 @@
                     req.respond(HTTP_OK, ctype)
                     return self.makeindex(req, tmpl, subdir)
 
-            virtualrepo = virtual
-            while virtualrepo:
+            def _virtualdirs():
+                # Check the full virtual path, each parent, and the root ('')
+                if virtual != '':
+                    yield virtual
+
+                    for p in util.finddirs(virtual):
+                        yield p
+
+                yield ''
+
+            for virtualrepo in _virtualdirs():
                 real = repos.get(virtualrepo)
                 if real:
                     req.env['REPO_NAME'] = virtualrepo
@@ -284,11 +293,6 @@
                     except error.RepoError as inst:
                         raise ErrorResponse(HTTP_SERVER_ERROR, str(inst))
 
-                up = virtualrepo.rfind('/')
-                if up < 0:
-                    break
-                virtualrepo = virtualrepo[:up]
-
             # browse subdirectories
             subdir = virtual + '/'
             if [r for r in repos if r.startswith(subdir)]: