##// END OF EJS Templates
hgweb: move getblock() closure out of compare()...
Yuya Nishihara -
r38009:53b0a51a default
parent child Browse files
Show More
@@ -591,10 +591,7 b' def _compline(tmpl, type, leftlineno, le'
591 'rightline': rightline or '',
591 'rightline': rightline or '',
592 })
592 })
593
593
594 def compare(tmpl, context, leftlines, rightlines):
594 def _getcompblock(tmpl, leftlines, rightlines, opcodes):
595 '''Generator function that provides side-by-side comparison data.'''
596
597 def getblock(opcodes):
598 for type, llo, lhi, rlo, rhi in opcodes:
595 for type, llo, lhi, rlo, rhi in opcodes:
599 len1 = lhi - llo
596 len1 = lhi - llo
600 len2 = rhi - rlo
597 len2 = rhi - rlo
@@ -623,13 +620,16 b' def compare(tmpl, context, leftlines, ri'
623 rightlineno=i + 1,
620 rightlineno=i + 1,
624 rightline=rightlines[i])
621 rightline=rightlines[i])
625
622
623 def compare(tmpl, context, leftlines, rightlines):
624 '''Generator function that provides side-by-side comparison data.'''
626 s = difflib.SequenceMatcher(None, leftlines, rightlines)
625 s = difflib.SequenceMatcher(None, leftlines, rightlines)
627 if context < 0:
626 if context < 0:
628 yield tmpl.generate('comparisonblock',
627 l = _getcompblock(tmpl, leftlines, rightlines, s.get_opcodes())
629 {'lines': getblock(s.get_opcodes())})
628 yield tmpl.generate('comparisonblock', {'lines': l})
630 else:
629 else:
631 for oc in s.get_grouped_opcodes(n=context):
630 for oc in s.get_grouped_opcodes(n=context):
632 yield tmpl.generate('comparisonblock', {'lines': getblock(oc)})
631 l = _getcompblock(tmpl, leftlines, rightlines, oc)
632 yield tmpl.generate('comparisonblock', {'lines': l})
633
633
634 def diffstatgen(ctx, basectx):
634 def diffstatgen(ctx, basectx):
635 '''Generator function that provides the diffstat data.'''
635 '''Generator function that provides the diffstat data.'''
General Comments 0
You need to be logged in to leave comments. Login now