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