Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/webcommands.py @ 36891:c68e79dcf21c
hgweb: don't redundantly pass templater with requestcontext (API)
The requestcontenxt has a ``tmpl`` attribute to access the
templater. We don't need to pass the templater explicitly when
passing a requestcontext instance.
.. api::
Various helper functions in hgweb.webutil no longer accept a
templater instance. Access the templater through the
``web`` argument instead.
Differential Revision: https://phab.mercurial-scm.org/D2801
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 10 Mar 2018 19:46:54 -0800 |
parents | ece242db5000 |
children | 563fd95a6efb |
comparison
equal
deleted
inserted
replaced
36890:ece242db5000 | 36891:c68e79dcf21c |
---|---|
397 for rev in revs: | 397 for rev in revs: |
398 curcount += 1 | 398 curcount += 1 |
399 if curcount > revcount + 1: | 399 if curcount > revcount + 1: |
400 break | 400 break |
401 | 401 |
402 entry = webutil.changelistentry(web, web.repo[rev], web.tmpl) | 402 entry = webutil.changelistentry(web, web.repo[rev]) |
403 entry['parity'] = next(parity) | 403 entry['parity'] = next(parity) |
404 yield entry | 404 yield entry |
405 | 405 |
406 if shortlog: | 406 if shortlog: |
407 revcount = web.maxshortchanges | 407 revcount = web.maxshortchanges |
483 """ | 483 """ |
484 ctx = webutil.changectx(web.repo, req) | 484 ctx = webutil.changectx(web.repo, req) |
485 | 485 |
486 return web.sendtemplate( | 486 return web.sendtemplate( |
487 'changeset', | 487 'changeset', |
488 **webutil.changesetentry(web, req, web.tmpl, ctx)) | 488 **webutil.changesetentry(web, req, ctx)) |
489 | 489 |
490 rev = webcommand('rev')(changeset) | 490 rev = webcommand('rev')(changeset) |
491 | 491 |
492 def decodepath(path): | 492 def decodepath(path): |
493 """Hook for mapping a path in the repository to a path in the | 493 """Hook for mapping a path in the repository to a path in the |
806 | 806 |
807 style = web.config('web', 'style') | 807 style = web.config('web', 'style') |
808 if 'style' in web.req.qsparams: | 808 if 'style' in web.req.qsparams: |
809 style = web.req.qsparams['style'] | 809 style = web.req.qsparams['style'] |
810 | 810 |
811 diffs = webutil.diffs(web, web.tmpl, ctx, basectx, [path], style) | 811 diffs = webutil.diffs(web, ctx, basectx, [path], style) |
812 if fctx is not None: | 812 if fctx is not None: |
813 rename = webutil.renamelink(fctx) | 813 rename = webutil.renamelink(fctx) |
814 ctx = fctx | 814 ctx = fctx |
815 else: | 815 else: |
816 rename = [] | 816 rename = [] |
1064 | 1064 |
1065 def diff(fctx, linerange=None): | 1065 def diff(fctx, linerange=None): |
1066 ctx = fctx.changectx() | 1066 ctx = fctx.changectx() |
1067 basectx = ctx.p1() | 1067 basectx = ctx.p1() |
1068 path = fctx.path() | 1068 path = fctx.path() |
1069 return webutil.diffs(web, web.tmpl, ctx, basectx, [path], diffstyle, | 1069 return webutil.diffs(web, ctx, basectx, [path], diffstyle, |
1070 linerange=linerange, | 1070 linerange=linerange, |
1071 lineidprefix='%s-' % ctx.hex()[:12]) | 1071 lineidprefix='%s-' % ctx.hex()[:12]) |
1072 | 1072 |
1073 linerange = None | 1073 linerange = None |
1074 if lrange is not None: | 1074 if lrange is not None: |