[meld] Fix support for auto-compare from the command line (bgo#785630)



commit c95c148ede9cb472ae4729a75c7a30acbb5df894
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Sep 30 08:05:13 2017 +1000

    Fix support for auto-compare from the command line (bgo#785630)
    
    This also (best I can recall) adds support for auto-compare for folder
    comparisons, which I'm reasonably sure never actually worked.
    
    The worst part of this patch is that it relies on the existing scheduler
    queuing to ensure that the initial comparison has finished before
    running the auto-compare code. This is "fine", except that it's just one
    more thing to go wrong if/when I finally get rid of the scheduler.

 meld/dirdiff.py    |    5 +++++
 meld/meldwindow.py |    5 ++---
 meld/vcview.py     |    7 +++++++
 3 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 6adfb39..d308a2d 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -1582,3 +1582,8 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
 
     def on_find_activate(self, *extra):
         self.focus_pane.emit("start-interactive-search")
+
+    def auto_compare(self):
+        modified_states = (tree.STATE_MODIFIED, tree.STATE_CONFLICT)
+        for it in self.model.state_rows(modified_states):
+            self.run_diff_from_iter(it)
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index ce9dbd8..b412a4d 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -574,9 +574,8 @@ class MeldWindow(gnomeglade.Component):
         doc = dirdiff.DirDiff(len(dirs))
         self._append_page(doc, "folder")
         doc.set_locations(dirs)
-        # FIXME: This doesn't work, as dirdiff behaves differently to vcview
         if auto_compare:
-            doc.on_button_diff_clicked(None)
+            doc.scheduler.add_task(doc.auto_compare)
         return doc
 
     def append_filediff(self, files, merge_output=None, meta=None):
@@ -622,7 +621,7 @@ class MeldWindow(gnomeglade.Component):
         location = location[0] if isinstance(location, list) else location
         doc.set_location(location)
         if auto_compare:
-            doc.on_button_diff_clicked(None)
+            doc.scheduler.add_task(doc.auto_compare)
         return doc
 
     def append_recent(self, uri):
diff --git a/meld/vcview.py b/meld/vcview.py
index a9f4066..b165f63 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -821,3 +821,10 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
 
     def on_find_activate(self, *extra):
         self.treeview.emit("start-interactive-search")
+
+    def auto_compare(self):
+        modified_states = (tree.STATE_MODIFIED, tree.STATE_CONFLICT)
+        for it in self.model.state_rows(modified_states):
+            row_paths = self.model.value_paths(it)
+            paths = [p for p in row_paths if os.path.exists(p)]
+            self.run_diff(paths[0])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]