comparison mercurial/commands.py @ 39041:2525c4943c09

grep: difflib sequencematcher opcodes are native strs Differential Revision: https://phab.mercurial-scm.org/D4237
author Augie Fackler <augie@google.com>
date Thu, 09 Aug 2018 23:12:44 -0400
parents f3f109971359
children 9126a4034621
comparison
equal deleted inserted replaced
39040:f76c1343859d 39041:2525c4943c09
2606 m.append(s) 2606 m.append(s)
2607 2607
2608 def difflinestates(a, b): 2608 def difflinestates(a, b):
2609 sm = difflib.SequenceMatcher(None, a, b) 2609 sm = difflib.SequenceMatcher(None, a, b)
2610 for tag, alo, ahi, blo, bhi in sm.get_opcodes(): 2610 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
2611 if tag == 'insert': 2611 if tag == r'insert':
2612 for i in pycompat.xrange(blo, bhi): 2612 for i in pycompat.xrange(blo, bhi):
2613 yield ('+', b[i]) 2613 yield ('+', b[i])
2614 elif tag == 'delete': 2614 elif tag == r'delete':
2615 for i in pycompat.xrange(alo, ahi): 2615 for i in pycompat.xrange(alo, ahi):
2616 yield ('-', a[i]) 2616 yield ('-', a[i])
2617 elif tag == 'replace': 2617 elif tag == r'replace':
2618 for i in pycompat.xrange(alo, ahi): 2618 for i in pycompat.xrange(alo, ahi):
2619 yield ('-', a[i]) 2619 yield ('-', a[i])
2620 for i in pycompat.xrange(blo, bhi): 2620 for i in pycompat.xrange(blo, bhi):
2621 yield ('+', b[i]) 2621 yield ('+', b[i])
2622 2622