862 # ok, we couldn't match the hunk. Lets look for offsets and fuzz it |
862 # ok, we couldn't match the hunk. Lets look for offsets and fuzz it |
863 self.hash = {} |
863 self.hash = {} |
864 for x, s in enumerate(self.lines): |
864 for x, s in enumerate(self.lines): |
865 self.hash.setdefault(s, []).append(x) |
865 self.hash.setdefault(s, []).append(x) |
866 |
866 |
867 for fuzzlen in pycompat.xrange( |
867 for fuzzlen in range(self.ui.configint(b"patch", b"fuzz") + 1): |
868 self.ui.configint(b"patch", b"fuzz") + 1 |
|
869 ): |
|
870 for toponly in [True, False]: |
868 for toponly in [True, False]: |
871 old, oldstart, new, newstart = h.fuzzit(fuzzlen, toponly) |
869 old, oldstart, new, newstart = h.fuzzit(fuzzlen, toponly) |
872 oldstart = oldstart + self.offset + self.skew |
870 oldstart = oldstart + self.offset + self.skew |
873 oldstart = min(oldstart, len(self.lines)) |
871 oldstart = min(oldstart, len(self.lines)) |
874 if old: |
872 if old: |
1464 bend = self.startb |
1462 bend = self.startb |
1465 self.lenb = int(bend) - self.startb |
1463 self.lenb = int(bend) - self.startb |
1466 if self.startb: |
1464 if self.startb: |
1467 self.lenb += 1 |
1465 self.lenb += 1 |
1468 hunki = 1 |
1466 hunki = 1 |
1469 for x in pycompat.xrange(self.lenb): |
1467 for x in range(self.lenb): |
1470 l = lr.readline() |
1468 l = lr.readline() |
1471 if l.startswith(br'\ '): |
1469 if l.startswith(br'\ '): |
1472 # XXX: the only way to hit this is with an invalid line range. |
1470 # XXX: the only way to hit this is with an invalid line range. |
1473 # The no-eol marker is not counted in the line range, but I |
1471 # The no-eol marker is not counted in the line range, but I |
1474 # guess there are diff(1) out there which behave differently. |
1472 # guess there are diff(1) out there which behave differently. |
1545 fuzz = min(fuzz, len(old)) |
1543 fuzz = min(fuzz, len(old)) |
1546 if fuzz: |
1544 if fuzz: |
1547 top = 0 |
1545 top = 0 |
1548 bot = 0 |
1546 bot = 0 |
1549 hlen = len(self.hunk) |
1547 hlen = len(self.hunk) |
1550 for x in pycompat.xrange(hlen - 1): |
1548 for x in range(hlen - 1): |
1551 # the hunk starts with the @@ line, so use x+1 |
1549 # the hunk starts with the @@ line, so use x+1 |
1552 if self.hunk[x + 1].startswith(b' '): |
1550 if self.hunk[x + 1].startswith(b' '): |
1553 top += 1 |
1551 top += 1 |
1554 else: |
1552 else: |
1555 break |
1553 break |
1556 if not toponly: |
1554 if not toponly: |
1557 for x in pycompat.xrange(hlen - 1): |
1555 for x in range(hlen - 1): |
1558 if self.hunk[hlen - bot - 1].startswith(b' '): |
1556 if self.hunk[hlen - bot - 1].startswith(b' '): |
1559 bot += 1 |
1557 bot += 1 |
1560 else: |
1558 else: |
1561 break |
1559 break |
1562 |
1560 |