comparison mercurial/patch.py @ 37574:a1bcc7ff0eac

diffhelpers: make return value of testhunk() more Pythonic It's no longer C.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 09 Apr 2018 21:08:52 +0900
parents 49b82cdb5983
children 5537d8f5e989
comparison
equal deleted inserted replaced
37573:49b82cdb5983 37574:a1bcc7ff0eac
793 oldstart += self.offset 793 oldstart += self.offset
794 orig_start = oldstart 794 orig_start = oldstart
795 # if there's skew we want to emit the "(offset %d lines)" even 795 # if there's skew we want to emit the "(offset %d lines)" even
796 # when the hunk cleanly applies at start + skew, so skip the 796 # when the hunk cleanly applies at start + skew, so skip the
797 # fast case code 797 # fast case code
798 if (self.skew == 0 and 798 if self.skew == 0 and diffhelpers.testhunk(old, self.lines, oldstart):
799 diffhelpers.testhunk(old, self.lines, oldstart) == 0):
800 if self.remove: 799 if self.remove:
801 self.backend.unlink(self.fname) 800 self.backend.unlink(self.fname)
802 else: 801 else:
803 self.lines[oldstart:oldstart + len(old)] = new 802 self.lines[oldstart:oldstart + len(old)] = new
804 self.offset += len(new) - len(old) 803 self.offset += len(new) - len(old)
821 # Only adding lines with no or fuzzed context, just 820 # Only adding lines with no or fuzzed context, just
822 # take the skew in account 821 # take the skew in account
823 cand = [oldstart] 822 cand = [oldstart]
824 823
825 for l in cand: 824 for l in cand:
826 if not old or diffhelpers.testhunk(old, self.lines, l) == 0: 825 if not old or diffhelpers.testhunk(old, self.lines, l):
827 self.lines[l : l + len(old)] = new 826 self.lines[l : l + len(old)] = new
828 self.offset += len(new) - len(old) 827 self.offset += len(new) - len(old)
829 self.skew = l - orig_start 828 self.skew = l - orig_start
830 self.dirty = True 829 self.dirty = True
831 offset = l - orig_start - fuzzlen 830 offset = l - orig_start - fuzzlen