Mercurial > hg
comparison mercurial/hgweb/webcommands.py @ 37019:c97b936d8bb5
templater: use named function to expand template against mapping dict (API)
And replace __call__(t, **mapping) in favor of generate(t, mapping). I prefer
a named function here since the templater isn't a simple function-like object.
.. api::
The templater is no longer callable. Use ``templater.generate(t, mapping)``
instead of ``templater(t, **pycompat.strkwargs(mapping))``.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 16 Mar 2018 21:39:32 +0900 |
parents | a82fc3922446 |
children | b33b91ca2ec2 |
comparison
equal
deleted
inserted
replaced
37018:3e74d3cc500f | 37019:c97b936d8bb5 |
---|---|
292 n = ctx.node() | 292 n = ctx.node() |
293 showtags = webutil.showtag(web.repo, web.tmpl, 'changelogtag', n) | 293 showtags = webutil.showtag(web.repo, web.tmpl, 'changelogtag', n) |
294 files = webutil.listfilediffs(web.tmpl, ctx.files(), n, | 294 files = webutil.listfilediffs(web.tmpl, ctx.files(), n, |
295 web.maxfiles) | 295 web.maxfiles) |
296 | 296 |
297 yield web.tmpl( | 297 lm = webutil.commonentry(web.repo, ctx) |
298 'searchentry', | 298 lm.update({ |
299 parity=next(parity), | 299 'parity': next(parity), |
300 changelogtag=showtags, | 300 'changelogtag': showtags, |
301 files=files, | 301 'files': files, |
302 **pycompat.strkwargs(webutil.commonentry(web.repo, ctx))) | 302 }) |
303 yield web.tmpl.generate('searchentry', lm) | |
303 | 304 |
304 if count >= revcount: | 305 if count >= revcount: |
305 break | 306 break |
306 | 307 |
307 query = web.req.qsparams['rev'] | 308 query = web.req.qsparams['rev'] |
717 | 718 |
718 count += 1 | 719 count += 1 |
719 if count > 10: # limit to 10 tags | 720 if count > 10: # limit to 10 tags |
720 break | 721 break |
721 | 722 |
722 yield web.tmpl( | 723 yield web.tmpl.generate('tagentry', { |
723 'tagentry', | 724 'parity': next(parity), |
724 parity=next(parity), | 725 'tag': k, |
725 tag=k, | 726 'node': hex(n), |
726 node=hex(n), | 727 'date': web.repo[n].date(), |
727 date=web.repo[n].date()) | 728 }) |
728 | 729 |
729 def bookmarks(**map): | 730 def bookmarks(**map): |
730 parity = paritygen(web.stripecount) | 731 parity = paritygen(web.stripecount) |
731 marks = [b for b in web.repo._bookmarks.items() if b[1] in web.repo] | 732 marks = [b for b in web.repo._bookmarks.items() if b[1] in web.repo] |
732 sortkey = lambda b: (web.repo[b[1]].rev(), b[0]) | 733 sortkey = lambda b: (web.repo[b[1]].rev(), b[0]) |
743 revs = [] | 744 revs = [] |
744 if start < end: | 745 if start < end: |
745 revs = web.repo.changelog.revs(start, end - 1) | 746 revs = web.repo.changelog.revs(start, end - 1) |
746 for i in revs: | 747 for i in revs: |
747 ctx = web.repo[i] | 748 ctx = web.repo[i] |
748 | 749 lm = webutil.commonentry(web.repo, ctx) |
749 l.append(web.tmpl( | 750 lm['parity'] = next(parity) |
750 'shortlogentry', | 751 l.append(web.tmpl.generate('shortlogentry', lm)) |
751 parity=next(parity), | |
752 **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))) | |
753 | 752 |
754 for entry in reversed(l): | 753 for entry in reversed(l): |
755 yield entry | 754 yield entry |
756 | 755 |
757 tip = web.repo['tip'] | 756 tip = web.repo['tip'] |