Show More
@@ -88,7 +88,7 def generate_css(web, req, tmpl): | |||
|
88 | 88 | '/* pygments_style = %s */\n\n' % pg_style, |
|
89 | 89 | fmter.get_style_defs(''), |
|
90 | 90 | ])) |
|
91 | return web.res | |
|
91 | return web.res.sendresponse() | |
|
92 | 92 | |
|
93 | 93 | def extsetup(): |
|
94 | 94 | # monkeypatch in the new version |
@@ -621,13 +621,7 def kwweb_skip(orig, web, req, tmpl): | |||
|
621 | 621 | origmatch = kwt.match |
|
622 | 622 | kwt.match = util.never |
|
623 | 623 | try: |
|
624 |
r |
|
|
625 | if res is web.res: | |
|
626 | res = res.sendresponse() | |
|
627 | elif res is True: | |
|
628 | return | |
|
629 | ||
|
630 | for chunk in res: | |
|
624 | for chunk in orig(web, req, tmpl): | |
|
631 | 625 | yield chunk |
|
632 | 626 | finally: |
|
633 | 627 | if kwt: |
@@ -14,7 +14,6 import os | |||
|
14 | 14 | from .common import ( |
|
15 | 15 | ErrorResponse, |
|
16 | 16 | HTTP_BAD_REQUEST, |
|
17 | HTTP_OK, | |
|
18 | 17 | cspvalues, |
|
19 | 18 | permhooks, |
|
20 | 19 | statusmessage, |
@@ -405,15 +404,7 class hgweb(object): | |||
|
405 | 404 | # override easily enough. |
|
406 | 405 | res.status = '200 Script output follows' |
|
407 | 406 | res.headers['Content-Type'] = ctype |
|
408 |
|
|
|
409 | ||
|
410 | if content is res: | |
|
411 | return res.sendresponse() | |
|
412 | elif content is True: | |
|
413 | return [] | |
|
414 | else: | |
|
415 | wsgireq.respond(HTTP_OK, ctype) | |
|
416 | return content | |
|
407 | return getattr(webcommands, cmd)(rctx, wsgireq, tmpl) | |
|
417 | 408 | |
|
418 | 409 | except (error.LookupError, error.RepoLookupError) as err: |
|
419 | 410 | msg = pycompat.bytestr(err) |
@@ -57,12 +57,9 class webcommand(object): | |||
|
57 | 57 | The functions should populate the ``rctx.res`` object with details |
|
58 | 58 | about the HTTP response. |
|
59 | 59 | |
|
60 | The function can return the ``requestcontext.res`` instance to signal | |
|
61 | that it wants to use this object to generate the response. If an iterable | |
|
62 | is returned, the ``wsgirequest`` instance will be used and the returned | |
|
63 | content will constitute the response body. ``True`` can be returned to | |
|
64 | indicate that the function already sent output and the caller doesn't | |
|
65 | need to do anything more to send the response. | |
|
60 | The function returns a generator to be consumed by the WSGI application. | |
|
61 | For most commands, this should be the result from | |
|
62 | ``web.res.sendresponse()``. | |
|
66 | 63 | |
|
67 | 64 | Usage: |
|
68 | 65 | |
@@ -135,7 +132,7 def rawfile(web, req, tmpl): | |||
|
135 | 132 | .replace('\\', '\\\\').replace('"', '\\"')) |
|
136 | 133 | web.res.headers['Content-Disposition'] = 'inline; filename="%s"' % filename |
|
137 | 134 | web.res.setbodybytes(text) |
|
138 | return web.res | |
|
135 | return web.res.sendresponse() | |
|
139 | 136 | |
|
140 | 137 | def _filerevision(web, req, tmpl, fctx): |
|
141 | 138 | f = fctx.path() |
@@ -165,7 +162,7 def _filerevision(web, req, tmpl, fctx): | |||
|
165 | 162 | ishead=int(ishead), |
|
166 | 163 | **pycompat.strkwargs(webutil.commonentry(web.repo, fctx)))) |
|
167 | 164 | |
|
168 | return web.res | |
|
165 | return web.res.sendresponse() | |
|
169 | 166 | |
|
170 | 167 | @webcommand('file') |
|
171 | 168 | def file(web, req, tmpl): |
@@ -355,7 +352,7 def _search(web, req, tmpl): | |||
|
355 | 352 | showforcekw=showforcekw, |
|
356 | 353 | showunforcekw=showunforcekw)) |
|
357 | 354 | |
|
358 | return web.res | |
|
355 | return web.res.sendresponse() | |
|
359 | 356 | |
|
360 | 357 | @webcommand('changelog') |
|
361 | 358 | def changelog(web, req, tmpl, shortlog=False): |
@@ -455,7 +452,7 def changelog(web, req, tmpl, shortlog=F | |||
|
455 | 452 | lessvars=lessvars, |
|
456 | 453 | query=query)) |
|
457 | 454 | |
|
458 | return web.res | |
|
455 | return web.res.sendresponse() | |
|
459 | 456 | |
|
460 | 457 | @webcommand('shortlog') |
|
461 | 458 | def shortlog(web, req, tmpl): |
@@ -490,7 +487,7 def changeset(web, req, tmpl): | |||
|
490 | 487 | ctx = webutil.changectx(web.repo, req) |
|
491 | 488 | web.res.setbodygen(tmpl('changeset', |
|
492 | 489 | **webutil.changesetentry(web, req, tmpl, ctx))) |
|
493 | return web.res | |
|
490 | return web.res.sendresponse() | |
|
494 | 491 | |
|
495 | 492 | rev = webcommand('rev')(changeset) |
|
496 | 493 | |
@@ -602,7 +599,7 def manifest(web, req, tmpl): | |||
|
602 | 599 | archives=web.archivelist(hex(node)), |
|
603 | 600 | **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))) |
|
604 | 601 | |
|
605 | return web.res | |
|
602 | return web.res.sendresponse() | |
|
606 | 603 | |
|
607 | 604 | @webcommand('tags') |
|
608 | 605 | def tags(web, req, tmpl): |
@@ -638,7 +635,7 def tags(web, req, tmpl): | |||
|
638 | 635 | entriesnotip=lambda **x: entries(True, False, **x), |
|
639 | 636 | latestentry=lambda **x: entries(True, True, **x))) |
|
640 | 637 | |
|
641 | return web.res | |
|
638 | return web.res.sendresponse() | |
|
642 | 639 | |
|
643 | 640 | @webcommand('bookmarks') |
|
644 | 641 | def bookmarks(web, req, tmpl): |
@@ -679,7 +676,7 def bookmarks(web, req, tmpl): | |||
|
679 | 676 | entries=lambda **x: entries(latestonly=False, **x), |
|
680 | 677 | latestentry=lambda **x: entries(latestonly=True, **x))) |
|
681 | 678 | |
|
682 | return web.res | |
|
679 | return web.res.sendresponse() | |
|
683 | 680 | |
|
684 | 681 | @webcommand('branches') |
|
685 | 682 | def branches(web, req, tmpl): |
@@ -704,7 +701,7 def branches(web, req, tmpl): | |||
|
704 | 701 | entries=entries, |
|
705 | 702 | latestentry=latestentry)) |
|
706 | 703 | |
|
707 | return web.res | |
|
704 | return web.res.sendresponse() | |
|
708 | 705 | |
|
709 | 706 | @webcommand('summary') |
|
710 | 707 | def summary(web, req, tmpl): |
@@ -789,7 +786,7 def summary(web, req, tmpl): | |||
|
789 | 786 | archives=web.archivelist('tip'), |
|
790 | 787 | labels=web.configlist('web', 'labels'))) |
|
791 | 788 | |
|
792 | return web.res | |
|
789 | return web.res.sendresponse() | |
|
793 | 790 | |
|
794 | 791 | @webcommand('filediff') |
|
795 | 792 | def filediff(web, req, tmpl): |
@@ -838,7 +835,7 def filediff(web, req, tmpl): | |||
|
838 | 835 | diff=diffs, |
|
839 | 836 | **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))) |
|
840 | 837 | |
|
841 | return web.res | |
|
838 | return web.res.sendresponse() | |
|
842 | 839 | |
|
843 | 840 | diff = webcommand('diff')(filediff) |
|
844 | 841 | |
@@ -917,7 +914,7 def comparison(web, req, tmpl): | |||
|
917 | 914 | comparison=comparison, |
|
918 | 915 | **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))) |
|
919 | 916 | |
|
920 | return web.res | |
|
917 | return web.res.sendresponse() | |
|
921 | 918 | |
|
922 | 919 | @webcommand('annotate') |
|
923 | 920 | def annotate(web, req, tmpl): |
@@ -1011,7 +1008,7 def annotate(web, req, tmpl): | |||
|
1011 | 1008 | diffopts=diffopts, |
|
1012 | 1009 | **pycompat.strkwargs(webutil.commonentry(web.repo, fctx)))) |
|
1013 | 1010 | |
|
1014 | return web.res | |
|
1011 | return web.res.sendresponse() | |
|
1015 | 1012 | |
|
1016 | 1013 | @webcommand('filelog') |
|
1017 | 1014 | def filelog(web, req, tmpl): |
@@ -1151,7 +1148,7 def filelog(web, req, tmpl): | |||
|
1151 | 1148 | lessvars=lessvars, |
|
1152 | 1149 | **pycompat.strkwargs(webutil.commonentry(web.repo, fctx)))) |
|
1153 | 1150 | |
|
1154 | return web.res | |
|
1151 | return web.res.sendresponse() | |
|
1155 | 1152 | |
|
1156 | 1153 | @webcommand('archive') |
|
1157 | 1154 | def archive(web, req, tmpl): |
@@ -1225,7 +1222,7 def archive(web, req, tmpl): | |||
|
1225 | 1222 | matchfn=match, |
|
1226 | 1223 | subrepos=web.configbool("web", "archivesubrepos")) |
|
1227 | 1224 | |
|
1228 |
return |
|
|
1225 | return [] | |
|
1229 | 1226 | |
|
1230 | 1227 | @webcommand('static') |
|
1231 | 1228 | def static(web, req, tmpl): |
@@ -1240,7 +1237,7 def static(web, req, tmpl): | |||
|
1240 | 1237 | static = [os.path.join(p, 'static') for p in tp] |
|
1241 | 1238 | |
|
1242 | 1239 | staticfile(static, fname, web.res) |
|
1243 | return web.res | |
|
1240 | return web.res.sendresponse() | |
|
1244 | 1241 | |
|
1245 | 1242 | @webcommand('graph') |
|
1246 | 1243 | def graph(web, req, tmpl): |
@@ -1401,7 +1398,7 def graph(web, req, tmpl): | |||
|
1401 | 1398 | node=ctx.hex(), |
|
1402 | 1399 | changenav=changenav)) |
|
1403 | 1400 | |
|
1404 | return web.res | |
|
1401 | return web.res.sendresponse() | |
|
1405 | 1402 | |
|
1406 | 1403 | def _getdoc(e): |
|
1407 | 1404 | doc = e[0].__doc__ |
@@ -1463,7 +1460,7 def help(web, req, tmpl): | |||
|
1463 | 1460 | earlycommands=earlycommands, |
|
1464 | 1461 | othercommands=othercommands, |
|
1465 | 1462 | title='Index')) |
|
1466 | return web.res | |
|
1463 | return web.res.sendresponse() | |
|
1467 | 1464 | |
|
1468 | 1465 | # Render an index of sub-topics. |
|
1469 | 1466 | if topicname in helpmod.subtopics: |
@@ -1480,7 +1477,7 def help(web, req, tmpl): | |||
|
1480 | 1477 | topics=topics, |
|
1481 | 1478 | title=topicname, |
|
1482 | 1479 | subindex=True)) |
|
1483 | return web.res | |
|
1480 | return web.res.sendresponse() | |
|
1484 | 1481 | |
|
1485 | 1482 | u = webutil.wsgiui.load() |
|
1486 | 1483 | u.verbose = True |
@@ -1506,7 +1503,7 def help(web, req, tmpl): | |||
|
1506 | 1503 | topic=topicname, |
|
1507 | 1504 | doc=doc)) |
|
1508 | 1505 | |
|
1509 | return web.res | |
|
1506 | return web.res.sendresponse() | |
|
1510 | 1507 | |
|
1511 | 1508 | # tell hggettext to extract docstrings from these functions: |
|
1512 | 1509 | i18nfunctions = commands.values() |
General Comments 0
You need to be logged in to leave comments.
Login now