##// END OF EJS Templates
hgweb: convert {comparison} to a mappinggenerator with named template...
Yuya Nishihara -
r38012:b3992c21 default
parent child Browse files
Show More
@@ -622,16 +622,21 b' def _getcompblock(leftlines, rightlines,'
622 return templateutil.mappinggenerator(_getcompblockgen, args=args,
622 return templateutil.mappinggenerator(_getcompblockgen, args=args,
623 name='comparisonline')
623 name='comparisonline')
624
624
625 def compare(tmpl, contextnum, leftlines, rightlines):
625 def _comparegen(context, contextnum, leftlines, rightlines):
626 '''Generator function that provides side-by-side comparison data.'''
626 '''Generator function that provides side-by-side comparison data.'''
627 s = difflib.SequenceMatcher(None, leftlines, rightlines)
627 s = difflib.SequenceMatcher(None, leftlines, rightlines)
628 if contextnum < 0:
628 if contextnum < 0:
629 l = _getcompblock(leftlines, rightlines, s.get_opcodes())
629 l = _getcompblock(leftlines, rightlines, s.get_opcodes())
630 yield tmpl.generate('comparisonblock', {'lines': l})
630 yield {'lines': l}
631 else:
631 else:
632 for oc in s.get_grouped_opcodes(n=contextnum):
632 for oc in s.get_grouped_opcodes(n=contextnum):
633 l = _getcompblock(leftlines, rightlines, oc)
633 l = _getcompblock(leftlines, rightlines, oc)
634 yield tmpl.generate('comparisonblock', {'lines': l})
634 yield {'lines': l}
635
636 def compare(tmpl, contextnum, leftlines, rightlines):
637 args = (contextnum, leftlines, rightlines)
638 return templateutil.mappinggenerator(_comparegen, args=args,
639 name='comparisonblock')
635
640
636 def diffstatgen(ctx, basectx):
641 def diffstatgen(ctx, basectx):
637 '''Generator function that provides the diffstat data.'''
642 '''Generator function that provides the diffstat data.'''
General Comments 0
You need to be logged in to leave comments. Login now