[meld] Fix chunk-offset logic to deal with None chunks in three-way merges
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Fix chunk-offset logic to deal with None chunks in three-way merges
- Date: Sun, 14 Oct 2012 21:59:38 +0000 (UTC)
commit fc7f372a9e1ef3fcb6fe5221ef96654f754660b0
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Jul 21 07:34:05 2012 +1000
Fix chunk-offset logic to deal with None chunks in three-way merges
In three-way merges we can have a merged chunk that contains None on
one side, indicating that e.g., the left and middle chunks are
identical, while the middle and right chunks differ. This commit fixes
the recently modified change_sequence logic to handle None chunks.
meld/diffutil.py | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/meld/diffutil.py b/meld/diffutil.py
index 9f7c3ed..67e8174 100644
--- a/meld/diffutil.py
+++ b/meld/diffutil.py
@@ -188,6 +188,8 @@ class Differ(gobject.GObject):
def offset(c, start, o1, o2):
"""Offset a chunk by o1/o2 if it's after the inserted lines"""
+ if c is None:
+ return None
start_a = c.start_a + (o1 if c.start_a > start else 0)
end_a = c.end_a + (o1 if c.end_a > start else 0)
start_b = c.start_b + (o2 if c.start_b > start else 0)
@@ -200,17 +202,17 @@ class Differ(gobject.GObject):
self._changed_chunks = tuple()
chunk_changed = False
for (c1, c2) in self._merge_cache:
- print c1, c2
if sequence == 0:
- if c1.start_b <= startidx < c1.end_b:
+ if c1 and c1.start_b <= startidx < c1.end_b:
chunk_changed = True
c1 = offset(c1, startidx, 0, sizechange)
elif sequence == 2:
- if c2.start_b <= startidx < c2.end_b:
+ if c2 and c2.start_b <= startidx < c2.end_b:
chunk_changed = True
c2 = offset(c2, startidx, 0, sizechange)
- else: # sequence == 1
- if c1.start_a <= startidx < c1.end_a:
+ else:
+ # Middle sequence changes alter both chunks
+ if c1 and c1.start_a <= startidx < c1.end_a:
chunk_changed = True
c1 = offset(c1, startidx, sizechange, 0)
if self.num_sequences == 3:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]