/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to viz/diffwin.py

  • Committer: Jelmer Vernooij
  • Date: 2006-05-19 16:56:46 UTC
  • mfrom: (0.1.25 gannotate)
  • Revision ID: jelmer@samba.org-20060519165646-0d867938fdbc9097
Merge in Dan Loda's gannotate plugin and put it in annotate/

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
except ImportError:
22
22
    have_gtksourceview = False
23
23
 
24
 
import bzrlib
25
 
if bzrlib.version_info < (0, 9):
26
 
    # function deprecated in 0.9
27
 
    from bzrlib.delta import compare_trees
28
 
 
 
24
from bzrlib.delta import compare_trees
29
25
from bzrlib.diff import show_diff_trees
30
 
from bzrlib.errors import NoSuchFile
31
26
 
32
27
 
33
28
class DiffWindow(gtk.Window):
37
32
    differences between two revisions on a branch.
38
33
    """
39
34
 
40
 
    def __init__(self):
 
35
    def __init__(self, app=None):
41
36
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
42
37
        self.set_border_width(0)
43
38
        self.set_title("bzrk diff")
44
39
 
 
40
        self.app = app
 
41
 
45
42
        # Use two thirds of the screen by default
46
43
        screen = self.get_screen()
47
44
        monitor = screen.get_monitor_geometry(0)
54
51
    def construct(self):
55
52
        """Construct the window contents."""
56
53
        hbox = gtk.HBox(spacing=6)
57
 
        hbox.set_border_width(0)
 
54
        hbox.set_border_width(12)
58
55
        self.add(hbox)
59
56
        hbox.show()
60
57
 
103
100
        scrollwin.add(sourceview)
104
101
        sourceview.show()
105
102
 
106
 
    def set_diff(self, description, rev_tree, parent_tree):
 
103
    def set_diff(self, branch, revid, parentid):
107
104
        """Set the differences showed by this window.
108
105
 
109
106
        Compares the two trees and populates the window with the
110
107
        differences.
111
108
        """
112
 
        self.rev_tree = rev_tree
113
 
        self.parent_tree = parent_tree
 
109
        self.rev_tree = branch.repository.revision_tree(revid)
 
110
        self.parent_tree = branch.repository.revision_tree(parentid)
114
111
 
115
112
        self.model.clear()
116
 
        if bzrlib.version_info < (0, 9):
117
 
            delta = compare_trees(self.parent_tree, self.rev_tree)
118
 
        else:
119
 
            delta = self.rev_tree.changes_from(self.parent_tree)
 
113
        delta = compare_trees(self.parent_tree, self.rev_tree)
120
114
 
121
115
        self.model.append(None, [ "Complete Diff", "" ])
122
116
 
134
128
            titer = self.model.append(None, [ "Renamed", None ])
135
129
            for oldpath, newpath, id, kind, text_modified, meta_modified \
136
130
                    in delta.renamed:
137
 
                self.model.append(titer, [ oldpath, newpath ])
 
131
                self.model.append(titer, [ oldpath, oldpath ])
138
132
 
139
133
        if len(delta.modified):
140
134
            titer = self.model.append(None, [ "Modified", None ])
142
136
                self.model.append(titer, [ path, path ])
143
137
 
144
138
        self.treeview.expand_all()
145
 
        self.set_title(description + " - bzrk diff")
146
 
 
147
 
    def set_file(self, file_path):
148
 
        tv_path = None
149
 
        for data in self.model:
150
 
            for child in data.iterchildren():
151
 
                if child[0] == file_path or child[1] == file_path:
152
 
                    tv_path = child.path
153
 
                    break
154
 
        if tv_path is None:
155
 
            raise NoSuchFile(file_path)
156
 
        self.treeview.set_cursor(tv_path)
157
 
        self.treeview.scroll_to_cell(tv_path)
 
139
        self.set_title(revid + " - " + branch.nick + " - bzrk diff")
158
140
 
159
141
    def _treeview_cursor_cb(self, *args):
160
142
        """Callback for when the treeview cursor changes."""