equal
deleted
inserted
replaced
813 # ok, we couldn't match the hunk. Lets look for offsets and fuzz it |
813 # ok, we couldn't match the hunk. Lets look for offsets and fuzz it |
814 self.hash = {} |
814 self.hash = {} |
815 for x, s in enumerate(self.lines): |
815 for x, s in enumerate(self.lines): |
816 self.hash.setdefault(s, []).append(x) |
816 self.hash.setdefault(s, []).append(x) |
817 |
817 |
818 for fuzzlen in xrange(self.ui.configint("patch", "fuzz") + 1): |
818 for fuzzlen in pycompat.xrange(self.ui.configint("patch", "fuzz") + 1): |
819 for toponly in [True, False]: |
819 for toponly in [True, False]: |
820 old, oldstart, new, newstart = h.fuzzit(fuzzlen, toponly) |
820 old, oldstart, new, newstart = h.fuzzit(fuzzlen, toponly) |
821 oldstart = oldstart + self.offset + self.skew |
821 oldstart = oldstart + self.offset + self.skew |
822 oldstart = min(oldstart, len(self.lines)) |
822 oldstart = min(oldstart, len(self.lines)) |
823 if old: |
823 if old: |
1284 if aend is None: |
1284 if aend is None: |
1285 aend = self.starta |
1285 aend = self.starta |
1286 self.lena = int(aend) - self.starta |
1286 self.lena = int(aend) - self.starta |
1287 if self.starta: |
1287 if self.starta: |
1288 self.lena += 1 |
1288 self.lena += 1 |
1289 for x in xrange(self.lena): |
1289 for x in pycompat.xrange(self.lena): |
1290 l = lr.readline() |
1290 l = lr.readline() |
1291 if l.startswith('---'): |
1291 if l.startswith('---'): |
1292 # lines addition, old block is empty |
1292 # lines addition, old block is empty |
1293 lr.push(l) |
1293 lr.push(l) |
1294 break |
1294 break |
1318 bend = self.startb |
1318 bend = self.startb |
1319 self.lenb = int(bend) - self.startb |
1319 self.lenb = int(bend) - self.startb |
1320 if self.startb: |
1320 if self.startb: |
1321 self.lenb += 1 |
1321 self.lenb += 1 |
1322 hunki = 1 |
1322 hunki = 1 |
1323 for x in xrange(self.lenb): |
1323 for x in pycompat.xrange(self.lenb): |
1324 l = lr.readline() |
1324 l = lr.readline() |
1325 if l.startswith('\ '): |
1325 if l.startswith('\ '): |
1326 # XXX: the only way to hit this is with an invalid line range. |
1326 # XXX: the only way to hit this is with an invalid line range. |
1327 # The no-eol marker is not counted in the line range, but I |
1327 # The no-eol marker is not counted in the line range, but I |
1328 # guess there are diff(1) out there which behave differently. |
1328 # guess there are diff(1) out there which behave differently. |
1394 fuzz = min(fuzz, len(old)) |
1394 fuzz = min(fuzz, len(old)) |
1395 if fuzz: |
1395 if fuzz: |
1396 top = 0 |
1396 top = 0 |
1397 bot = 0 |
1397 bot = 0 |
1398 hlen = len(self.hunk) |
1398 hlen = len(self.hunk) |
1399 for x in xrange(hlen - 1): |
1399 for x in pycompat.xrange(hlen - 1): |
1400 # the hunk starts with the @@ line, so use x+1 |
1400 # the hunk starts with the @@ line, so use x+1 |
1401 if self.hunk[x + 1].startswith(' '): |
1401 if self.hunk[x + 1].startswith(' '): |
1402 top += 1 |
1402 top += 1 |
1403 else: |
1403 else: |
1404 break |
1404 break |
1405 if not toponly: |
1405 if not toponly: |
1406 for x in xrange(hlen - 1): |
1406 for x in pycompat.xrange(hlen - 1): |
1407 if self.hunk[hlen - bot - 1].startswith(' '): |
1407 if self.hunk[hlen - bot - 1].startswith(' '): |
1408 bot += 1 |
1408 bot += 1 |
1409 else: |
1409 else: |
1410 break |
1410 break |
1411 |
1411 |