Patchwork [5,of,7] hgweb: wrap {succsandmarkers} with mappinggenerator

login
register
mail settings
Submitter Yuya Nishihara
Date May 9, 2018, 1:33 p.m.
Message ID <20330c4fe13bd19941e5.1525872786@mimosa>
Download mbox | patch
Permalink /patch/31431/
State Accepted
Headers show

Comments

Yuya Nishihara - May 9, 2018, 1:33 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522763676 -32400
#      Tue Apr 03 22:54:36 2018 +0900
# Node ID 20330c4fe13bd19941e56152e6b525b336d54e07
# Parent  dd0c574b7d3565fdaefd222d6448b9468516d640
hgweb: wrap {succsandmarkers} with mappinggenerator

This is also a generator of mappings, which needs a wrapper.

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -378,7 +378,7 @@  def linerange(req):
 def formatlinerange(fromline, toline):
     return '%d:%d' % (fromline + 1, toline)
 
-def succsandmarkers(context, mapping):
+def _succsandmarkersgen(context, mapping):
     repo = context.resource(mapping, 'repo')
     itemmappings = templatekw.showsuccsandmarkers(context, mapping)
     for item in itemmappings.tovalue(context, mapping):
@@ -386,6 +386,9 @@  def succsandmarkers(context, mapping):
                                        for successor in item['successors'])
         yield item
 
+def succsandmarkers(context, mapping):
+    return templateutil.mappinggenerator(_succsandmarkersgen, args=(mapping,))
+
 # teach templater succsandmarkers is switched to (context, mapping) API
 succsandmarkers._requires = {'repo', 'ctx'}