# HG changeset patch # User Yuya Nishihara # Date 2018-04-19 14:33:17 # Node ID 090c89a8db32399adec8778f7c62fdf70e86c52b # Parent 5cab6f5016fa5e2c50f89bbfc2f92369efd41522 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. diff --git a/mercurial/diffhelpers.py b/mercurial/diffhelpers.py --- a/mercurial/diffhelpers.py +++ b/mercurial/diffhelpers.py @@ -69,7 +69,7 @@ def testhunk(a, b, bstart): """ 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]: