Show More
@@ -240,6 +240,7 b' static void recurse(struct line *a, stru' | |||||
240 | static struct hunklist diff(struct line *a, int an, struct line *b, int bn) |
|
240 | static struct hunklist diff(struct line *a, int an, struct line *b, int bn) | |
241 | { |
|
241 | { | |
242 | struct hunklist l; |
|
242 | struct hunklist l; | |
|
243 | struct hunk *curr; | |||
243 | struct pos *pos; |
|
244 | struct pos *pos; | |
244 | int t; |
|
245 | int t; | |
245 |
|
246 | |||
@@ -259,6 +260,30 b' static struct hunklist diff(struct line ' | |||||
259 | } |
|
260 | } | |
260 |
|
261 | |||
261 | free(pos); |
|
262 | free(pos); | |
|
263 | ||||
|
264 | for (curr = l.base; curr != l.head; curr++) { | |||
|
265 | struct hunk *next = curr+1; | |||
|
266 | int shift = 0; | |||
|
267 | ||||
|
268 | if (next == l.head) | |||
|
269 | break; | |||
|
270 | ||||
|
271 | if (curr->a2 == next->a1) | |||
|
272 | while (curr->a2+shift < an && curr->b2+shift < bn | |||
|
273 | && !cmp(a+curr->a2+shift, b+curr->b2+shift)) | |||
|
274 | shift++; | |||
|
275 | else if (curr->b2 == next->b1) | |||
|
276 | while (curr->b2+shift < bn && curr->a2+shift < an | |||
|
277 | && !cmp(b+curr->b2+shift, a+curr->a2+shift)) | |||
|
278 | shift++; | |||
|
279 | if (!shift) | |||
|
280 | continue; | |||
|
281 | curr->b2 += shift; | |||
|
282 | next->b1 += shift; | |||
|
283 | curr->a2 += shift; | |||
|
284 | next->a1 += shift; | |||
|
285 | } | |||
|
286 | ||||
262 | return l; |
|
287 | return l; | |
263 | } |
|
288 | } | |
264 |
|
289 |
@@ -1,6 +1,6 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 |
|
2 | |||
3 | import sys |
|
3 | import sys, struct | |
4 | from mercurial import bdiff, mpatch |
|
4 | from mercurial import bdiff, mpatch | |
5 |
|
5 | |||
6 | def test1(a, b): |
|
6 | def test1(a, b): | |
@@ -39,4 +39,16 b' test("abc", "abc")' | |||||
39 | test("a\n", "a\n") |
|
39 | test("a\n", "a\n") | |
40 | test("a\nb", "a\nb") |
|
40 | test("a\nb", "a\nb") | |
41 |
|
41 | |||
|
42 | #issue1295 | |||
|
43 | def showdiff(a, b): | |||
|
44 | bin = bdiff.bdiff(a, b) | |||
|
45 | pos = 0 | |||
|
46 | while pos < len(bin): | |||
|
47 | p1, p2, l = struct.unpack(">lll", bin[pos:pos + 12]) | |||
|
48 | pos += 12 | |||
|
49 | print p1, p2, repr(bin[pos:pos + l]) | |||
|
50 | pos += l | |||
|
51 | showdiff("x\n\nx\n\nx\n\nx\n\nz\n", "x\n\nx\n\ny\n\nx\n\nx\n\nz\n") | |||
|
52 | showdiff("x\n\nx\n\nx\n\nx\n\nz\n", "x\n\nx\n\ny\n\nx\n\ny\n\nx\n\nz\n") | |||
|
53 | ||||
42 | print "done" |
|
54 | print "done" |
General Comments 0
You need to be logged in to leave comments.
Login now