##// END OF EJS Templates
diffhelpers: make return value of testhunk() more Pythonic...
Yuya Nishihara -
r37592:a1bcc7ff default
parent child Browse files
Show More
@@ -70,8 +70,8 b' def testhunk(a, b, bstart):'
70 70 alen = len(a)
71 71 blen = len(b)
72 72 if alen > blen - bstart:
73 return -1
73 return False
74 74 for i in xrange(alen):
75 75 if a[i][1:] != b[i + bstart]:
76 return -1
77 return 0
76 return False
77 return True
@@ -795,8 +795,7 b' class patchfile(object):'
795 795 # if there's skew we want to emit the "(offset %d lines)" even
796 796 # when the hunk cleanly applies at start + skew, so skip the
797 797 # fast case code
798 if (self.skew == 0 and
799 diffhelpers.testhunk(old, self.lines, oldstart) == 0):
798 if self.skew == 0 and diffhelpers.testhunk(old, self.lines, oldstart):
800 799 if self.remove:
801 800 self.backend.unlink(self.fname)
802 801 else:
@@ -823,7 +822,7 b' class patchfile(object):'
823 822 cand = [oldstart]
824 823
825 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 826 self.lines[l : l + len(old)] = new
828 827 self.offset += len(new) - len(old)
829 828 self.skew = l - orig_start
General Comments 0
You need to be logged in to leave comments. Login now