[meld] Add Differ API for checking whether diffs include non-conflict chunks
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Add Differ API for checking whether diffs include non-conflict chunks
- Date: Sat, 19 Jun 2010 02:36:52 +0000 (UTC)
commit a5e31634e2591cb5d79746d99baf3f1b82dfbf78
Author: Kai Willadsen <kai willadsen gmail com>
Date: Mon May 17 17:40:22 2010 +1000
Add Differ API for checking whether diffs include non-conflict chunks
For sensitivity setting of (upcoming) merge-all actions, we need to know
whether a given pair of sequences have mergeable (i.e., non-conflicting)
changes. This commit adds the necessary API to the Differ class.
meld/diffutil.py | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/meld/diffutil.py b/meld/diffutil.py
index b1d4c7b..0533e05 100644
--- a/meld/diffutil.py
+++ b/meld/diffutil.py
@@ -86,6 +86,7 @@ class Differ(gobject.GObject):
self._line_cache = [[], [], []]
self.ignore_blanks = False
self._initialised = False
+ self._has_mergeable_changes = (False, False)
def _update_merge_cache(self, texts):
if self.num_sequences == 3:
@@ -101,6 +102,14 @@ class Differ(gobject.GObject):
self._consume_blank_lines(c[1], texts, 1, 2))
self._merge_cache = [x for x in self._merge_cache if x != (None, None)]
+ mergeable0, mergeable1 = False, False
+ for (c0, c1) in self._merge_cache:
+ mergeable0 = mergeable0 or (c0 and c0[0] != 'conflict')
+ mergeable1 = mergeable1 or (c1 and c1[0] != 'conflict')
+ if mergeable0 and mergeable1:
+ break
+ self._has_mergeable_changes = (mergeable0, mergeable1)
+
self._update_line_cache()
self.emit("diffs-changed")
@@ -219,6 +228,17 @@ class Differ(gobject.GObject):
def diff_count(self):
return len(self._merge_cache)
+ def has_mergeable_changes(self, which):
+ if which == 0:
+ return (False, self._has_mergeable_changes[0])
+ elif which == 1:
+ if self.num_sequences == 2:
+ return (self._has_mergeable_changes[0], False)
+ else:
+ return self._has_mergeable_changes
+ else: # which == 2
+ return (self._has_mergeable_changes[1], False)
+
def _change_sequence(self, which, sequence, startidx, sizechange, texts):
diffs = self.diffs[which]
lines_added = [0,0,0]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]