Patchwork [1,of,8] hgwebdir: wrap {entries} with mappinggenerator

login
register
mail settings
Submitter Yuya Nishihara
Date April 10, 2018, 3:41 p.m.
Message ID <4dcd5d6cbfd17115e4a2.1523374894@mimosa>
Download mbox | patch
Permalink /patch/30632/
State Accepted
Headers show

Comments

Yuya Nishihara - April 10, 2018, 3:41 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522588318 -32400
#      Sun Apr 01 22:11:58 2018 +0900
# Node ID 4dcd5d6cbfd17115e4a2359c124ec8887bb7986c
# Parent  479fbecf9cccd27040b88e713956d15286b6d2b0
hgwebdir: wrap {entries} with mappinggenerator

No bare generator should be put in a template mapping.

Patch

diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py
+++ b/mercurial/hgweb/hgwebdir_mod.py
@@ -35,6 +35,7 @@  from .. import (
     pycompat,
     scmutil,
     templater,
+    templateutil,
     ui as uimod,
     util,
 )
@@ -246,9 +247,8 @@  def rawindexentries(ui, repos, req, subd
 
         yield row
 
-def indexentries(ui, repos, req, stripecount, sortcolumn='',
-                 descending=False, subdir=''):
-
+def _indexentriesgen(context, ui, repos, req, stripecount, sortcolumn,
+                     descending, subdir):
     rows = rawindexentries(ui, repos, req, subdir=subdir)
 
     sortdefault = None, False
@@ -262,6 +262,11 @@  def indexentries(ui, repos, req, stripec
         row['parity'] = parity
         yield row
 
+def indexentries(ui, repos, req, stripecount, sortcolumn='',
+                 descending=False, subdir=''):
+    args = (ui, repos, req, stripecount, sortcolumn, descending, subdir)
+    return templateutil.mappinggenerator(_indexentriesgen, args=args)
+
 class hgwebdir(object):
     """HTTP server for multiple repositories.