diffhelpers: backport 9e40bc4c1bde from C implementation stable
authorYuya Nishihara <yuya@tcha.org>
Thu, 19 Apr 2018 23:33:17 +0900
branchstable
changeset 37802 090c89a8db32
parent 37801 5cab6f5016fa
child 37803 72f6498c040b
diffhelpers: backport 9e40bc4c1bde from C implementation 9e40bc4c1bde just says "harden testhunk." I don't think this would be the case, but it makes some sense to avoid negative index.
mercurial/diffhelpers.py
--- a/mercurial/diffhelpers.py	Fri Apr 20 20:38:29 2018 +0900
+++ b/mercurial/diffhelpers.py	Thu Apr 19 23:33:17 2018 +0900
@@ -69,7 +69,7 @@
     """
     alen = len(a)
     blen = len(b)
-    if alen > blen - bstart:
+    if alen > blen - bstart or bstart < 0:
         return False
     for i in xrange(alen):
         if a[i][1:] != b[i + bstart]: