[Pkg-bazaar-commits] ./bzr-gtk/unstable r426: Start support for Merge Directives

Aaron Bentley aaron at aaronbentley.com
Fri Apr 10 07:44:56 UTC 2009


------------------------------------------------------------
revno: 426
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: bzr-gtk-meld
timestamp: Mon 2008-01-14 00:12:30 -0500
message:
  Start support for Merge Directives
modified:
  __init__.py
  diff.py
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2008-01-14 04:21:45 +0000
+++ b/__init__.py	2008-01-14 05:12:30 +0000
@@ -77,6 +77,7 @@
     branch,
     builtins,
     errors,
+    merge_directive,
     workingtree,
     )
 """)
@@ -679,7 +680,13 @@
     def run(self, path):
         from bzrlib.plugins.gtk.diff import DiffWindow
         window = DiffWindow()
-        window.set_diff_text(path, open(path, 'rb').read())
+        lines = open(path, 'rb').readlines()
+        try:
+            directive = merge_directive.MergeDirective.from_lines(lines)
+        except errors.NotAMergeDirective:
+            window.set_diff_text(path, lines)
+        else:
+            window.set_diff_text(path, directive.patch.splitlines(True))
         window.show()
         gtk = self.open_display()
         window.connect("destroy", gtk.main_quit)

=== modified file 'diff.py'
--- a/diff.py	2008-01-14 04:20:46 +0000
+++ b/diff.py	2008-01-14 05:12:30 +0000
@@ -33,6 +33,7 @@
 from bzrlib import osutils
 from bzrlib.diff import show_diff_trees, internal_diff
 from bzrlib.errors import NoSuchFile
+from bzrlib.patches import parse_patches
 from bzrlib.trace import warning
 from bzrlib.plugins.gtk.window import Window
 
@@ -234,7 +235,13 @@
 #            self.parent_tree.unlock()
 
     def show_diff(self, specific_files):
-        self.buffer.set_text(self._diffs[None])
+        sections = []
+        if specific_files is None:
+            self.buffer.set_text(self._diffs[None])
+        else:
+            for specific_file in specific_files:
+                sections.append(self._diffs[specific_file])
+            self.buffer.set_text(''.join(sections))
 
 
 class DiffView(DiffFileView):
@@ -322,14 +329,19 @@
         column.add_attribute(cell, "text", 0)
         self.treeview.append_column(column)
 
-    def set_diff_text(self, description, text):
+    def set_diff_text(self, description, lines):
         # The diffs of the  selected file: a scrollable source or
         # text view
         self.diff_view = DiffFileView()
         self.diff_view.show()
         self.pane.pack2(self.diff_view)
         self.model.append(None, [ "Complete Diff", "" ])
-        self.diff_view._diffs[None] = text
+        self.diff_view._diffs[None] = ''.join(lines)
+        for patch in parse_patches(lines):
+            oldname = patch.oldname.split('\t')[0]
+            newname = patch.newname.split('\t')[0]
+            self.model.append(None, [oldname, newname])
+            self.diff_view._diffs[newname] = str(patch)
         
 
     def set_diff(self, description, rev_tree, parent_tree):



More information about the Pkg-bazaar-commits mailing list