hgweb: convert {comparison} to a mappinggenerator with named template
authorYuya Nishihara <yuya@tcha.org>
Wed, 04 Apr 2018 21:17:10 +0900
changeset 37992 b3992c21b7f3
parent 37991 4e407c7b1fbd
child 37993 623dc2651d26
hgweb: convert {comparison} to a mappinggenerator with named template No bare generator.
mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py	Wed Apr 04 21:14:30 2018 +0900
+++ b/mercurial/hgweb/webutil.py	Wed Apr 04 21:17:10 2018 +0900
@@ -622,16 +622,21 @@
     return templateutil.mappinggenerator(_getcompblockgen, args=args,
                                          name='comparisonline')
 
-def compare(tmpl, contextnum, leftlines, rightlines):
+def _comparegen(context, contextnum, leftlines, rightlines):
     '''Generator function that provides side-by-side comparison data.'''
     s = difflib.SequenceMatcher(None, leftlines, rightlines)
     if contextnum < 0:
         l = _getcompblock(leftlines, rightlines, s.get_opcodes())
-        yield tmpl.generate('comparisonblock', {'lines': l})
+        yield {'lines': l}
     else:
         for oc in s.get_grouped_opcodes(n=contextnum):
             l = _getcompblock(leftlines, rightlines, oc)
-            yield tmpl.generate('comparisonblock', {'lines': l})
+            yield {'lines': l}
+
+def compare(tmpl, contextnum, leftlines, rightlines):
+    args = (contextnum, leftlines, rightlines)
+    return templateutil.mappinggenerator(_comparegen, args=args,
+                                         name='comparisonblock')
 
 def diffstatgen(ctx, basectx):
     '''Generator function that provides the diffstat data.'''