Mercurial > hg
comparison mercurial/hgweb/webutil.py @ 37991:4e407c7b1fbd
hgweb: rename 'context' argument of webutil.compare() to avoid name conflicts
The meaning of 'context' depends on context. Here it is the number of the
context lines in unified diff.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 04 Apr 2018 21:14:30 +0900 |
parents | c0ccbf4fbe47 |
children | b3992c21b7f3 |
comparison
equal
deleted
inserted
replaced
37990:c0ccbf4fbe47 | 37991:4e407c7b1fbd |
---|---|
620 def _getcompblock(leftlines, rightlines, opcodes): | 620 def _getcompblock(leftlines, rightlines, opcodes): |
621 args = (leftlines, rightlines, opcodes) | 621 args = (leftlines, rightlines, opcodes) |
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, context, leftlines, rightlines): | 625 def compare(tmpl, 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 context < 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 tmpl.generate('comparisonblock', {'lines': l}) |
631 else: | 631 else: |
632 for oc in s.get_grouped_opcodes(n=context): | 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 tmpl.generate('comparisonblock', {'lines': l}) |
635 | 635 |
636 def diffstatgen(ctx, basectx): | 636 def diffstatgen(ctx, basectx): |
637 '''Generator function that provides the diffstat data.''' | 637 '''Generator function that provides the diffstat data.''' |