Show More
@@ -30,7 +30,6 b' from __future__ import absolute_import' | |||
|
30 | 30 | |
|
31 | 31 | from . import highlight |
|
32 | 32 | from mercurial.hgweb import ( |
|
33 | common, | |
|
34 | 33 | webcommands, |
|
35 | 34 | webutil, |
|
36 | 35 | ) |
@@ -84,9 +83,12 b' def annotate_highlight(orig, web, req, t' | |||
|
84 | 83 | def generate_css(web, req, tmpl): |
|
85 | 84 | pg_style = web.config('web', 'pygments_style', 'colorful') |
|
86 | 85 | fmter = highlight.HtmlFormatter(style=pg_style) |
|
87 | req.respond(common.HTTP_OK, 'text/css') | |
|
88 | return ['/* pygments_style = %s */\n\n' % pg_style, | |
|
89 | fmter.get_style_defs('')] | |
|
86 | web.res.headers['Content-Type'] = 'text/css' | |
|
87 | web.res.setbodybytes(''.join([ | |
|
88 | '/* pygments_style = %s */\n\n' % pg_style, | |
|
89 | fmter.get_style_defs(''), | |
|
90 | ])) | |
|
91 | return web.res | |
|
90 | 92 | |
|
91 | 93 | def extsetup(): |
|
92 | 94 | # monkeypatch in the new version |
@@ -400,8 +400,11 b' class hgweb(object):' | |||
|
400 | 400 | msg = 'no such method: %s' % cmd |
|
401 | 401 | raise ErrorResponse(HTTP_BAD_REQUEST, msg) |
|
402 | 402 | elif cmd == 'file' and req.qsparams.get('style') == 'raw': |
|
403 | rctx.ctype = ctype | |
|
403 | res.status = '200 Script output follows' | |
|
404 | res.headers['Content-Type'] = ctype | |
|
404 | 405 | content = webcommands.rawfile(rctx, wsgireq, tmpl) |
|
406 | assert content is res | |
|
407 | return res.sendresponse() | |
|
405 | 408 | else: |
|
406 | 409 | # Set some globals appropriate for web handlers. Commands can |
|
407 | 410 | # override easily enough. |
@@ -106,17 +106,13 b' def rawfile(web, req, tmpl):' | |||
|
106 | 106 | |
|
107 | 107 | path = webutil.cleanpath(web.repo, req.req.qsparams.get('file', '')) |
|
108 | 108 | if not path: |
|
109 |
|
|
|
110 | req.respond(HTTP_OK, web.ctype) | |
|
111 | return content | |
|
109 | return manifest(web, req, tmpl) | |
|
112 | 110 | |
|
113 | 111 | try: |
|
114 | 112 | fctx = webutil.filectx(web.repo, req) |
|
115 | 113 | except error.LookupError as inst: |
|
116 | 114 | try: |
|
117 |
|
|
|
118 | req.respond(HTTP_OK, web.ctype) | |
|
119 | return content | |
|
115 | return manifest(web, req, tmpl) | |
|
120 | 116 | except ErrorResponse: |
|
121 | 117 | raise inst |
|
122 | 118 | |
@@ -133,8 +129,12 b' def rawfile(web, req, tmpl):' | |||
|
133 | 129 | if mt.startswith('text/'): |
|
134 | 130 | mt += '; charset="%s"' % encoding.encoding |
|
135 | 131 | |
|
136 | req.respond(HTTP_OK, mt, path, body=text) | |
|
137 | return [] | |
|
132 | web.res.headers['Content-Type'] = mt | |
|
133 | filename = (path.rpartition('/')[-1] | |
|
134 | .replace('\\', '\\\\').replace('"', '\\"')) | |
|
135 | web.res.headers['Content-Disposition'] = 'inline; filename="%s"' % filename | |
|
136 | web.res.setbodybytes(text) | |
|
137 | return web.res | |
|
138 | 138 | |
|
139 | 139 | def _filerevision(web, req, tmpl, fctx): |
|
140 | 140 | f = fctx.path() |
@@ -153,7 +153,8 b' def _filerevision(web, req, tmpl, fctx):' | |||
|
153 | 153 | "linenumber": "% 6d" % (lineno + 1), |
|
154 | 154 | "parity": next(parity)} |
|
155 | 155 | |
|
156 | return tmpl("filerevision", | |
|
156 | web.res.setbodygen(tmpl( | |
|
157 | 'filerevision', | |
|
157 | 158 |
|
|
158 | 159 |
|
|
159 | 160 |
|
@@ -161,7 +162,9 b' def _filerevision(web, req, tmpl, fctx):' | |||
|
161 | 162 |
|
|
162 | 163 |
|
|
163 | 164 |
|
|
164 |
|
|
|
165 | **pycompat.strkwargs(webutil.commonentry(web.repo, fctx)))) | |
|
166 | ||
|
167 | return web.res | |
|
165 | 168 | |
|
166 | 169 | @webcommand('file') |
|
167 | 170 | def file(web, req, tmpl): |
@@ -335,11 +338,20 b' def _search(web, req, tmpl):' | |||
|
335 | 338 | tip = web.repo['tip'] |
|
336 | 339 | parity = paritygen(web.stripecount) |
|
337 | 340 | |
|
338 | return tmpl('search', query=query, node=tip.hex(), symrev='tip', | |
|
339 | entries=changelist, archives=web.archivelist("tip"), | |
|
340 | morevars=morevars, lessvars=lessvars, | |
|
341 | web.res.setbodygen(tmpl( | |
|
342 | 'search', | |
|
343 | query=query, | |
|
344 | node=tip.hex(), | |
|
345 | symrev='tip', | |
|
346 | entries=changelist, | |
|
347 | archives=web.archivelist('tip'), | |
|
348 | morevars=morevars, | |
|
349 | lessvars=lessvars, | |
|
341 | 350 |
|
|
342 |
|
|
|
351 | showforcekw=showforcekw, | |
|
352 | showunforcekw=showunforcekw)) | |
|
353 | ||
|
354 | return web.res | |
|
343 | 355 | |
|
344 | 356 | @webcommand('changelog') |
|
345 | 357 | def changelog(web, req, tmpl, shortlog=False): |
@@ -423,12 +435,23 b' def changelog(web, req, tmpl, shortlog=F' | |||
|
423 | 435 | else: |
|
424 | 436 | nextentry = [] |
|
425 | 437 | |
|
426 | return tmpl('shortlog' if shortlog else 'changelog', changenav=changenav, | |
|
427 | node=ctx.hex(), rev=pos, symrev=symrev, changesets=count, | |
|
438 | web.res.setbodygen(tmpl( | |
|
439 | 'shortlog' if shortlog else 'changelog', | |
|
440 | changenav=changenav, | |
|
441 | node=ctx.hex(), | |
|
442 | rev=pos, | |
|
443 | symrev=symrev, | |
|
444 | changesets=count, | |
|
428 | 445 |
|
|
429 |
|
|
|
430 | archives=web.archivelist("tip"), revcount=revcount, | |
|
431 | morevars=morevars, lessvars=lessvars, query=query) | |
|
446 | latestentry=latestentry, | |
|
447 | nextentry=nextentry, | |
|
448 | archives=web.archivelist('tip'), | |
|
449 | revcount=revcount, | |
|
450 | morevars=morevars, | |
|
451 | lessvars=lessvars, | |
|
452 | query=query)) | |
|
453 | ||
|
454 | return web.res | |
|
432 | 455 | |
|
433 | 456 | @webcommand('shortlog') |
|
434 | 457 | def shortlog(web, req, tmpl): |
@@ -461,8 +484,9 b' def changeset(web, req, tmpl):' | |||
|
461 | 484 | templates related to diffs may all be used to produce the output. |
|
462 | 485 | """ |
|
463 | 486 | ctx = webutil.changectx(web.repo, req) |
|
464 | ||
|
465 |
|
|
|
487 | web.res.setbodygen(tmpl('changeset', | |
|
488 | **webutil.changesetentry(web, req, tmpl, ctx))) | |
|
489 | return web.res | |
|
466 | 490 | |
|
467 | 491 | rev = webcommand('rev')(changeset) |
|
468 | 492 | |
@@ -563,7 +587,8 b' def manifest(web, req, tmpl):' | |||
|
563 | 587 | "emptydirs": "/".join(emptydirs), |
|
564 | 588 | "basename": d} |
|
565 | 589 | |
|
566 | return tmpl("manifest", | |
|
590 | web.res.setbodygen(tmpl( | |
|
591 | 'manifest', | |
|
567 | 592 |
|
|
568 | 593 |
|
|
569 | 594 |
|
@@ -571,7 +596,9 b' def manifest(web, req, tmpl):' | |||
|
571 | 596 |
|
|
572 | 597 |
|
|
573 | 598 |
|
|
574 |
|
|
|
599 | **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))) | |
|
600 | ||
|
601 | return web.res | |
|
575 | 602 | |
|
576 | 603 | @webcommand('tags') |
|
577 | 604 | def tags(web, req, tmpl): |
@@ -600,11 +627,14 b' def tags(web, req, tmpl):' | |||
|
600 | 627 | "date": web.repo[n].date(), |
|
601 | 628 | "node": hex(n)} |
|
602 | 629 | |
|
603 | return tmpl("tags", | |
|
630 | web.res.setbodygen(tmpl( | |
|
631 | 'tags', | |
|
604 | 632 |
|
|
605 | 633 |
|
|
606 | 634 |
|
|
607 |
|
|
|
635 | latestentry=lambda **x: entries(True, True, **x))) | |
|
636 | ||
|
637 | return web.res | |
|
608 | 638 | |
|
609 | 639 | @webcommand('bookmarks') |
|
610 | 640 | def bookmarks(web, req, tmpl): |
@@ -638,11 +668,14 b' def bookmarks(web, req, tmpl):' | |||
|
638 | 668 | else: |
|
639 | 669 | latestrev = -1 |
|
640 | 670 | |
|
641 | return tmpl("bookmarks", | |
|
671 | web.res.setbodygen(tmpl( | |
|
672 | 'bookmarks', | |
|
642 | 673 |
|
|
643 |
|
|
|
674 | lastchange=[{'date': web.repo[latestrev].date()}], | |
|
644 | 675 |
|
|
645 |
|
|
|
676 | latestentry=lambda **x: entries(latestonly=True, **x))) | |
|
677 | ||
|
678 | return web.res | |
|
646 | 679 | |
|
647 | 680 | @webcommand('branches') |
|
648 | 681 | def branches(web, req, tmpl): |
@@ -660,8 +693,14 b' def branches(web, req, tmpl):' | |||
|
660 | 693 | """ |
|
661 | 694 | entries = webutil.branchentries(web.repo, web.stripecount) |
|
662 | 695 | latestentry = webutil.branchentries(web.repo, web.stripecount, 1) |
|
663 | return tmpl('branches', node=hex(web.repo.changelog.tip()), | |
|
664 | entries=entries, latestentry=latestentry) | |
|
696 | ||
|
697 | web.res.setbodygen(tmpl( | |
|
698 | 'branches', | |
|
699 | node=hex(web.repo.changelog.tip()), | |
|
700 | entries=entries, | |
|
701 | latestentry=latestentry)) | |
|
702 | ||
|
703 | return web.res | |
|
665 | 704 | |
|
666 | 705 | @webcommand('summary') |
|
667 | 706 | def summary(web, req, tmpl): |
@@ -731,9 +770,11 b' def summary(web, req, tmpl):' | |||
|
731 | 770 | desc = web.config("web", "description") |
|
732 | 771 | if not desc: |
|
733 | 772 | desc = 'unknown' |
|
734 | return tmpl("summary", | |
|
773 | ||
|
774 | web.res.setbodygen(tmpl( | |
|
775 | 'summary', | |
|
735 | 776 |
|
|
736 |
|
|
|
777 | owner=get_contact(web.config) or 'unknown', | |
|
737 | 778 |
|
|
738 | 779 |
|
|
739 | 780 |
|
@@ -741,8 +782,10 b' def summary(web, req, tmpl):' | |||
|
741 | 782 |
|
|
742 | 783 |
|
|
743 | 784 |
|
|
744 |
|
|
|
745 |
|
|
|
785 | archives=web.archivelist('tip'), | |
|
786 | labels=web.configlist('web', 'labels'))) | |
|
787 | ||
|
788 | return web.res | |
|
746 | 789 | |
|
747 | 790 | @webcommand('filediff') |
|
748 | 791 | def filediff(web, req, tmpl): |
@@ -782,12 +825,16 b' def filediff(web, req, tmpl):' | |||
|
782 | 825 | else: |
|
783 | 826 | rename = [] |
|
784 | 827 | ctx = ctx |
|
785 | return tmpl("filediff", | |
|
828 | ||
|
829 | web.res.setbodygen(tmpl( | |
|
830 | 'filediff', | |
|
786 | 831 |
|
|
787 | 832 |
|
|
788 | 833 |
|
|
789 | 834 |
|
|
790 |
|
|
|
835 | **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))) | |
|
836 | ||
|
837 | return web.res | |
|
791 | 838 | |
|
792 | 839 | diff = webcommand('diff')(filediff) |
|
793 | 840 | |
@@ -853,7 +900,9 b' def comparison(web, req, tmpl):' | |||
|
853 | 900 | else: |
|
854 | 901 | rename = [] |
|
855 | 902 | ctx = ctx |
|
856 | return tmpl('filecomparison', | |
|
903 | ||
|
904 | web.res.setbodygen(tmpl( | |
|
905 | 'filecomparison', | |
|
857 | 906 |
|
|
858 | 907 |
|
|
859 | 908 |
|
@@ -862,7 +911,9 b' def comparison(web, req, tmpl):' | |||
|
862 | 911 |
|
|
863 | 912 |
|
|
864 | 913 |
|
|
865 |
|
|
|
914 | **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))) | |
|
915 | ||
|
916 | return web.res | |
|
866 | 917 | |
|
867 | 918 | @webcommand('annotate') |
|
868 | 919 | def annotate(web, req, tmpl): |
@@ -944,7 +995,8 b' def annotate(web, req, tmpl):' | |||
|
944 | 995 | diffopts = webutil.difffeatureopts(req, web.repo.ui, 'annotate') |
|
945 | 996 | diffopts = {k: getattr(diffopts, k) for k in diffopts.defaults} |
|
946 | 997 | |
|
947 | return tmpl("fileannotate", | |
|
998 | web.res.setbodygen(tmpl( | |
|
999 | 'fileannotate', | |
|
948 | 1000 |
|
|
949 | 1001 |
|
|
950 | 1002 |
|
@@ -953,7 +1005,9 b' def annotate(web, req, tmpl):' | |||
|
953 | 1005 |
|
|
954 | 1006 |
|
|
955 | 1007 |
|
|
956 |
|
|
|
1008 | **pycompat.strkwargs(webutil.commonentry(web.repo, fctx)))) | |
|
1009 | ||
|
1010 | return web.res | |
|
957 | 1011 | |
|
958 | 1012 | @webcommand('filelog') |
|
959 | 1013 | def filelog(web, req, tmpl): |
@@ -1318,9 +1372,15 b' def graph(web, req, tmpl):' | |||
|
1318 | 1372 | |
|
1319 | 1373 | rows = len(tree) |
|
1320 | 1374 | |
|
1321 | return tmpl('graph', rev=rev, symrev=symrev, revcount=revcount, | |
|
1375 | web.res.setbodygen(tmpl( | |
|
1376 | 'graph', | |
|
1377 | rev=rev, | |
|
1378 | symrev=symrev, | |
|
1379 | revcount=revcount, | |
|
1322 | 1380 |
|
|
1323 | lessvars=lessvars, morevars=morevars, downrev=downrev, | |
|
1381 | lessvars=lessvars, | |
|
1382 | morevars=morevars, | |
|
1383 | downrev=downrev, | |
|
1324 | 1384 |
|
|
1325 | 1385 |
|
|
1326 | 1386 |
|
@@ -1328,7 +1388,10 b' def graph(web, req, tmpl):' | |||
|
1328 | 1388 |
|
|
1329 | 1389 |
|
|
1330 | 1390 |
|
|
1331 |
|
|
|
1391 | node=ctx.hex(), | |
|
1392 | changenav=changenav)) | |
|
1393 | ||
|
1394 | return web.res | |
|
1332 | 1395 | |
|
1333 | 1396 | def _getdoc(e): |
|
1334 | 1397 | doc = e[0].__doc__ |
@@ -1384,8 +1447,13 b' def help(web, req, tmpl):' | |||
|
1384 | 1447 | for c, doc in other: |
|
1385 | 1448 | yield {'topic': c, 'summary': doc} |
|
1386 | 1449 | |
|
1387 | return tmpl('helptopics', topics=topics, earlycommands=earlycommands, | |
|
1388 | othercommands=othercommands, title='Index') | |
|
1450 | web.res.setbodygen(tmpl( | |
|
1451 | 'helptopics', | |
|
1452 | topics=topics, | |
|
1453 | earlycommands=earlycommands, | |
|
1454 | othercommands=othercommands, | |
|
1455 | title='Index')) | |
|
1456 | return web.res | |
|
1389 | 1457 | |
|
1390 | 1458 | # Render an index of sub-topics. |
|
1391 | 1459 | if topicname in helpmod.subtopics: |
@@ -1397,8 +1465,12 b' def help(web, req, tmpl):' | |||
|
1397 | 1465 | 'summary': summary, |
|
1398 | 1466 | }) |
|
1399 | 1467 | |
|
1400 | return tmpl('helptopics', topics=topics, title=topicname, | |
|
1401 | subindex=True) | |
|
1468 | web.res.setbodygen(tmpl( | |
|
1469 | 'helptopics', | |
|
1470 | topics=topics, | |
|
1471 | title=topicname, | |
|
1472 | subindex=True)) | |
|
1473 | return web.res | |
|
1402 | 1474 | |
|
1403 | 1475 | u = webutil.wsgiui.load() |
|
1404 | 1476 | u.verbose = True |
@@ -1418,7 +1490,13 b' def help(web, req, tmpl):' | |||
|
1418 | 1490 | doc = helpmod.help_(u, commands, topic, subtopic=subtopic) |
|
1419 | 1491 | except error.Abort: |
|
1420 | 1492 | raise ErrorResponse(HTTP_NOT_FOUND) |
|
1421 | return tmpl('help', topic=topicname, doc=doc) | |
|
1493 | ||
|
1494 | web.res.setbodygen(tmpl( | |
|
1495 | 'help', | |
|
1496 | topic=topicname, | |
|
1497 | doc=doc)) | |
|
1498 | ||
|
1499 | return web.res | |
|
1422 | 1500 | |
|
1423 | 1501 | # tell hggettext to extract docstrings from these functions: |
|
1424 | 1502 | i18nfunctions = commands.values() |
General Comments 0
You need to be logged in to leave comments.
Login now