Show More
@@ -176,71 +176,70 b' class hgwebdir(object):' | |||||
176 |
|
176 | |||
177 | def run_wsgi(self, req): |
|
177 | def run_wsgi(self, req): | |
178 | try: |
|
178 | try: | |
179 |
|
|
179 | self.refresh() | |
180 | self.refresh() |
|
|||
181 |
|
180 | |||
182 |
|
|
181 | virtual = req.env.get("PATH_INFO", "").strip('/') | |
183 |
|
|
182 | tmpl = self.templater(req) | |
184 |
|
|
183 | ctype = tmpl('mimetype', encoding=encoding.encoding) | |
185 |
|
|
184 | ctype = templater.stringify(ctype) | |
186 |
|
185 | |||
187 |
|
|
186 | # a static file | |
188 |
|
|
187 | if virtual.startswith('static/') or 'static' in req.form: | |
189 |
|
|
188 | if virtual.startswith('static/'): | |
190 |
|
|
189 | fname = virtual[7:] | |
191 |
|
|
190 | else: | |
192 |
|
|
191 | fname = req.form['static'][0] | |
193 |
|
|
192 | static = self.ui.config("web", "static", None, | |
194 |
|
|
193 | untrusted=False) | |
195 |
|
|
194 | if not static: | |
196 |
|
|
195 | tp = self.templatepath or templater.templatepaths() | |
197 |
|
|
196 | if isinstance(tp, str): | |
198 |
|
|
197 | tp = [tp] | |
199 |
|
|
198 | static = [os.path.join(p, 'static') for p in tp] | |
200 |
|
|
199 | staticfile(static, fname, req) | |
201 |
|
|
200 | return [] | |
202 |
|
201 | |||
203 |
|
|
202 | # top-level index | |
204 |
|
|
203 | elif not virtual: | |
205 |
|
|
204 | req.respond(HTTP_OK, ctype) | |
206 |
|
|
205 | return self.makeindex(req, tmpl) | |
207 |
|
206 | |||
208 |
|
|
207 | # nested indexes and hgwebs | |
209 |
|
208 | |||
210 |
|
|
209 | repos = dict(self.repos) | |
211 |
|
|
210 | virtualrepo = virtual | |
212 |
|
|
211 | while virtualrepo: | |
213 |
|
|
212 | real = repos.get(virtualrepo) | |
214 |
|
|
213 | if real: | |
215 |
|
|
214 | req.env['REPO_NAME'] = virtualrepo | |
216 |
|
|
215 | try: | |
217 |
|
|
216 | # ensure caller gets private copy of ui | |
218 |
|
|
217 | repo = hg.repository(self.ui.copy(), real) | |
219 |
|
|
218 | return hgweb(repo).run_wsgi(req) | |
220 |
|
|
219 | except IOError, inst: | |
221 |
|
|
220 | msg = inst.strerror | |
222 |
|
|
221 | raise ErrorResponse(HTTP_SERVER_ERROR, msg) | |
223 |
|
|
222 | except error.RepoError, inst: | |
224 |
|
|
223 | raise ErrorResponse(HTTP_SERVER_ERROR, str(inst)) | |
225 |
|
224 | |||
226 |
|
|
225 | up = virtualrepo.rfind('/') | |
227 |
|
|
226 | if up < 0: | |
228 |
|
|
227 | break | |
229 |
|
|
228 | virtualrepo = virtualrepo[:up] | |
230 |
|
229 | |||
231 |
|
|
230 | # browse subdirectories | |
232 |
|
|
231 | subdir = virtual + '/' | |
233 |
|
|
232 | if [r for r in repos if r.startswith(subdir)]: | |
234 |
|
|
233 | req.respond(HTTP_OK, ctype) | |
235 |
|
|
234 | return self.makeindex(req, tmpl, subdir) | |
236 |
|
235 | |||
237 |
|
|
236 | # prefixes not found | |
238 |
|
|
237 | req.respond(HTTP_NOT_FOUND, ctype) | |
239 |
|
|
238 | return tmpl("notfound", repo=virtual) | |
240 |
|
239 | |||
241 |
|
|
240 | except ErrorResponse, err: | |
242 |
|
|
241 | req.respond(err, ctype) | |
243 |
|
|
242 | return tmpl('error', error=err.message or '') | |
244 | finally: |
|
243 | finally: | |
245 | tmpl = None |
|
244 | tmpl = None | |
246 |
|
245 |
General Comments 0
You need to be logged in to leave comments.
Login now