# HG changeset patch # User Brendan Cully # Date 1183870556 25200 # Node ID edd07be943dd0bb14793349e8516c6bb86122049 # Parent 9a45e1597d0840da7f8bf67c4061912db43632c3 hgwebdir: check for repo foo before browsing subdirectories of foo/ 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 @@ -221,31 +221,31 @@ class hgwebdir(object): tmpl('error', error='%r not found' % fname)) elif virtual: repos = dict(self.repos) - # browse subdirectories - subdir = virtual + '/' - if [r for r in repos if r.startswith(subdir)]: - makeindex(req, subdir) - return - while virtual: real = repos.get(virtual) if real: - break + req.env['REPO_NAME'] = virtual + try: + repo = hg.repository(parentui, real) + hgweb(repo).run_wsgi(req) + except IOError, inst: + req.write(tmpl("error", error=inst.strerror)) + except hg.RepoError, inst: + req.write(tmpl("error", error=str(inst))) + return + + # browse subdirectories + subdir = virtual + '/' + if [r for r in repos if r.startswith(subdir)]: + makeindex(req, subdir) + return + up = virtual.rfind('/') if up < 0: break virtual = virtual[:up] - if real: - req.env['REPO_NAME'] = virtual - try: - repo = hg.repository(parentui, real) - hgweb(repo).run_wsgi(req) - except IOError, inst: - req.write(tmpl("error", error=inst.strerror)) - except hg.RepoError, inst: - req.write(tmpl("error", error=str(inst))) - else: - req.write(tmpl("notfound", repo=virtual)) + + req.write(tmpl("notfound", repo=virtual)) else: if req.form.has_key('static'): static = os.path.join(templater.templatepath(), "static")