[meld] Open conflicted files in a 3 way auto merge.



commit 77f0d1e86822758539571e7c116355d0ae8d9c4c
Author: Louis des Landes <louis obsidian com au>
Date:   Thu Mar 7 12:49:54 2013 +1100

    Open conflicted files in a 3 way auto merge.

 meld/vcview.py |   34 ++++++++++++++++++++++++++++++----
 1 files changed, 30 insertions(+), 4 deletions(-)
---
diff --git a/meld/vcview.py b/meld/vcview.py
index 0044ac5..48d0bf9 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -465,10 +465,36 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
     def run_diff(self, path_list):
         try:
             for path in path_list:
-                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], {})
+                kwargs = {}
+                status = self.vc._get_tree_cache(path).get(path, None)
+                if status == tree.STATE_CONFLICT:
+                    # We use auto merge, so we create a new temp file
+                    # for other, base and this, then set the output to
+                    # the current file.
+                    file1 = self.vc.get_path_for_conflict(
+                                path, conflict=tree.CONFLICT_OTHER)
+                    file2 = self.vc.get_path_for_conflict(
+                                path, conflict=tree.CONFLICT_BASE)
+                    file3 = self.vc.get_path_for_conflict(
+                                path, conflict=tree.CONFLICT_THIS)
+                    os.chmod(file1, 0o444)
+                    os.chmod(file2, 0o444)
+                    os.chmod(file3, 0o444)
+                    _temp_files.append(file1)
+                    _temp_files.append(file2)
+                    _temp_files.append(file3)
+
+                    diffs = [file1, file2, file3]
+                    # If we want to use auto-merge or use the merged
+                    # output given by the VCS
+                    kwargs['auto_merge'] = False
+                    kwargs['merge_output'] = path
+                else:
+                    file1 = self.vc.get_path_for_repo_file(path)
+                    os.chmod(file1, 0o444)
+                    _temp_files.append(file1)
+                    diffs = [file1, path]
+                self.emit("create-diff", diffs, kwargs)
         except NotImplementedError:
             for path in path_list:
                 self.scheduler.add_task(self.run_diff_iter([path]), atfront=1)


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