/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 annotate/gannotate.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:
23
23
import pango
24
24
 
25
25
from bzrlib.errors import NoSuchRevision
26
 
from bzrlib.revision import NULL_REVISION
27
26
 
28
27
from colormap import AnnotateColorMap, AnnotateColorSaturation
29
28
from logview import LogView
59
58
 
60
59
    def annotate(self, branch, file_id):
61
60
        self.revisions = {}
62
 
        self.annotations = []
63
 
        self.branch = branch
64
 
        self.file_id = file_id
65
61
        
66
62
        # [revision id, line number, committer, revno, highlight color, line]
67
63
        self.annomodel = gtk.ListStore(gobject.TYPE_STRING,
93
89
                                       None,
94
90
                                       line.rstrip("\r\n")
95
91
                                      ])
96
 
                self.annotations.append(revision)
97
92
 
98
93
            if not self.plain:
99
94
                self._set_oldest_newest()
114
109
            # bar?
115
110
            print("gannotate: Line number %d does't exist. Defaulting to "
116
111
                  "line 1." % lineno)
117
 
            return
118
112
        else:
119
113
            row = lineno - 1
120
114
 
121
115
        self.annoview.set_cursor(row)
122
 
        self.annoview.scroll_to_cell(row, use_align=True)
123
116
 
124
117
    def _annotate(self, branch, file_id):
125
118
        rev_hist = branch.revision_history()
146
139
 
147
140
    def _set_oldest_newest(self):
148
141
        rev_dates = map(lambda i: self.revisions[i].timestamp, self.revisions)
149
 
        if len(rev_dates) == 0:
150
 
            return
151
142
        oldest = min(rev_dates)
152
143
        newest = max(rev_dates)
153
144
 
173
164
 
174
165
    def _show_log(self, w):
175
166
        (path, col) = self.annoview.get_cursor()
176
 
        if path is None:
177
 
            return
178
167
        rev_id = self.annomodel[path][REVISION_ID_COL]
179
168
        self.logview.set_revision(self.revisions[rev_id])
180
169
 
191
180
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
192
181
        sw.set_shadow_type(gtk.SHADOW_IN)
193
182
        sw.add(self.annoview)
194
 
        self.annoview.gwindow = self
195
183
        sw.show()
196
184
        
197
185
        self.pane = pane = gtk.VPaned()
208
196
 
209
197
        self.add(vbox)
210
198
 
211
 
    def row_diff(self, tv, path, tvc):
212
 
        row = path[0]
213
 
        revision = self.annotations[row]
214
 
        repository = self.branch.repository
215
 
        tree1 = repository.revision_tree(revision.revision_id)
216
 
        if len(revision.parent_ids) > 0:
217
 
            tree2 = repository.revision_tree(revision.parent_ids[0])
218
 
        else:
219
 
            tree2 = repository.revision_tree(NULL_REVISION)
220
 
        from bzrlib.plugins.gtk.viz.diffwin import DiffWindow
221
 
        window = DiffWindow()
222
 
        window.set_diff("Diff for row %d" % (row+1), tree1, tree2)
223
 
        window.set_file(tree1.id2path(self.file_id))
224
 
        window.show()
225
 
 
226
 
 
227
199
    def _create_annotate_view(self):
228
200
        tv = gtk.TreeView()
229
201
        tv.set_rules_hint(False)
230
202
        tv.connect("cursor-changed", self._show_log)
231
203
        tv.show()
232
 
        tv.connect("row-activated", self.row_diff)
233
204
 
234
205
        cell = gtk.CellRendererText()
235
206
        cell.set_property("xalign", 1.0)