mercurial/hgweb/hgwebdir_mod.py
changeset 4079 40c9710e8182
parent 3882 9c8488490724
child 4080 ef14fdb675da
equal deleted inserted replaced
4078:ff08cebcd116 4079:40c9710e8182
    14 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile,style_map")
    14 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile,style_map")
    15 from mercurial.i18n import gettext as _
    15 from mercurial.i18n import gettext as _
    16 
    16 
    17 # This is a stopgap
    17 # This is a stopgap
    18 class hgwebdir(object):
    18 class hgwebdir(object):
    19     def __init__(self, config):
    19     def __init__(self, config, parentui=None):
    20         def cleannames(items):
    20         def cleannames(items):
    21             return [(name.strip(os.sep), path) for name, path in items]
    21             return [(name.strip(os.sep), path) for name, path in items]
    22 
    22 
       
    23         self.parentui = parentui
    23         self.motd = ""
    24         self.motd = ""
    24         self.style = ""
    25         self.style = ""
    25         self.repos_sorted = ('name', False)
    26         self.repos_sorted = ('name', False)
    26         if isinstance(config, (list, tuple)):
    27         if isinstance(config, (list, tuple)):
    27             self.repos = cleannames(config)
    28             self.repos = cleannames(config)
    71             yield tmpl("footer", **map)
    72             yield tmpl("footer", **map)
    72 
    73 
    73         def motd(**map):
    74         def motd(**map):
    74             yield self.motd
    75             yield self.motd
    75 
    76 
       
    77         parentui = self.parentui or ui.ui(report_untrusted=False)
       
    78 
    76         url = req.env['REQUEST_URI'].split('?')[0]
    79         url = req.env['REQUEST_URI'].split('?')[0]
    77         if not url.endswith('/'):
    80         if not url.endswith('/'):
    78             url += '/'
    81             url += '/'
    79 
    82 
    80         style = self.style
    83         style = self.style
   109                     separator = ';'
   112                     separator = ';'
   110 
   113 
   111             rows = []
   114             rows = []
   112             parity = 0
   115             parity = 0
   113             for name, path in self.repos:
   116             for name, path in self.repos:
   114                 u = ui.ui(report_untrusted=False)
   117                 u = ui.ui(parentui=parentui)
   115                 try:
   118                 try:
   116                     u.readconfig(os.path.join(path, '.hg', 'hgrc'))
   119                     u.readconfig(os.path.join(path, '.hg', 'hgrc'))
   117                 except IOError:
   120                 except IOError:
   118                     pass
   121                     pass
   119                 def get(section, name, default=None):
   122                 def get(section, name, default=None):
   177                     break
   180                     break
   178                 virtual = virtual[:up]
   181                 virtual = virtual[:up]
   179             if real:
   182             if real:
   180                 req.env['REPO_NAME'] = virtual
   183                 req.env['REPO_NAME'] = virtual
   181                 try:
   184                 try:
   182                     hgweb(real).run_wsgi(req)
   185                     repo = hg.repository(parentui, real)
       
   186                     hgweb(repo).run_wsgi(req)
   183                 except IOError, inst:
   187                 except IOError, inst:
   184                     req.write(tmpl("error", error=inst.strerror))
   188                     req.write(tmpl("error", error=inst.strerror))
   185                 except hg.RepoError, inst:
   189                 except hg.RepoError, inst:
   186                     req.write(tmpl("error", error=str(inst)))
   190                     req.write(tmpl("error", error=str(inst)))
   187             else:
   191             else: