diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -153,10 +153,11 @@ class hgwebdir(object): # nested indexes and hgwebs repos = dict(self.repos) - while virtual: - real = repos.get(virtual) + virtualrepo = virtual + while virtualrepo: + real = repos.get(virtualrepo) if real: - req.env['REPO_NAME'] = virtual + req.env['REPO_NAME'] = virtualrepo try: repo = hg.repository(self.ui, real) return hgweb(repo).run_wsgi(req) @@ -166,16 +167,16 @@ class hgwebdir(object): except error.RepoError, inst: raise ErrorResponse(HTTP_SERVER_ERROR, str(inst)) - # browse subdirectories - subdir = virtual + '/' - if [r for r in repos if r.startswith(subdir)]: - req.respond(HTTP_OK, ctype) - return self.makeindex(req, tmpl, subdir) - - up = virtual.rfind('/') + up = virtualrepo.rfind('/') if up < 0: break - virtual = virtual[:up] + virtualrepo = virtualrepo[:up] + + # browse subdirectories + subdir = virtual + '/' + if [r for r in repos if r.startswith(subdir)]: + req.respond(HTTP_OK, ctype) + return self.makeindex(req, tmpl, subdir) # prefixes not found req.respond(HTTP_NOT_FOUND, ctype) diff --git a/tests/test-hgwebdir.t b/tests/test-hgwebdir.t --- a/tests/test-hgwebdir.t +++ b/tests/test-hgwebdir.t @@ -77,7 +77,7 @@ should give a 404 - repo is not publishe 404 Not Found - error: repository c not found + error: repository c/file/tip/c not found [1] atom-log without basedir diff --git a/tests/test-hgwebdirsym.t b/tests/test-hgwebdirsym.t --- a/tests/test-hgwebdirsym.t +++ b/tests/test-hgwebdirsym.t @@ -56,19 +56,19 @@ should fail 404 Not Found - error: repository circle not found + error: repository circle/al/file/tip/a not found [1] $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/circle/b/file/tip/a?style=raw' 404 Not Found - error: repository circle not found + error: repository circle/b/file/tip/a not found [1] $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/circle/c/file/tip/a?style=raw' 404 Not Found - error: repository circle not found + error: repository circle/c/file/tip/a not found [1] collections errors