Show More
@@ -765,7 +765,11 b' def debugsetparents(ui, repo, rev1, rev2' | |||||
765 | if not rev2: |
|
765 | if not rev2: | |
766 | rev2 = hex(nullid) |
|
766 | rev2 = hex(nullid) | |
767 |
|
767 | |||
768 | repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2)) |
|
768 | wlock = repo.wlock() | |
|
769 | try: | |||
|
770 | repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2)) | |||
|
771 | finally: | |||
|
772 | wlock.release() | |||
769 |
|
773 | |||
770 | def debugstate(ui, repo): |
|
774 | def debugstate(ui, repo): | |
771 | """show the contents of the current dirstate""" |
|
775 | """show the contents of the current dirstate""" |
@@ -797,19 +797,22 b' class hgweb(object):' | |||||
797 | "sessionvars": sessionvars |
|
797 | "sessionvars": sessionvars | |
798 | }) |
|
798 | }) | |
799 |
|
799 | |||
800 | if not req.form.has_key('cmd'): |
|
800 | try: | |
801 | req.form['cmd'] = [self.t.cache['default']] |
|
801 | if not req.form.has_key('cmd'): | |
|
802 | req.form['cmd'] = [self.t.cache['default']] | |||
802 |
|
803 | |||
803 | cmd = req.form['cmd'][0] |
|
804 | cmd = req.form['cmd'][0] | |
804 |
|
805 | |||
805 | method = getattr(self, 'do_' + cmd, None) |
|
806 | method = getattr(self, 'do_' + cmd, None) | |
806 | if method: |
|
807 | if method: | |
807 | try: |
|
808 | try: | |
808 | method(req) |
|
809 | method(req) | |
809 | except (hg.RepoError, revlog.RevlogError), inst: |
|
810 | except (hg.RepoError, revlog.RevlogError), inst: | |
810 | req.write(self.t("error", error=str(inst))) |
|
811 | req.write(self.t("error", error=str(inst))) | |
811 | else: |
|
812 | else: | |
812 | req.write(self.t("error", error='No such method: ' + cmd)) |
|
813 | req.write(self.t("error", error='No such method: ' + cmd)) | |
|
814 | finally: | |||
|
815 | self.t = None | |||
813 |
|
816 | |||
814 | def changectx(self, req): |
|
817 | def changectx(self, req): | |
815 | if req.form.has_key('node'): |
|
818 | if req.form.has_key('node'): |
@@ -179,53 +179,56 b' class hgwebdir(object):' | |||||
179 | parity = 1 - parity |
|
179 | parity = 1 - parity | |
180 | yield row |
|
180 | yield row | |
181 |
|
181 | |||
182 | virtual = req.env.get("PATH_INFO", "").strip('/') |
|
182 | try: | |
183 | if virtual.startswith('static/'): |
|
183 | virtual = req.env.get("PATH_INFO", "").strip('/') | |
184 | static = os.path.join(templater.templatepath(), 'static') |
|
184 | if virtual.startswith('static/'): | |
185 | fname = virtual[7:] |
|
185 | static = os.path.join(templater.templatepath(), 'static') | |
186 | req.write(staticfile(static, fname, req) or |
|
186 | fname = virtual[7:] | |
187 | tmpl('error', error='%r not found' % fname)) |
|
187 | req.write(staticfile(static, fname, req) or | |
188 | elif virtual: |
|
188 | tmpl('error', error='%r not found' % fname)) | |
189 |
|
|
189 | elif virtual: | |
190 |
|
|
190 | while virtual: | |
|
191 | real = dict(self.repos).get(virtual) | |||
|
192 | if real: | |||
|
193 | break | |||
|
194 | up = virtual.rfind('/') | |||
|
195 | if up < 0: | |||
|
196 | break | |||
|
197 | virtual = virtual[:up] | |||
191 | if real: |
|
198 | if real: | |
192 |
|
|
199 | req.env['REPO_NAME'] = virtual | |
193 |
|
|
200 | try: | |
194 | if up < 0: |
|
201 | repo = hg.repository(parentui, real) | |
195 |
|
|
202 | hgweb(repo).run_wsgi(req) | |
196 | virtual = virtual[:up] |
|
203 | except IOError, inst: | |
197 | if real: |
|
204 | req.write(tmpl("error", error=inst.strerror)) | |
198 | req.env['REPO_NAME'] = virtual |
|
205 | except hg.RepoError, inst: | |
199 | try: |
|
206 | req.write(tmpl("error", error=str(inst))) | |
200 | repo = hg.repository(parentui, real) |
|
207 | else: | |
201 | hgweb(repo).run_wsgi(req) |
|
208 | req.write(tmpl("notfound", repo=virtual)) | |
202 | except IOError, inst: |
|
|||
203 | req.write(tmpl("error", error=inst.strerror)) |
|
|||
204 | except hg.RepoError, inst: |
|
|||
205 | req.write(tmpl("error", error=str(inst))) |
|
|||
206 | else: |
|
209 | else: | |
207 | req.write(tmpl("notfound", repo=virtual)) |
|
210 | if req.form.has_key('static'): | |
208 | else: |
|
211 | static = os.path.join(templater.templatepath(), "static") | |
209 |
|
|
212 | fname = req.form['static'][0] | |
210 | static = os.path.join(templater.templatepath(), "static") |
|
213 | req.write(staticfile(static, fname, req) | |
211 | fname = req.form['static'][0] |
|
214 | or tmpl("error", error="%r not found" % fname)) | |
212 | req.write(staticfile(static, fname, req) |
|
215 | else: | |
213 | or tmpl("error", error="%r not found" % fname)) |
|
216 | sortable = ["name", "description", "contact", "lastchange"] | |
214 | else: |
|
217 | sortcolumn, descending = self.repos_sorted | |
215 | sortable = ["name", "description", "contact", "lastchange"] |
|
218 | if req.form.has_key('sort'): | |
216 |
sortcolumn |
|
219 | sortcolumn = req.form['sort'][0] | |
217 | if req.form.has_key('sort'): |
|
220 | descending = sortcolumn.startswith('-') | |
218 | sortcolumn = req.form['sort'][0] |
|
221 | if descending: | |
219 |
|
|
222 | sortcolumn = sortcolumn[1:] | |
220 |
if |
|
223 | if sortcolumn not in sortable: | |
221 |
sortcolumn = |
|
224 | sortcolumn = "" | |
222 | if sortcolumn not in sortable: |
|
|||
223 | sortcolumn = "" |
|
|||
224 |
|
225 | |||
225 | sort = [("sort_%s" % column, |
|
226 | sort = [("sort_%s" % column, | |
226 | "%s%s" % ((not descending and column == sortcolumn) |
|
227 | "%s%s" % ((not descending and column == sortcolumn) | |
227 | and "-" or "", column)) |
|
228 | and "-" or "", column)) | |
228 | for column in sortable] |
|
229 | for column in sortable] | |
229 | req.write(tmpl("index", entries=entries, |
|
230 | req.write(tmpl("index", entries=entries, | |
230 | sortcolumn=sortcolumn, descending=descending, |
|
231 | sortcolumn=sortcolumn, descending=descending, | |
231 | **dict(sort))) |
|
232 | **dict(sort))) | |
|
233 | finally: | |||
|
234 | tmpl = None |
@@ -16,20 +16,6 b' class wsgiapplication(object):' | |||||
16 | def __call__(self, wsgienv, start_response): |
|
16 | def __call__(self, wsgienv, start_response): | |
17 | return _wsgirequest(self.destmaker(), wsgienv, start_response) |
|
17 | return _wsgirequest(self.destmaker(), wsgienv, start_response) | |
18 |
|
18 | |||
19 | class _wsgioutputfile(object): |
|
|||
20 | def __init__(self, request): |
|
|||
21 | self.request = request |
|
|||
22 |
|
||||
23 | def write(self, data): |
|
|||
24 | self.request.write(data) |
|
|||
25 | def writelines(self, lines): |
|
|||
26 | for line in lines: |
|
|||
27 | self.write(line) |
|
|||
28 | def flush(self): |
|
|||
29 | return None |
|
|||
30 | def close(self): |
|
|||
31 | return None |
|
|||
32 |
|
||||
33 | class _wsgirequest(object): |
|
19 | class _wsgirequest(object): | |
34 | def __init__(self, destination, wsgienv, start_response): |
|
20 | def __init__(self, destination, wsgienv, start_response): | |
35 | version = wsgienv['wsgi.version'] |
|
21 | version = wsgienv['wsgi.version'] | |
@@ -37,7 +23,6 b' class _wsgirequest(object):' | |||||
37 | raise RuntimeError("Unknown and unsupported WSGI version %d.%d" \ |
|
23 | raise RuntimeError("Unknown and unsupported WSGI version %d.%d" \ | |
38 | % version) |
|
24 | % version) | |
39 | self.inp = wsgienv['wsgi.input'] |
|
25 | self.inp = wsgienv['wsgi.input'] | |
40 | self.out = _wsgioutputfile(self) |
|
|||
41 | self.server_write = None |
|
26 | self.server_write = None | |
42 | self.err = wsgienv['wsgi.errors'] |
|
27 | self.err = wsgienv['wsgi.errors'] | |
43 | self.threaded = wsgienv['wsgi.multithread'] |
|
28 | self.threaded = wsgienv['wsgi.multithread'] | |
@@ -49,6 +34,8 b' class _wsgirequest(object):' | |||||
49 | self.headers = [] |
|
34 | self.headers = [] | |
50 | destination.run_wsgi(self) |
|
35 | destination.run_wsgi(self) | |
51 |
|
36 | |||
|
37 | out = property(lambda self: self) | |||
|
38 | ||||
52 | def __iter__(self): |
|
39 | def __iter__(self): | |
53 | return iter([]) |
|
40 | return iter([]) | |
54 |
|
41 | |||
@@ -75,6 +62,16 b' class _wsgirequest(object):' | |||||
75 | if inst[0] != errno.ECONNRESET: |
|
62 | if inst[0] != errno.ECONNRESET: | |
76 | raise |
|
63 | raise | |
77 |
|
64 | |||
|
65 | def writelines(self, lines): | |||
|
66 | for line in lines: | |||
|
67 | self.write(line) | |||
|
68 | ||||
|
69 | def flush(self): | |||
|
70 | return None | |||
|
71 | ||||
|
72 | def close(self): | |||
|
73 | return None | |||
|
74 | ||||
78 | def header(self, headers=[('Content-type','text/html')]): |
|
75 | def header(self, headers=[('Content-type','text/html')]): | |
79 | self.headers.extend(headers) |
|
76 | self.headers.extend(headers) | |
80 |
|
77 |
@@ -206,12 +206,17 b' def create_server(ui, repo):' | |||||
206 | BaseHTTPServer.HTTPServer.__init__(self, *args, **kargs) |
|
206 | BaseHTTPServer.HTTPServer.__init__(self, *args, **kargs) | |
207 | self.accesslog = accesslog |
|
207 | self.accesslog = accesslog | |
208 | self.errorlog = errorlog |
|
208 | self.errorlog = errorlog | |
209 | self.repo = repo |
|
|||
210 | self.webdir_conf = webdir_conf |
|
|||
211 | self.webdirmaker = hgwebdir |
|
|||
212 | self.repoviewmaker = hgweb |
|
|||
213 | self.reqmaker = wsgiapplication(self.make_handler) |
|
|||
214 | self.daemon_threads = True |
|
209 | self.daemon_threads = True | |
|
210 | def make_handler(): | |||
|
211 | if webdir_conf: | |||
|
212 | hgwebobj = hgwebdir(webdir_conf, ui) | |||
|
213 | elif repo is not None: | |||
|
214 | hgwebobj = hgweb(hg.repository(repo.ui, repo.root)) | |||
|
215 | else: | |||
|
216 | raise hg.RepoError(_("There is no Mercurial repository here" | |||
|
217 | " (.hg not found)")) | |||
|
218 | return hgwebobj | |||
|
219 | self.reqmaker = wsgiapplication(make_handler) | |||
215 |
|
220 | |||
216 | addr, port = self.socket.getsockname()[:2] |
|
221 | addr, port = self.socket.getsockname()[:2] | |
217 | if addr in ('0.0.0.0', '::'): |
|
222 | if addr in ('0.0.0.0', '::'): | |
@@ -223,17 +228,6 b' def create_server(ui, repo):' | |||||
223 | pass |
|
228 | pass | |
224 | self.addr, self.port = addr, port |
|
229 | self.addr, self.port = addr, port | |
225 |
|
230 | |||
226 | def make_handler(self): |
|
|||
227 | if self.webdir_conf: |
|
|||
228 | hgwebobj = self.webdirmaker(self.webdir_conf, ui) |
|
|||
229 | elif self.repo is not None: |
|
|||
230 | hgwebobj = self.repoviewmaker(hg.repository(repo.ui, |
|
|||
231 | repo.root)) |
|
|||
232 | else: |
|
|||
233 | raise hg.RepoError(_("There is no Mercurial repository here" |
|
|||
234 | " (.hg not found)")) |
|
|||
235 | return hgwebobj |
|
|||
236 |
|
||||
237 | class IPv6HTTPServer(MercurialHTTPServer): |
|
231 | class IPv6HTTPServer(MercurialHTTPServer): | |
238 | address_family = getattr(socket, 'AF_INET6', None) |
|
232 | address_family = getattr(socket, 'AF_INET6', None) | |
239 |
|
233 |
General Comments 0
You need to be logged in to leave comments.
Login now