Patchwork [4,of,7] hgweb: wrap {lines} of filerevision with mappinggenerator

login
register
mail settings
Submitter Yuya Nishihara
Date May 13, 2018, 3:20 a.m.
Message ID <074088cc1a58201566d9.1526181601@mimosa>
Download mbox | patch
Permalink /patch/31572/
State Accepted
Headers show

Comments

Yuya Nishihara - May 13, 2018, 3:20 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522769049 -32400
#      Wed Apr 04 00:24:09 2018 +0900
# Node ID 074088cc1a58201566d9a0c024db122c45149d79
# Parent  94e0c9ba279d1269f9ed8c602a0e20d44dd59321
hgweb: wrap {lines} of filerevision with mappinggenerator

No bare generator of mappings should be put in a template mapping.

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -149,7 +149,7 @@  def _filerevision(web, fctx):
         mt = mimetypes.guess_type(f)[0] or 'application/octet-stream'
         text = '(binary:%s)' % mt
 
-    def lines():
+    def lines(context):
         for lineno, t in enumerate(text.splitlines(True)):
             yield {"line": t,
                    "lineid": "l%d" % (lineno + 1),
@@ -160,7 +160,7 @@  def _filerevision(web, fctx):
         'filerevision',
         file=f,
         path=webutil.up(f),
-        text=lines(),
+        text=templateutil.mappinggenerator(lines),
         symrev=webutil.symrevorshortnode(web.req, fctx),
         rename=webutil.renamelink(fctx),
         permissions=fctx.manifest().flags(f),