Show More
@@ -17,6 +17,7 b'' | |||
|
17 | 17 | |
|
18 | 18 | import os |
|
19 | 19 | import logging |
|
20 | import itertools | |
|
20 | 21 | |
|
21 | 22 | import mercurial |
|
22 | 23 | import mercurial.error |
@@ -67,8 +68,27 b' class HgWeb(mercurial.hgweb.hgweb_mod.hg' | |||
|
67 | 68 | """Unused function so raise an exception if accidentally called.""" |
|
68 | 69 | raise NotImplementedError |
|
69 | 70 | |
|
70 | def run_wsgi(self, req): | |
|
71 | """Check the request has a valid command, failing fast otherwise.""" | |
|
71 | def __call__(self, environ, start_response): | |
|
72 | """Run the WSGI application. | |
|
73 | ||
|
74 | This may be called by multiple threads. | |
|
75 | """ | |
|
76 | req = mercurial.hgweb.request.wsgirequest(environ, start_response) | |
|
77 | gen = self.run_wsgi(req) | |
|
78 | ||
|
79 | first_chunk = None | |
|
80 | ||
|
81 | try: | |
|
82 | data = gen.next() | |
|
83 | def first_chunk(): yield data | |
|
84 | except StopIteration: | |
|
85 | pass | |
|
86 | ||
|
87 | if first_chunk: | |
|
88 | return itertools.chain(first_chunk(), gen) | |
|
89 | return gen | |
|
90 | ||
|
91 | def _runwsgi(self, req, repo): | |
|
72 | 92 | cmd = req.form.get('cmd', [''])[0] |
|
73 | 93 | if not mercurial.hgweb.protocol.iscmd(cmd): |
|
74 | 94 | req.respond( |
@@ -78,7 +98,7 b' class HgWeb(mercurial.hgweb.hgweb_mod.hg' | |||
|
78 | 98 | ) |
|
79 | 99 | return [''] |
|
80 | 100 | |
|
81 |
return super(HgWeb, self).run |
|
|
101 | return super(HgWeb, self)._runwsgi(req, repo) | |
|
82 | 102 | |
|
83 | 103 | |
|
84 | 104 | def make_hg_ui_from_config(repo_config): |
General Comments 0
You need to be logged in to leave comments.
Login now