mercurial/hgweb/hgwebdir_mod.py
changeset 8191 35604226d712
parent 8190 9b8ac5fb7760
child 8209 a1a5a57efe90
equal deleted inserted replaced
8190:9b8ac5fb7760 8191:35604226d712
    15 from hgweb_mod import hgweb
    15 from hgweb_mod import hgweb
    16 from request import wsgirequest
    16 from request import wsgirequest
    17 
    17 
    18 # This is a stopgap
    18 # This is a stopgap
    19 class hgwebdir(object):
    19 class hgwebdir(object):
    20     def __init__(self, conf, parentui=None):
    20     def __init__(self, conf, baseui=None):
    21         def cleannames(items):
    21         def cleannames(items):
    22             return [(util.pconvert(name).strip('/'), path)
    22             return [(util.pconvert(name).strip('/'), path)
    23                     for name, path in items]
    23                     for name, path in items]
    24 
    24 
    25         if parentui:
    25         if baseui:
    26            self.parentui = parentui
    26            self.ui = baseui.copy()
    27         else:
    27         else:
    28             self.parentui = ui.ui()
    28             self.ui = ui.ui()
    29             self.parentui.setconfig('ui', 'report_untrusted', 'off')
    29             self.ui.setconfig('ui', 'report_untrusted', 'off')
    30             self.parentui.setconfig('ui', 'interactive', 'off')
    30             self.ui.setconfig('ui', 'interactive', 'off')
    31 
    31 
    32         self.motd = None
    32         self.motd = None
    33         self.style = 'paper'
    33         self.style = 'paper'
    34         self.stripecount = None
    34         self.stripecount = None
    35         self.repos_sorted = ('name', False)
    35         self.repos_sorted = ('name', False)
   142                 while virtual:
   142                 while virtual:
   143                     real = repos.get(virtual)
   143                     real = repos.get(virtual)
   144                     if real:
   144                     if real:
   145                         req.env['REPO_NAME'] = virtual
   145                         req.env['REPO_NAME'] = virtual
   146                         try:
   146                         try:
   147                             repo = hg.repository(self.parentui, real)
   147                             repo = hg.repository(self.ui, real)
   148                             return hgweb(repo).run_wsgi(req)
   148                             return hgweb(repo).run_wsgi(req)
   149                         except IOError, inst:
   149                         except IOError, inst:
   150                             msg = inst.strerror
   150                             msg = inst.strerror
   151                             raise ErrorResponse(HTTP_SERVER_ERROR, msg)
   151                             raise ErrorResponse(HTTP_SERVER_ERROR, msg)
   152                         except error.RepoError, inst:
   152                         except error.RepoError, inst:
   201             for name, path in self.repos:
   201             for name, path in self.repos:
   202                 if not name.startswith(subdir):
   202                 if not name.startswith(subdir):
   203                     continue
   203                     continue
   204                 name = name[len(subdir):]
   204                 name = name[len(subdir):]
   205 
   205 
   206                 u = self.parentui.copy()
   206                 u = self.ui.copy()
   207                 try:
   207                 try:
   208                     u.readconfig(os.path.join(path, '.hg', 'hgrc'))
   208                     u.readconfig(os.path.join(path, '.hg', 'hgrc'))
   209                 except Exception, e:
   209                 except Exception, e:
   210                     u.warn(_('error reading %s/.hg/hgrc: %s\n') % (path, e))
   210                     u.warn(_('error reading %s/.hg/hgrc: %s\n') % (path, e))
   211                     continue
   211                     continue
   295                 yield self.motd
   295                 yield self.motd
   296             else:
   296             else:
   297                 yield config('web', 'motd', '')
   297                 yield config('web', 'motd', '')
   298 
   298 
   299         def config(section, name, default=None, untrusted=True):
   299         def config(section, name, default=None, untrusted=True):
   300             return self.parentui.config(section, name, default, untrusted)
   300             return self.ui.config(section, name, default, untrusted)
   301 
   301 
   302         if self._baseurl is not None:
   302         if self._baseurl is not None:
   303             req.env['SCRIPT_NAME'] = self._baseurl
   303             req.env['SCRIPT_NAME'] = self._baseurl
   304 
   304 
   305         url = req.env.get('SCRIPT_NAME', '')
   305         url = req.env.get('SCRIPT_NAME', '')