changeset 4852:edd07be943dd

hgwebdir: check for repo foo before browsing subdirectories of foo/
author Brendan Cully <brendan@kublai.com>
date Sat, 07 Jul 2007 21:55:56 -0700
parents 9a45e1597d08
children bf10a03a6b24
files mercurial/hgweb/hgwebdir_mod.py
diffstat 1 files changed, 18 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py	Sat Jul 07 15:09:28 2007 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py	Sat Jul 07 21:55:56 2007 -0700
@@ -221,31 +221,31 @@
                           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")