[meld] Add kwargs to create-diff signal and use to specify merge output



commit a87cab9eef253d4e9f0594de92fab6e914402ab5
Author: Louis des Landes <louis obsidian com au>
Date:   Thu Mar 7 12:45:59 2013 +1100

    Add kwargs to create-diff signal and use to specify merge output

 meld/dirdiff.py    |    5 +++--
 meld/melddoc.py    |    3 ++-
 meld/meldwindow.py |   15 ++++++++++-----
 meld/vcview.py     |    6 +++---
 4 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index af53384..ff1a0d0 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -981,7 +981,8 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
         if not rows[pane]:
             return
         if os.path.isfile(rows[pane]):
-            self.emit("create-diff", [r for r in rows if os.path.isfile(r)])
+            self.emit("create-diff", [r for r in rows if os.path.isfile(r)],
+                      {})
         elif os.path.isdir(rows[pane]):
             if view.row_expanded(path):
                 view.collapse_row(path)
@@ -1023,7 +1024,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
         for row in selected:
             row_paths = self.model.value_paths(self.model.get_iter(row))
             paths = [p for p in row_paths if os.path.exists(p)]
-            self.emit("create-diff", paths)
+            self.emit("create-diff", paths, {})
 
     def on_button_copy_left_clicked(self, button):
         self.copy_selected(-1)
diff --git a/meld/melddoc.py b/meld/melddoc.py
index 7414e6a..04bab52 100644
--- a/meld/melddoc.py
+++ b/meld/melddoc.py
@@ -40,7 +40,8 @@ class MeldDoc(gobject.GObject):
         'file-changed':         (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
                                  (gobject.TYPE_STRING,)),
         'create-diff':          (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
-                                 (gobject.TYPE_PYOBJECT,)),
+                                 (gobject.TYPE_PYOBJECT,
+                                  gobject.TYPE_PYOBJECT)),
         'status-changed':       (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
                                  (gobject.TYPE_PYOBJECT,)),
         'current-diff-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index 57f88dc..5f356f6 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -592,7 +592,8 @@ class MeldWindow(gnomeglade.Component):
         if isinstance(page, melddoc.MeldDoc):
             page.connect("label-changed", self.on_notebook_label_changed)
             page.connect("file-changed", self.on_file_changed)
-            page.connect("create-diff", lambda obj, arg: self.append_diff(arg))
+            page.connect("create-diff", lambda obj, arg, kwargs:
+                         self.append_diff(arg, **kwargs))
             page.connect("status-changed",
                          lambda obj, arg: self.statusbar.set_doc_status(arg))
 
@@ -628,14 +629,17 @@ class MeldWindow(gnomeglade.Component):
         doc.set_files(files)
         return doc
 
-    def append_filemerge(self, files):
+    def append_filemerge(self, files, merge_output=None):
         assert len(files) == 3
         doc = filemerge.FileMerge(app.prefs, len(files))
         self._append_page(doc, "text-x-generic")
         doc.set_files(files)
+        if merge_output is not None:
+            doc.set_merge_output_file(merge_output)
         return doc
 
-    def append_diff(self, paths, auto_compare=False, auto_merge=False):
+    def append_diff(self, paths, auto_compare=False, auto_merge=False,
+                    merge_output=None):
         dirslist = [p for p in paths if os.path.isdir(p)]
         fileslist = [p for p in paths if os.path.isfile(p)]
         if dirslist and fileslist:
@@ -660,7 +664,7 @@ class MeldWindow(gnomeglade.Component):
         elif dirslist:
             return self.append_dirdiff(paths, auto_compare)
         elif auto_merge:
-            return self.append_filemerge(paths)
+            return self.append_filemerge(paths, merge_output=merge_output)
         else:
             return self.append_filediff(paths)
 
@@ -696,7 +700,8 @@ class MeldWindow(gnomeglade.Component):
         self.scheduler.add_scheduler(doc.scheduler)
         path = os.path.abspath(path)
         doc.set_location(path)
-        doc.connect("create-diff", lambda obj,arg: self.append_diff(arg))
+        doc.connect("create-diff", lambda obj, arg, kwargs:
+                    self.append_diff(arg, **kwargs))
         doc.run_diff([path])
 
     def open_paths(self, paths, auto_compare=False, auto_merge=False):
diff --git a/meld/vcview.py b/meld/vcview.py
index 019cd39..0044ac5 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -460,7 +460,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
                     retry_diff = True
             else:
                 for path in path_list:
-                    self.emit("create-diff", [path])
+                    self.emit("create-diff", [path], {})
 
     def run_diff(self, path_list):
         try:
@@ -468,7 +468,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
                 comp_path = self.vc.get_path_for_repo_file(path)
                 os.chmod(comp_path, 0o444)
                 _temp_files.append(comp_path)
-                self.emit("create-diff", [comp_path, path])
+                self.emit("create-diff", [comp_path, path], {})
         except NotImplementedError:
             for path in path_list:
                 self.scheduler.add_task(self.run_diff_iter([path]), atfront=1)
@@ -648,7 +648,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         if result == 0:
             for d in diffs:
                 os.chmod(d[0], 0o444)
-                self.emit("create-diff", d)
+                self.emit("create-diff", d, {})
             return True
         elif not silent:
             primary = _("Error fetching original comparison file")


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