Show More
@@ -58,7 +58,7 b' def pygmentize(web, field, fctx, tmpl):' | |||||
58 | highlight.pygmentize(field, fctx, style, tmpl, |
|
58 | highlight.pygmentize(field, fctx, style, tmpl, | |
59 | guessfilenameonly=filenameonly) |
|
59 | guessfilenameonly=filenameonly) | |
60 |
|
60 | |||
61 |
def filerevision_highlight(orig, web, |
|
61 | def filerevision_highlight(orig, web, fctx): | |
62 | mt = ''.join(web.tmpl('mimetype', encoding=encoding.encoding)) |
|
62 | mt = ''.join(web.tmpl('mimetype', encoding=encoding.encoding)) | |
63 | # only pygmentize for mimetype containing 'html' so we both match |
|
63 | # only pygmentize for mimetype containing 'html' so we both match | |
64 | # 'text/html' and possibly 'application/xhtml+xml' in the future |
|
64 | # 'text/html' and possibly 'application/xhtml+xml' in the future | |
@@ -70,17 +70,17 b' def filerevision_highlight(orig, web, re' | |||||
70 | if 'html' in mt: |
|
70 | if 'html' in mt: | |
71 | pygmentize(web, 'fileline', fctx, web.tmpl) |
|
71 | pygmentize(web, 'fileline', fctx, web.tmpl) | |
72 |
|
72 | |||
73 |
return orig(web, |
|
73 | return orig(web, fctx) | |
74 |
|
74 | |||
75 |
def annotate_highlight(orig, web |
|
75 | def annotate_highlight(orig, web): | |
76 | mt = ''.join(web.tmpl('mimetype', encoding=encoding.encoding)) |
|
76 | mt = ''.join(web.tmpl('mimetype', encoding=encoding.encoding)) | |
77 | if 'html' in mt: |
|
77 | if 'html' in mt: | |
78 | fctx = webutil.filectx(web.repo, web.req) |
|
78 | fctx = webutil.filectx(web.repo, web.req) | |
79 | pygmentize(web, 'annotateline', fctx, web.tmpl) |
|
79 | pygmentize(web, 'annotateline', fctx, web.tmpl) | |
80 |
|
80 | |||
81 |
return orig(web |
|
81 | return orig(web) | |
82 |
|
82 | |||
83 |
def generate_css(web |
|
83 | def generate_css(web): | |
84 | pg_style = web.config('web', 'pygments_style', 'colorful') |
|
84 | pg_style = web.config('web', 'pygments_style', 'colorful') | |
85 | fmter = highlight.HtmlFormatter(style=pg_style) |
|
85 | fmter = highlight.HtmlFormatter(style=pg_style) | |
86 | web.res.headers['Content-Type'] = 'text/css' |
|
86 | web.res.headers['Content-Type'] = 'text/css' |
@@ -614,14 +614,14 b' def kwdiff(orig, repo, *args, **kwargs):' | |||||
614 | if kwt: |
|
614 | if kwt: | |
615 | kwt.restrict = restrict |
|
615 | kwt.restrict = restrict | |
616 |
|
616 | |||
617 |
def kwweb_skip(orig, web |
|
617 | def kwweb_skip(orig, web): | |
618 | '''Wraps webcommands.x turning off keyword expansion.''' |
|
618 | '''Wraps webcommands.x turning off keyword expansion.''' | |
619 | kwt = getattr(web.repo, '_keywordkwt', None) |
|
619 | kwt = getattr(web.repo, '_keywordkwt', None) | |
620 | if kwt: |
|
620 | if kwt: | |
621 | origmatch = kwt.match |
|
621 | origmatch = kwt.match | |
622 | kwt.match = util.never |
|
622 | kwt.match = util.never | |
623 | try: |
|
623 | try: | |
624 |
for chunk in orig(web |
|
624 | for chunk in orig(web): | |
625 | yield chunk |
|
625 | yield chunk | |
626 | finally: |
|
626 | finally: | |
627 | if kwt: |
|
627 | if kwt: |
@@ -932,11 +932,11 b' def overridearchivecmd(orig, ui, repo, d' | |||||
932 | finally: |
|
932 | finally: | |
933 | repo.unfiltered().lfstatus = False |
|
933 | repo.unfiltered().lfstatus = False | |
934 |
|
934 | |||
935 |
def hgwebarchive(orig, web |
|
935 | def hgwebarchive(orig, web): | |
936 | web.repo.lfstatus = True |
|
936 | web.repo.lfstatus = True | |
937 |
|
937 | |||
938 | try: |
|
938 | try: | |
939 |
return orig(web |
|
939 | return orig(web) | |
940 | finally: |
|
940 | finally: | |
941 | web.repo.lfstatus = False |
|
941 | web.repo.lfstatus = False | |
942 |
|
942 |
@@ -404,7 +404,7 b' class hgweb(object):' | |||||
404 | # override easily enough. |
|
404 | # override easily enough. | |
405 | res.status = '200 Script output follows' |
|
405 | res.status = '200 Script output follows' | |
406 | res.headers['Content-Type'] = ctype |
|
406 | res.headers['Content-Type'] = ctype | |
407 |
return getattr(webcommands, cmd)(rctx |
|
407 | return getattr(webcommands, cmd)(rctx) | |
408 |
|
408 | |||
409 | except (error.LookupError, error.RepoLookupError) as err: |
|
409 | except (error.LookupError, error.RepoLookupError) as err: | |
410 | msg = pycompat.bytestr(err) |
|
410 | msg = pycompat.bytestr(err) |
@@ -65,7 +65,7 b' class webcommand(object):' | |||||
65 | Usage: |
|
65 | Usage: | |
66 |
|
66 | |||
67 | @webcommand('mycommand') |
|
67 | @webcommand('mycommand') | |
68 |
def mycommand(web |
|
68 | def mycommand(web): | |
69 | pass |
|
69 | pass | |
70 | """ |
|
70 | """ | |
71 |
|
71 | |||
@@ -78,7 +78,7 b' class webcommand(object):' | |||||
78 | return func |
|
78 | return func | |
79 |
|
79 | |||
80 | @webcommand('log') |
|
80 | @webcommand('log') | |
81 |
def log(web |
|
81 | def log(web): | |
82 | """ |
|
82 | """ | |
83 | /log[/{revision}[/{path}]] |
|
83 | /log[/{revision}[/{path}]] | |
84 | -------------------------- |
|
84 | -------------------------- | |
@@ -95,23 +95,23 b' def log(web, req, tmpl):' | |||||
95 | """ |
|
95 | """ | |
96 |
|
96 | |||
97 | if web.req.qsparams.get('file'): |
|
97 | if web.req.qsparams.get('file'): | |
98 |
return filelog(web |
|
98 | return filelog(web) | |
99 | else: |
|
99 | else: | |
100 |
return changelog(web |
|
100 | return changelog(web) | |
101 |
|
101 | |||
102 | @webcommand('rawfile') |
|
102 | @webcommand('rawfile') | |
103 |
def rawfile(web |
|
103 | def rawfile(web): | |
104 | guessmime = web.configbool('web', 'guessmime') |
|
104 | guessmime = web.configbool('web', 'guessmime') | |
105 |
|
105 | |||
106 | path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', '')) |
|
106 | path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', '')) | |
107 | if not path: |
|
107 | if not path: | |
108 |
return manifest(web |
|
108 | return manifest(web) | |
109 |
|
109 | |||
110 | try: |
|
110 | try: | |
111 | fctx = webutil.filectx(web.repo, web.req) |
|
111 | fctx = webutil.filectx(web.repo, web.req) | |
112 | except error.LookupError as inst: |
|
112 | except error.LookupError as inst: | |
113 | try: |
|
113 | try: | |
114 |
return manifest(web |
|
114 | return manifest(web) | |
115 | except ErrorResponse: |
|
115 | except ErrorResponse: | |
116 | raise inst |
|
116 | raise inst | |
117 |
|
117 | |||
@@ -135,7 +135,7 b' def rawfile(web, req, tmpl):' | |||||
135 | web.res.setbodybytes(text) |
|
135 | web.res.setbodybytes(text) | |
136 | return web.res.sendresponse() |
|
136 | return web.res.sendresponse() | |
137 |
|
137 | |||
138 |
def _filerevision(web, |
|
138 | def _filerevision(web, fctx): | |
139 | f = fctx.path() |
|
139 | f = fctx.path() | |
140 | text = fctx.data() |
|
140 | text = fctx.data() | |
141 | parity = paritygen(web.stripecount) |
|
141 | parity = paritygen(web.stripecount) | |
@@ -164,7 +164,7 b' def _filerevision(web, req, fctx):' | |||||
164 | **pycompat.strkwargs(webutil.commonentry(web.repo, fctx))) |
|
164 | **pycompat.strkwargs(webutil.commonentry(web.repo, fctx))) | |
165 |
|
165 | |||
166 | @webcommand('file') |
|
166 | @webcommand('file') | |
167 |
def file(web |
|
167 | def file(web): | |
168 | """ |
|
168 | """ | |
169 | /file/{revision}[/{path}] |
|
169 | /file/{revision}[/{path}] | |
170 | ------------------------- |
|
170 | ------------------------- | |
@@ -184,16 +184,16 b' def file(web, req, tmpl):' | |||||
184 | be rendered. |
|
184 | be rendered. | |
185 | """ |
|
185 | """ | |
186 | if web.req.qsparams.get('style') == 'raw': |
|
186 | if web.req.qsparams.get('style') == 'raw': | |
187 |
return rawfile(web |
|
187 | return rawfile(web) | |
188 |
|
188 | |||
189 | path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', '')) |
|
189 | path = webutil.cleanpath(web.repo, web.req.qsparams.get('file', '')) | |
190 | if not path: |
|
190 | if not path: | |
191 |
return manifest(web |
|
191 | return manifest(web) | |
192 | try: |
|
192 | try: | |
193 |
return _filerevision(web |
|
193 | return _filerevision(web, webutil.filectx(web.repo, web.req)) | |
194 | except error.LookupError as inst: |
|
194 | except error.LookupError as inst: | |
195 | try: |
|
195 | try: | |
196 |
return manifest(web |
|
196 | return manifest(web) | |
197 | except ErrorResponse: |
|
197 | except ErrorResponse: | |
198 | raise inst |
|
198 | raise inst | |
199 |
|
199 | |||
@@ -354,7 +354,7 b' def _search(web):' | |||||
354 | showunforcekw=showunforcekw) |
|
354 | showunforcekw=showunforcekw) | |
355 |
|
355 | |||
356 | @webcommand('changelog') |
|
356 | @webcommand('changelog') | |
357 |
def changelog(web, |
|
357 | def changelog(web, shortlog=False): | |
358 | """ |
|
358 | """ | |
359 | /changelog[/{revision}] |
|
359 | /changelog[/{revision}] | |
360 | ----------------------- |
|
360 | ----------------------- | |
@@ -452,7 +452,7 b' def changelog(web, req, tmpl, shortlog=F' | |||||
452 | query=query) |
|
452 | query=query) | |
453 |
|
453 | |||
454 | @webcommand('shortlog') |
|
454 | @webcommand('shortlog') | |
455 |
def shortlog(web |
|
455 | def shortlog(web): | |
456 | """ |
|
456 | """ | |
457 | /shortlog |
|
457 | /shortlog | |
458 | --------- |
|
458 | --------- | |
@@ -463,10 +463,10 b' def shortlog(web, req, tmpl):' | |||||
463 | difference is the ``shortlog`` template will be rendered instead of the |
|
463 | difference is the ``shortlog`` template will be rendered instead of the | |
464 | ``changelog`` template. |
|
464 | ``changelog`` template. | |
465 | """ |
|
465 | """ | |
466 |
return changelog(web, |
|
466 | return changelog(web, shortlog=True) | |
467 |
|
467 | |||
468 | @webcommand('changeset') |
|
468 | @webcommand('changeset') | |
469 |
def changeset(web |
|
469 | def changeset(web): | |
470 | """ |
|
470 | """ | |
471 | /changeset[/{revision}] |
|
471 | /changeset[/{revision}] | |
472 | ----------------------- |
|
472 | ----------------------- | |
@@ -498,7 +498,7 b' def decodepath(path):' | |||||
498 | return path |
|
498 | return path | |
499 |
|
499 | |||
500 | @webcommand('manifest') |
|
500 | @webcommand('manifest') | |
501 |
def manifest(web |
|
501 | def manifest(web): | |
502 | """ |
|
502 | """ | |
503 | /manifest[/{revision}[/{path}]] |
|
503 | /manifest[/{revision}[/{path}]] | |
504 | ------------------------------- |
|
504 | ------------------------------- | |
@@ -598,7 +598,7 b' def manifest(web, req, tmpl):' | |||||
598 | **pycompat.strkwargs(webutil.commonentry(web.repo, ctx))) |
|
598 | **pycompat.strkwargs(webutil.commonentry(web.repo, ctx))) | |
599 |
|
599 | |||
600 | @webcommand('tags') |
|
600 | @webcommand('tags') | |
601 |
def tags(web |
|
601 | def tags(web): | |
602 | """ |
|
602 | """ | |
603 | /tags |
|
603 | /tags | |
604 | ----- |
|
604 | ----- | |
@@ -632,7 +632,7 b' def tags(web, req, tmpl):' | |||||
632 | latestentry=lambda **x: entries(True, True, **x)) |
|
632 | latestentry=lambda **x: entries(True, True, **x)) | |
633 |
|
633 | |||
634 | @webcommand('bookmarks') |
|
634 | @webcommand('bookmarks') | |
635 |
def bookmarks(web |
|
635 | def bookmarks(web): | |
636 | """ |
|
636 | """ | |
637 | /bookmarks |
|
637 | /bookmarks | |
638 | ---------- |
|
638 | ---------- | |
@@ -671,7 +671,7 b' def bookmarks(web, req, tmpl):' | |||||
671 | latestentry=lambda **x: entries(latestonly=True, **x)) |
|
671 | latestentry=lambda **x: entries(latestonly=True, **x)) | |
672 |
|
672 | |||
673 | @webcommand('branches') |
|
673 | @webcommand('branches') | |
674 |
def branches(web |
|
674 | def branches(web): | |
675 | """ |
|
675 | """ | |
676 | /branches |
|
676 | /branches | |
677 | --------- |
|
677 | --------- | |
@@ -694,7 +694,7 b' def branches(web, req, tmpl):' | |||||
694 | latestentry=latestentry) |
|
694 | latestentry=latestentry) | |
695 |
|
695 | |||
696 | @webcommand('summary') |
|
696 | @webcommand('summary') | |
697 |
def summary(web |
|
697 | def summary(web): | |
698 | """ |
|
698 | """ | |
699 | /summary |
|
699 | /summary | |
700 | -------- |
|
700 | -------- | |
@@ -778,7 +778,7 b' def summary(web, req, tmpl):' | |||||
778 | labels=web.configlist('web', 'labels')) |
|
778 | labels=web.configlist('web', 'labels')) | |
779 |
|
779 | |||
780 | @webcommand('filediff') |
|
780 | @webcommand('filediff') | |
781 |
def filediff(web |
|
781 | def filediff(web): | |
782 | """ |
|
782 | """ | |
783 | /diff/{revision}/{path} |
|
783 | /diff/{revision}/{path} | |
784 | ----------------------- |
|
784 | ----------------------- | |
@@ -827,7 +827,7 b' def filediff(web, req, tmpl):' | |||||
827 | diff = webcommand('diff')(filediff) |
|
827 | diff = webcommand('diff')(filediff) | |
828 |
|
828 | |||
829 | @webcommand('comparison') |
|
829 | @webcommand('comparison') | |
830 |
def comparison(web |
|
830 | def comparison(web): | |
831 | """ |
|
831 | """ | |
832 | /comparison/{revision}/{path} |
|
832 | /comparison/{revision}/{path} | |
833 | ----------------------------- |
|
833 | ----------------------------- | |
@@ -902,7 +902,7 b' def comparison(web, req, tmpl):' | |||||
902 | **pycompat.strkwargs(webutil.commonentry(web.repo, ctx))) |
|
902 | **pycompat.strkwargs(webutil.commonentry(web.repo, ctx))) | |
903 |
|
903 | |||
904 | @webcommand('annotate') |
|
904 | @webcommand('annotate') | |
905 |
def annotate(web |
|
905 | def annotate(web): | |
906 | """ |
|
906 | """ | |
907 | /annotate/{revision}/{path} |
|
907 | /annotate/{revision}/{path} | |
908 | --------------------------- |
|
908 | --------------------------- | |
@@ -994,7 +994,7 b' def annotate(web, req, tmpl):' | |||||
994 | **pycompat.strkwargs(webutil.commonentry(web.repo, fctx))) |
|
994 | **pycompat.strkwargs(webutil.commonentry(web.repo, fctx))) | |
995 |
|
995 | |||
996 | @webcommand('filelog') |
|
996 | @webcommand('filelog') | |
997 |
def filelog(web |
|
997 | def filelog(web): | |
998 | """ |
|
998 | """ | |
999 | /filelog/{revision}/{path} |
|
999 | /filelog/{revision}/{path} | |
1000 | -------------------------- |
|
1000 | -------------------------- | |
@@ -1132,7 +1132,7 b' def filelog(web, req, tmpl):' | |||||
1132 | **pycompat.strkwargs(webutil.commonentry(web.repo, fctx))) |
|
1132 | **pycompat.strkwargs(webutil.commonentry(web.repo, fctx))) | |
1133 |
|
1133 | |||
1134 | @webcommand('archive') |
|
1134 | @webcommand('archive') | |
1135 |
def archive(web |
|
1135 | def archive(web): | |
1136 | """ |
|
1136 | """ | |
1137 | /archive/{revision}.{format}[/{path}] |
|
1137 | /archive/{revision}.{format}[/{path}] | |
1138 | ------------------------------------- |
|
1138 | ------------------------------------- | |
@@ -1206,7 +1206,7 b' def archive(web, req, tmpl):' | |||||
1206 | return [] |
|
1206 | return [] | |
1207 |
|
1207 | |||
1208 | @webcommand('static') |
|
1208 | @webcommand('static') | |
1209 |
def static(web |
|
1209 | def static(web): | |
1210 | fname = web.req.qsparams['file'] |
|
1210 | fname = web.req.qsparams['file'] | |
1211 | # a repo owner may set web.static in .hg/hgrc to get any file |
|
1211 | # a repo owner may set web.static in .hg/hgrc to get any file | |
1212 | # readable by the user running the CGI script |
|
1212 | # readable by the user running the CGI script | |
@@ -1221,7 +1221,7 b' def static(web, req, tmpl):' | |||||
1221 | return web.res.sendresponse() |
|
1221 | return web.res.sendresponse() | |
1222 |
|
1222 | |||
1223 | @webcommand('graph') |
|
1223 | @webcommand('graph') | |
1224 |
def graph(web |
|
1224 | def graph(web): | |
1225 | """ |
|
1225 | """ | |
1226 | /graph[/{revision}] |
|
1226 | /graph[/{revision}] | |
1227 | ------------------- |
|
1227 | ------------------- | |
@@ -1388,7 +1388,7 b' def _getdoc(e):' | |||||
1388 | return doc |
|
1388 | return doc | |
1389 |
|
1389 | |||
1390 | @webcommand('help') |
|
1390 | @webcommand('help') | |
1391 |
def help(web |
|
1391 | def help(web): | |
1392 | """ |
|
1392 | """ | |
1393 | /help[/{topic}] |
|
1393 | /help[/{topic}] | |
1394 | --------------- |
|
1394 | --------------- |
@@ -6,7 +6,7 b' from mercurial.hgweb import (' | |||||
6 | webcommands, |
|
6 | webcommands, | |
7 | ) |
|
7 | ) | |
8 |
|
8 | |||
9 |
def raiseerror(web |
|
9 | def raiseerror(web): | |
10 | '''Dummy web command that raises an uncaught Exception.''' |
|
10 | '''Dummy web command that raises an uncaught Exception.''' | |
11 |
|
11 | |||
12 | # Simulate an error after partial response. |
|
12 | # Simulate an error after partial response. |
General Comments 0
You need to be logged in to leave comments.
Login now