mercurial/hgweb/hgwebdir_mod.py
branchstable
changeset 13066 86888ae9ce90
parent 12696 ef969e58a394
child 13214 5bcb6c9d16db
equal deleted inserted replaced
13065:de4a18cbfc98 13066:86888ae9ce90
   151                     return self.makeindex(req, tmpl)
   151                     return self.makeindex(req, tmpl)
   152 
   152 
   153                 # nested indexes and hgwebs
   153                 # nested indexes and hgwebs
   154 
   154 
   155                 repos = dict(self.repos)
   155                 repos = dict(self.repos)
   156                 while virtual:
   156                 virtualrepo = virtual
   157                     real = repos.get(virtual)
   157                 while virtualrepo:
       
   158                     real = repos.get(virtualrepo)
   158                     if real:
   159                     if real:
   159                         req.env['REPO_NAME'] = virtual
   160                         req.env['REPO_NAME'] = virtualrepo
   160                         try:
   161                         try:
   161                             repo = hg.repository(self.ui, real)
   162                             repo = hg.repository(self.ui, real)
   162                             return hgweb(repo).run_wsgi(req)
   163                             return hgweb(repo).run_wsgi(req)
   163                         except IOError, inst:
   164                         except IOError, inst:
   164                             msg = inst.strerror
   165                             msg = inst.strerror
   165                             raise ErrorResponse(HTTP_SERVER_ERROR, msg)
   166                             raise ErrorResponse(HTTP_SERVER_ERROR, msg)
   166                         except error.RepoError, inst:
   167                         except error.RepoError, inst:
   167                             raise ErrorResponse(HTTP_SERVER_ERROR, str(inst))
   168                             raise ErrorResponse(HTTP_SERVER_ERROR, str(inst))
   168 
   169 
   169                     # browse subdirectories
   170                     up = virtualrepo.rfind('/')
   170                     subdir = virtual + '/'
       
   171                     if [r for r in repos if r.startswith(subdir)]:
       
   172                         req.respond(HTTP_OK, ctype)
       
   173                         return self.makeindex(req, tmpl, subdir)
       
   174 
       
   175                     up = virtual.rfind('/')
       
   176                     if up < 0:
   171                     if up < 0:
   177                         break
   172                         break
   178                     virtual = virtual[:up]
   173                     virtualrepo = virtualrepo[:up]
       
   174 
       
   175                 # browse subdirectories
       
   176                 subdir = virtual + '/'
       
   177                 if [r for r in repos if r.startswith(subdir)]:
       
   178                     req.respond(HTTP_OK, ctype)
       
   179                     return self.makeindex(req, tmpl, subdir)
   179 
   180 
   180                 # prefixes not found
   181                 # prefixes not found
   181                 req.respond(HTTP_NOT_FOUND, ctype)
   182                 req.respond(HTTP_NOT_FOUND, ctype)
   182                 return tmpl("notfound", repo=virtual)
   183                 return tmpl("notfound", repo=virtual)
   183 
   184