Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/webutil.py @ 37995:c4313a9fde7b
hgweb: use template context to render {files} of changesetentry()
This is a preferred way to process nested templates.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 03 Apr 2018 23:31:11 +0900 |
parents | 790ca0c11fd4 |
children | 028d7c24f2e5 |
comparison
equal
deleted
inserted
replaced
37994:790ca0c11fd4 | 37995:c4313a9fde7b |
---|---|
461 if 'node' in req.qsparams: | 461 if 'node' in req.qsparams: |
462 return templatefilters.revescape(req.qsparams['node']) | 462 return templatefilters.revescape(req.qsparams['node']) |
463 else: | 463 else: |
464 return short(ctx.node()) | 464 return short(ctx.node()) |
465 | 465 |
466 def _listfilesgen(context, tmpl, ctx, stripecount): | 466 def _listfilesgen(context, ctx, stripecount): |
467 parity = paritygen(stripecount) | 467 parity = paritygen(stripecount) |
468 for blockno, f in enumerate(ctx.files()): | 468 for blockno, f in enumerate(ctx.files()): |
469 template = 'filenodelink' if f in ctx else 'filenolink' | 469 template = 'filenodelink' if f in ctx else 'filenolink' |
470 yield tmpl.generate(template, { | 470 yield context.process(template, { |
471 'node': ctx.hex(), | 471 'node': ctx.hex(), |
472 'file': f, | 472 'file': f, |
473 'blockno': blockno + 1, | 473 'blockno': blockno + 1, |
474 'parity': next(parity), | 474 'parity': next(parity), |
475 }) | 475 }) |
501 basenode=basectx.hex(), | 501 basenode=basectx.hex(), |
502 changesettag=showtags, | 502 changesettag=showtags, |
503 changesetbookmark=showbookmarks, | 503 changesetbookmark=showbookmarks, |
504 changesetbranch=showbranch, | 504 changesetbranch=showbranch, |
505 files=templateutil.mappedgenerator(_listfilesgen, | 505 files=templateutil.mappedgenerator(_listfilesgen, |
506 args=(web.tmpl, ctx, | 506 args=(ctx, web.stripecount)), |
507 web.stripecount)), | |
508 diffsummary=lambda **x: diffsummary(diffstatsgen), | 507 diffsummary=lambda **x: diffsummary(diffstatsgen), |
509 diffstat=diffstats, | 508 diffstat=diffstats, |
510 archives=web.archivelist(ctx.hex()), | 509 archives=web.archivelist(ctx.hex()), |
511 **pycompat.strkwargs(commonentry(web.repo, ctx))) | 510 **pycompat.strkwargs(commonentry(web.repo, ctx))) |
512 | 511 |