Show More
@@ -728,21 +728,19 b' class patchfile(object):' | |||
|
728 | 728 | h = h.getnormalized() |
|
729 | 729 | |
|
730 | 730 | # fast case first, no offsets, no fuzz |
|
731 | old, new = h.fuzzit(0, False) | |
|
732 |
|
|
|
733 | # zero length hunk ranges already have their start decremented | |
|
734 | if h.lena: | |
|
735 | start -= 1 | |
|
736 | orig_start = start | |
|
731 | old, oldstart, new, newstart = h.fuzzit(0, False) | |
|
732 | oldstart += self.offset | |
|
733 | orig_start = oldstart | |
|
737 | 734 | # if there's skew we want to emit the "(offset %d lines)" even |
|
738 | 735 | # when the hunk cleanly applies at start + skew, so skip the |
|
739 | 736 | # fast case code |
|
740 | if self.skew == 0 and diffhelpers.testhunk(old, self.lines, start) == 0: | |
|
737 | if (self.skew == 0 and | |
|
738 | diffhelpers.testhunk(old, self.lines, oldstart) == 0): | |
|
741 | 739 | if self.remove: |
|
742 | 740 | self.backend.unlink(self.fname) |
|
743 | 741 | else: |
|
744 |
self.lines[start |
|
|
745 |
self.offset += |
|
|
742 | self.lines[oldstart:oldstart + len(old)] = new | |
|
743 | self.offset += len(new) - len(old) | |
|
746 | 744 | self.dirty = True |
|
747 | 745 | return 0 |
|
748 | 746 | |
@@ -759,7 +757,7 b' class patchfile(object):' | |||
|
759 | 757 | |
|
760 | 758 | for fuzzlen in xrange(3): |
|
761 | 759 | for toponly in [True, False]: |
|
762 | old, new = h.fuzzit(fuzzlen, toponly) | |
|
760 | old, oldstart, new, newstart = h.fuzzit(fuzzlen, toponly) | |
|
763 | 761 | |
|
764 | 762 | cand = self.findlines(old[0][1:], search_start) |
|
765 | 763 | for l in cand: |
@@ -1004,11 +1002,19 b' class hunk(object):' | |||
|
1004 | 1002 | else: |
|
1005 | 1003 | top = min(fuzz, top) |
|
1006 | 1004 | |
|
1007 | return old[top:len(old)-bot], new[top:len(new)-bot] | |
|
1008 | return old, new | |
|
1005 | return old[top:len(old)-bot], new[top:len(new)-bot], top | |
|
1006 | return old, new, 0 | |
|
1009 | 1007 | |
|
1010 | 1008 | def fuzzit(self, fuzz, toponly): |
|
1011 |
|
|
|
1009 | old, new, top = self._fuzzit(self.a, self.b, fuzz, toponly) | |
|
1010 | oldstart = self.starta + top | |
|
1011 | newstart = self.startb + top | |
|
1012 | # zero length hunk ranges already have their start decremented | |
|
1013 | if self.lena: | |
|
1014 | oldstart -= 1 | |
|
1015 | if self.lenb: | |
|
1016 | newstart -= 1 | |
|
1017 | return old, oldstart, new, newstart | |
|
1012 | 1018 | |
|
1013 | 1019 | class binhunk(object): |
|
1014 | 1020 | 'A binary patch file. Only understands literals so far.' |
General Comments 0
You need to be logged in to leave comments.
Login now