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) |
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: |