From patchwork Sat May 12 03:35:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [03,of,10] hgweb: use template context to render {lines} of {diff} From: Yuya Nishihara X-Patchwork-Id: 31532 Message-Id: <61596d8c9f8c083ccac0.1526096110@mimosa> To: mercurial-devel@mercurial-scm.org Date: Sat, 12 May 2018 12:35:10 +0900 # HG changeset patch # User Yuya Nishihara # Date 1522766621 -32400 # Tue Apr 03 23:43:41 2018 +0900 # Node ID 61596d8c9f8c083ccac07334e3a4010df7ad9646 # Parent 11a0e939b544d0c091c20b1d82bdc775a3b0b9ff hgweb: use template context to render {lines} of {diff} This is a preferred way to process nested templates. diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -519,7 +519,7 @@ def listfilediffs(files, node, max): return templateutil.mappedgenerator(_listfilediffsgen, args=(files, node, max)) -def _prettyprintdifflines(context, tmpl, lines, blockno, lineidprefix): +def _prettyprintdifflines(context, lines, blockno, lineidprefix): for lineno, l in enumerate(lines, 1): difflineno = "%d.%d" % (blockno, lineno) if l.startswith('+'): @@ -530,7 +530,7 @@ def _prettyprintdifflines(context, tmpl, ltype = "difflineat" else: ltype = "diffline" - yield tmpl.generate(ltype, { + yield context.process(ltype, { 'line': l, 'lineno': lineno, 'lineid': lineidprefix + "l%s" % difflineno, @@ -563,7 +563,7 @@ def diffs(web, ctx, basectx, files, styl lines.extend(hunklines) if lines: l = templateutil.mappedgenerator(_prettyprintdifflines, - args=(web.tmpl, lines, blockno, + args=(lines, blockno, lineidprefix)) yield web.tmpl.generate('diffblock', { 'parity': next(parity),