diff mercurial/hgweb/hgwebdir_mod.py @ 32004:bd3cb917761a

hgwebdir: allow a repository to be hosted at "/" This can be useful in general, but will also be useful for hosting subrepos, with the main repo at /.
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 31 Mar 2017 23:00:41 -0400
parents da7d19324b1e
children eede022fc142
line wrap: on
line diff
--- 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)]: