diffhelpers: make return value of testhunk() more Pythonic
It's no longer C.
--- a/mercurial/diffhelpers.py Mon Apr 09 21:06:46 2018 +0900
+++ b/mercurial/diffhelpers.py Mon Apr 09 21:08:52 2018 +0900
@@ -70,8 +70,8 @@
alen = len(a)
blen = len(b)
if alen > blen - bstart:
- return -1
+ return False
for i in xrange(alen):
if a[i][1:] != b[i + bstart]:
- return -1
- return 0
+ return False
+ return True
--- a/mercurial/patch.py Mon Apr 09 21:06:46 2018 +0900
+++ b/mercurial/patch.py Mon Apr 09 21:08:52 2018 +0900
@@ -795,8 +795,7 @@
# if there's skew we want to emit the "(offset %d lines)" even
# when the hunk cleanly applies at start + skew, so skip the
# fast case code
- if (self.skew == 0 and
- diffhelpers.testhunk(old, self.lines, oldstart) == 0):
+ if self.skew == 0 and diffhelpers.testhunk(old, self.lines, oldstart):
if self.remove:
self.backend.unlink(self.fname)
else:
@@ -823,7 +822,7 @@
cand = [oldstart]
for l in cand:
- if not old or diffhelpers.testhunk(old, self.lines, l) == 0:
+ if not old or diffhelpers.testhunk(old, self.lines, l):
self.lines[l : l + len(old)] = new
self.offset += len(new) - len(old)
self.skew = l - orig_start