Show More
@@ -591,45 +591,45 b' def _compline(tmpl, type, leftlineno, le' | |||
|
591 | 591 | 'rightline': rightline or '', |
|
592 | 592 | }) |
|
593 | 593 | |
|
594 |
def |
|
|
595 | '''Generator function that provides side-by-side comparison data.''' | |
|
596 | ||
|
597 | def getblock(opcodes): | |
|
598 | for type, llo, lhi, rlo, rhi in opcodes: | |
|
599 | len1 = lhi - llo | |
|
600 | len2 = rhi - rlo | |
|
601 | count = min(len1, len2) | |
|
602 | for i in xrange(count): | |
|
594 | def _getcompblock(tmpl, leftlines, rightlines, opcodes): | |
|
595 | for type, llo, lhi, rlo, rhi in opcodes: | |
|
596 | len1 = lhi - llo | |
|
597 | len2 = rhi - rlo | |
|
598 | count = min(len1, len2) | |
|
599 | for i in xrange(count): | |
|
600 | yield _compline(tmpl, | |
|
601 | type=type, | |
|
602 | leftlineno=llo + i + 1, | |
|
603 | leftline=leftlines[llo + i], | |
|
604 | rightlineno=rlo + i + 1, | |
|
605 | rightline=rightlines[rlo + i]) | |
|
606 | if len1 > len2: | |
|
607 | for i in xrange(llo + count, lhi): | |
|
603 | 608 | yield _compline(tmpl, |
|
604 | 609 | type=type, |
|
605 |
leftlineno= |
|
|
606 |
leftline=leftlines[ |
|
|
607 |
rightlineno= |
|
|
608 |
rightline= |
|
|
609 |
|
|
|
610 |
|
|
|
611 |
|
|
|
612 |
|
|
|
613 |
|
|
|
614 |
|
|
|
615 |
|
|
|
616 |
|
|
|
617 | elif len2 > len1: | |
|
618 | for i in xrange(rlo + count, rhi): | |
|
619 | yield _compline(tmpl, | |
|
620 | type=type, | |
|
621 | leftlineno=None, | |
|
622 | leftline=None, | |
|
623 | rightlineno=i + 1, | |
|
624 | rightline=rightlines[i]) | |
|
610 | leftlineno=i + 1, | |
|
611 | leftline=leftlines[i], | |
|
612 | rightlineno=None, | |
|
613 | rightline=None) | |
|
614 | elif len2 > len1: | |
|
615 | for i in xrange(rlo + count, rhi): | |
|
616 | yield _compline(tmpl, | |
|
617 | type=type, | |
|
618 | leftlineno=None, | |
|
619 | leftline=None, | |
|
620 | rightlineno=i + 1, | |
|
621 | rightline=rightlines[i]) | |
|
625 | 622 | |
|
623 | def compare(tmpl, context, leftlines, rightlines): | |
|
624 | '''Generator function that provides side-by-side comparison data.''' | |
|
626 | 625 | s = difflib.SequenceMatcher(None, leftlines, rightlines) |
|
627 | 626 | if context < 0: |
|
628 | yield tmpl.generate('comparisonblock', | |
|
629 | {'lines': getblock(s.get_opcodes())}) | |
|
627 | l = _getcompblock(tmpl, leftlines, rightlines, s.get_opcodes()) | |
|
628 | yield tmpl.generate('comparisonblock', {'lines': l}) | |
|
630 | 629 | else: |
|
631 | 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 | 634 | def diffstatgen(ctx, basectx): |
|
635 | 635 | '''Generator function that provides the diffstat data.''' |
General Comments 0
You need to be logged in to leave comments.
Login now