[meld] Fix regression in three-way diffs and on-the-fly updates
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Fix regression in three-way diffs and on-the-fly updates
- Date: Sat, 14 Jul 2012 00:42:25 +0000 (UTC)
commit 9ca55149e22347b1fd83d581b096f23939bed83b
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Jul 14 10:36:43 2012 +1000
Fix regression in three-way diffs and on-the-fly updates
This commit fixes a regression in commit 92295b5 that caused three-way
diffs and on-the-fly updating to fail because they were synthesizing
new chunks, but not using the namedtuple representation.
Included in this fix is a small rework of some of the code in
Differ._change_sequence, being more explicit about what the various
loops are actually doing.
meld/diffutil.py | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/meld/diffutil.py b/meld/diffutil.py
index bf657bd..af6f3e2 100644
--- a/meld/diffutil.py
+++ b/meld/diffutil.py
@@ -238,13 +238,18 @@ class Differ(gobject.GObject):
linesx = texts[x][rangex[0]:rangex[1]]
lines1 = texts[1][range1[0]:range1[1]]
#print "<<<\n%s\n===\n%s\n>>>" % ("\n".join(linesx),"\n".join(lines1))
+
+ def offset(c, o1, o2):
+ return DiffChunk._make((c[0], c[1] + o1, c[2] + o1,
+ c[3] + o2, c[4] + o2))
+
newdiffs = self._matcher(None, lines1, linesx).get_difference_opcodes()
- newdiffs = [ (c[0], c[1]+range1[0],c[2]+range1[0], c[3]+rangex[0],c[4]+rangex[0]) for c in newdiffs]
+ newdiffs = [offset(c, range1[0], rangex[0]) for c in newdiffs]
+
if hiidx < len(self.diffs[which]):
- self.diffs[which][hiidx:] = [ (c[0],
- c[1] + lines_added[1], c[2] + lines_added[1],
- c[3] + lines_added[x], c[4] + lines_added[x])
- for c in self.diffs[which][hiidx:] ]
+ offset_diffs = [offset(c, lines_added[1], lines_added[x]) for c
+ in self.diffs[which][hiidx:]]
+ self.diffs[which][hiidx:] = offset_diffs
self.diffs[which][loidx:hiidx] = newdiffs
def _range_from_lines(self, textindex, lines):
@@ -336,8 +341,8 @@ class Differ(gobject.GObject):
tag = "insert"
else:
tag = "conflict"
- out0 = (tag, l1, h1, l0, h0)
- out1 = (tag, l1, h1, l2, h2)
+ out0 = DiffChunk._make((tag, l1, h1, l0, h0))
+ out1 = DiffChunk._make((tag, l1, h1, l2, h2))
yield out0, out1
def _merge_diffs(self, seq0, seq1, texts):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]