/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 branchview/treeview.py

  • Committer: Jelmer Vernooij
  • Date: 2012-07-09 15:23:26 UTC
  • mto: This revision was merged to the branch mainline in revision 794.
  • Revision ID: jelmer@samba.org-20120709152326-dzxb8zoz0btull7n
Remove bzr-notify.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
__copyright__ = "Copyright © 2005 Canonical Ltd."
7
7
__author__    = "Daniel Schierbeck <daniel.schierbeck@gmail.com>"
8
8
 
9
 
import sys
10
 
import string
11
 
import gtk
12
 
import gobject
13
 
import pango
14
 
import re
15
 
import treemodel
 
9
from gi.repository import Gtk
 
10
from gi.repository import GObject
 
11
from gi.repository import Pango
 
12
 
16
13
from bzrlib import ui
17
 
 
18
 
from bzrlib.plugins.gtk import _i18n
19
 
from linegraph import linegraph, same_branch
20
 
from graphcell import CellRendererGraph
21
 
from treemodel import TreeModel
22
14
from bzrlib.revision import NULL_REVISION
23
15
 
24
 
class TreeView(gtk.VBox):
 
16
from bzrlib.plugins.gtk import lock
 
17
from bzrlib.plugins.gtk.ui import ProgressPanel
 
18
from bzrlib.plugins.gtk.branchview import treemodel
 
19
from bzrlib.plugins.gtk.branchview.linegraph import linegraph, same_branch
 
20
from bzrlib.plugins.gtk.branchview.graphcell import CellRendererGraph
 
21
 
 
22
 
 
23
class TreeView(Gtk.VBox):
25
24
 
26
25
    __gproperties__ = {
27
 
        'branch': (gobject.TYPE_PYOBJECT,
 
26
        'branch': (GObject.TYPE_PYOBJECT,
28
27
                   'Branch',
29
28
                   'The Bazaar branch being visualized',
30
 
                   gobject.PARAM_CONSTRUCT_ONLY | gobject.PARAM_WRITABLE),
 
29
                   GObject.PARAM_CONSTRUCT_ONLY | GObject.PARAM_WRITABLE),
31
30
 
32
 
        'revision': (gobject.TYPE_PYOBJECT,
 
31
        'revision': (GObject.TYPE_PYOBJECT,
33
32
                     'Revision',
34
33
                     'The currently selected revision',
35
 
                     gobject.PARAM_READWRITE),
 
34
                     GObject.PARAM_READWRITE),
36
35
 
37
 
        'revision-number': (gobject.TYPE_STRING,
 
36
        'revision-number': (GObject.TYPE_STRING,
38
37
                            'Revision number',
39
38
                            'The number of the selected revision',
40
39
                            '',
41
 
                            gobject.PARAM_READABLE),
 
40
                            GObject.PARAM_READABLE),
42
41
 
43
 
        'children': (gobject.TYPE_PYOBJECT,
 
42
        'children': (GObject.TYPE_PYOBJECT,
44
43
                     'Child revisions',
45
44
                     'Children of the currently selected revision',
46
 
                     gobject.PARAM_READABLE),
 
45
                     GObject.PARAM_READABLE),
47
46
 
48
 
        'parents': (gobject.TYPE_PYOBJECT,
 
47
        'parents': (GObject.TYPE_PYOBJECT,
49
48
                    'Parent revisions',
50
49
                    'Parents to the currently selected revision',
51
 
                    gobject.PARAM_READABLE),
 
50
                    GObject.PARAM_READABLE),
52
51
 
53
 
        'revno-column-visible': (gobject.TYPE_BOOLEAN,
 
52
        'revno-column-visible': (GObject.TYPE_BOOLEAN,
54
53
                                 'Revision number column',
55
54
                                 'Show revision number column',
56
55
                                 True,
57
 
                                 gobject.PARAM_READWRITE),
 
56
                                 GObject.PARAM_READWRITE),
58
57
 
59
 
        'graph-column-visible': (gobject.TYPE_BOOLEAN,
 
58
        'graph-column-visible': (GObject.TYPE_BOOLEAN,
60
59
                                 'Graph column',
61
60
                                 'Show graph column',
62
61
                                 True,
63
 
                                 gobject.PARAM_READWRITE),
 
62
                                 GObject.PARAM_READWRITE),
64
63
 
65
 
        'date-column-visible': (gobject.TYPE_BOOLEAN,
 
64
        'date-column-visible': (GObject.TYPE_BOOLEAN,
66
65
                                 'Date',
67
66
                                 'Show date column',
68
67
                                 False,
69
 
                                 gobject.PARAM_READWRITE),
 
68
                                 GObject.PARAM_READWRITE),
70
69
 
71
 
        'compact': (gobject.TYPE_BOOLEAN,
 
70
        'compact': (GObject.TYPE_BOOLEAN,
72
71
                    'Compact view',
73
72
                    'Break ancestry lines to save space',
74
73
                    True,
75
 
                    gobject.PARAM_CONSTRUCT | gobject.PARAM_READWRITE),
 
74
                    GObject.PARAM_CONSTRUCT | GObject.PARAM_READWRITE),
76
75
 
77
 
        'mainline-only': (gobject.TYPE_BOOLEAN,
 
76
        'mainline-only': (GObject.TYPE_BOOLEAN,
78
77
                    'Mainline only',
79
78
                    'Only show the mainline history.',
80
79
                    False,
81
 
                    gobject.PARAM_CONSTRUCT | gobject.PARAM_READWRITE),
 
80
                    GObject.PARAM_CONSTRUCT | GObject.PARAM_READWRITE),
82
81
 
83
82
    }
84
83
 
85
84
    __gsignals__ = {
86
 
        'revision-selected': (gobject.SIGNAL_RUN_FIRST,
87
 
                              gobject.TYPE_NONE,
 
85
        'revision-selected': (GObject.SignalFlags.RUN_FIRST,
 
86
                              None,
88
87
                              ()),
89
 
        'revision-activated': (gobject.SIGNAL_RUN_FIRST,
90
 
                              gobject.TYPE_NONE,
91
 
                              (gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT)),
92
 
        'tag-added': (gobject.SIGNAL_RUN_FIRST,
93
 
                              gobject.TYPE_NONE,
94
 
                              (gobject.TYPE_STRING, gobject.TYPE_STRING))
 
88
        'revision-activated': (GObject.SignalFlags.RUN_FIRST,
 
89
                              None,
 
90
                              (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT)),
 
91
        'tag-added': (GObject.SignalFlags.RUN_FIRST,
 
92
                              None,
 
93
                              (GObject.TYPE_STRING, GObject.TYPE_STRING)),
 
94
        'refreshed': (GObject.SignalFlags.RUN_FIRST, None,
 
95
                              ())
95
96
    }
96
97
 
97
98
    def __init__(self, branch, start, maxnum, compact=True):
104
105
        :param broken_line_length: After how much lines to break 
105
106
                                   branches.
106
107
        """
107
 
        gtk.VBox.__init__(self, spacing=0)
108
 
 
109
 
        self.scrolled_window = gtk.ScrolledWindow()
110
 
        self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
111
 
                                        gtk.POLICY_AUTOMATIC)
112
 
        self.scrolled_window.set_shadow_type(gtk.SHADOW_IN)
 
108
        super(TreeView, self).__init__(homogeneous=False, spacing=0)
 
109
 
 
110
        self.progress_widget = ProgressPanel()
 
111
        self.pack_start(self.progress_widget, False, True, 0)
 
112
        if getattr(ui.ui_factory, "set_progress_bar_widget", None) is not None:
 
113
            # We'are using our own ui, let's tell it to use our widget.
 
114
            ui.ui_factory.set_progress_bar_widget(self.progress_widget)
 
115
 
 
116
        self.scrolled_window = Gtk.ScrolledWindow()
 
117
        self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
 
118
                                        Gtk.PolicyType.AUTOMATIC)
 
119
        self.scrolled_window.set_shadow_type(Gtk.ShadowType.IN)
113
120
        self.scrolled_window.show()
114
 
        self.pack_start(self.scrolled_window, expand=True, fill=True)
 
121
        self.pack_start(self.scrolled_window, True, True, 0)
115
122
 
116
123
        self.scrolled_window.add(self.construct_treeview())
117
124
 
118
 
        self.iter = None
 
125
        self.path = None
119
126
        self.branch = branch
120
127
        self.revision = None
 
128
        self.index = {}
121
129
 
122
130
        self.start = start
123
131
        self.maxnum = maxnum
124
132
        self.compact = compact
125
133
 
126
 
        gobject.idle_add(self.populate)
127
 
 
128
 
        self.connect("destroy", lambda x: self.branch.unlock())
 
134
        self.model = treemodel.BranchTreeModel(self.branch, [])
 
135
        GObject.idle_add(self.populate)
 
136
 
 
137
        self.connect("destroy", self._on_destroy)
 
138
 
 
139
    def _on_destroy(self, *ignored):
 
140
        self.branch.unlock()
 
141
        if getattr(ui.ui_factory, "set_progress_bar_widget", None) is not None:
 
142
            # We'are using our own ui, let's tell it to stop using our widget.
 
143
            ui.ui_factory.set_progress_bar_widget(None)
129
144
 
130
145
    def do_get_property(self, property):
131
146
        if property.name == 'revno-column-visible':
141
156
        elif property.name == 'branch':
142
157
            return self.branch
143
158
        elif property.name == 'revision':
144
 
            return self.model.get_value(self.iter, treemodel.REVISION)
 
159
            if self.path is None:
 
160
                return None
 
161
            return self.model.get_value(self.model.get_iter(self.path),
 
162
                                        treemodel.REVISION)
145
163
        elif property.name == 'revision-number':
146
 
            return self.model.get_value(self.iter, treemodel.REVNO)
 
164
            if self.path is None:
 
165
                return None
 
166
            return self.model.get_value(self.model.get_iter(self.path),
 
167
                                        treemodel.REVNO)
147
168
        elif property.name == 'children':
148
 
            return self.model.get_value(self.iter, treemodel.CHILDREN)
 
169
            if self.path is None:
 
170
                return None
 
171
            return self.model.get_value(self.model.get_iter(self.path),
 
172
                                        treemodel.CHILDREN)
149
173
        elif property.name == 'parents':
150
 
            return self.model.get_value(self.iter, treemodel.PARENTS)
 
174
            if self.path is None:
 
175
                return None
 
176
            return self.model.get_value(self.model.get_iter(self.path),
 
177
                                        treemodel.PARENTS)
151
178
        else:
152
179
            raise AttributeError, 'unknown property %s' % property.name
153
180
 
173
200
        """Return revision id of currently selected revision, or None."""
174
201
        return self.get_property('revision')
175
202
 
 
203
    def has_revision_id(self, revision_id):
 
204
        return (revision_id in self.index)
 
205
 
176
206
    def set_revision(self, revision):
177
207
        self.set_property('revision', revision)
178
208
 
181
211
 
182
212
        :param revid: Revision id of revision to display.
183
213
        """
184
 
        self.treeview.set_cursor(self.index[revid])
 
214
        self.treeview.set_cursor(
 
215
            Gtk.TreePath(path=self.index[revid]), None, False)
185
216
        self.treeview.grab_focus()
186
217
 
187
218
    def get_children(self):
201
232
    def add_tag(self, tag, revid=None):
202
233
        if revid is None: revid = self.revision.revision_id
203
234
 
204
 
        try:
205
 
            self.branch.unlock()
206
 
 
 
235
        if lock.release(self.branch):
207
236
            try:
208
 
                self.branch.lock_write()
 
237
                lock.acquire(self.branch, lock.WRITE)
209
238
                self.model.add_tag(tag, revid)
210
239
            finally:
211
 
                self.branch.unlock()
212
 
 
213
 
        finally:
214
 
            self.branch.lock_read()
215
 
 
216
 
        self.emit('tag-added', tag, revid)
217
 
        
 
240
                lock.release(self.branch)
 
241
 
 
242
            lock.acquire(self.branch, lock.READ)
 
243
 
 
244
            self.emit('tag-added', tag, revid)
 
245
 
218
246
    def refresh(self):
219
 
        gobject.idle_add(self.populate, self.get_revision())
 
247
        GObject.idle_add(self.populate, self.get_revision())
220
248
 
221
249
    def update(self):
222
250
        try:
232
260
    def back(self):
233
261
        """Signal handler for the Back button."""
234
262
        parents = self.get_parents()
235
 
        if not len(parents):
 
263
        if not parents:
236
264
            return
237
265
 
238
266
        for parent_id in parents:
247
275
    def forward(self):
248
276
        """Signal handler for the Forward button."""
249
277
        children = self.get_children()
250
 
        if not len(children):
 
278
        if not children:
251
279
            return
252
280
 
253
281
        for child_id in children:
269
297
                       should be broken.
270
298
        """
271
299
 
272
 
        loading_progress = ui.ui_factory.nested_progress_bar()
273
 
        loading_progress.update(msg="Loading ancestry graph", total=5)
 
300
        if getattr(ui.ui_factory, "set_progress_bar_widget", None) is not None:
 
301
            # We'are using our own ui, let's tell it to use our widget.
 
302
            ui.ui_factory.set_progress_bar_widget(self.progress_widget)
 
303
        self.progress_bar = ui.ui_factory.nested_progress_bar()
 
304
        self.progress_bar.update("Loading ancestry graph", 0, 5)
274
305
 
275
306
        try:
276
307
            if self.compact:
277
308
                broken_line_length = 32
278
309
            else:
279
310
                broken_line_length = None
280
 
            
 
311
 
281
312
            show_graph = self.graph_column.get_visible()
282
313
 
283
314
            self.branch.lock_read()
284
 
            (linegraphdata, index, columns_len) = linegraph(self.branch.repository.get_graph(),
285
 
                                                            self.start,
286
 
                                                            self.maxnum, 
287
 
                                                            broken_line_length,
288
 
                                                            show_graph,
289
 
                                                            self.mainline_only,
290
 
                                                            loading_progress)
 
315
            (linegraphdata, index, columns_len) = linegraph(
 
316
                self.branch.repository.get_graph(),
 
317
                self.start,
 
318
                self.maxnum, 
 
319
                broken_line_length,
 
320
                show_graph,
 
321
                self.mainline_only,
 
322
                self.progress_bar)
291
323
 
292
 
            self.model = TreeModel(self.branch, linegraphdata)
 
324
            self.model.set_line_graph_data(linegraphdata)
293
325
            self.graph_cell.columns_len = columns_len
294
 
            width = self.graph_cell.get_size(self.treeview)[2]
 
326
            width = self.graph_cell.get_preferred_width(self.treeview)[1]
295
327
            if width > 500:
296
328
                width = 500
 
329
            elif width == 0:
 
330
                # The get_preferred_width() call got an insane value.
 
331
                width = 200
297
332
            self.graph_column.set_fixed_width(width)
298
333
            self.graph_column.set_max_width(width)
299
334
            self.index = index
300
335
            self.treeview.set_model(self.model)
301
336
 
302
337
            if not revision or revision == NULL_REVISION:
303
 
                self.treeview.set_cursor(0)
 
338
                self.treeview.set_cursor(Gtk.TreePath(path=0), None, False)
304
339
            else:
305
340
                self.set_revision(revision)
306
341
 
 
342
            self.emit('refreshed')
307
343
            return False
308
344
        finally:
309
 
            loading_progress.finished()
 
345
            self.progress_bar.finished()
310
346
 
311
347
    def construct_treeview(self):
312
 
        self.treeview = gtk.TreeView()
 
348
        self.treeview = Gtk.TreeView()
313
349
 
314
350
        self.treeview.set_rules_hint(True)
315
 
        self.treeview.set_search_column(treemodel.REVNO)
316
 
        
317
 
        # Fix old PyGTK bug - by JAM
318
 
        set_tooltip = getattr(self.treeview, 'set_tooltip_column', None)
319
 
        if set_tooltip is not None:
320
 
            set_tooltip(treemodel.MESSAGE)
321
 
 
 
351
        # combined revno/summary interactive search
 
352
        #
 
353
        # the row in a treemodel is considered "matched" if a REVNO *starts*
 
354
        # from the key (that is the key is found in a REVNO at the offset 0)
 
355
        # or if a MESSAGE *contains* the key anywhere (that is, the key is
 
356
        # found case insensitively in a MESSAGE at any offset)
 
357
        def search_equal_func(model, column, key, iter, ignored):
 
358
            return (model.get_value(iter, treemodel.REVNO).find(key) != 0
 
359
                and model.get_value(iter, treemodel.MESSAGE).lower().find(key.lower()) == -1)
 
360
 
 
361
        self.treeview.set_search_equal_func(search_equal_func, None)
 
362
        self.treeview.set_enable_search(True)
 
363
 
 
364
        self.treeview.set_tooltip_column(treemodel.MESSAGE)
 
365
        self.treeview.set_headers_visible(True)
 
366
 
 
367
        self._prev_cursor_path = None
322
368
        self.treeview.connect("cursor-changed",
323
369
                self._on_selection_changed)
324
370
 
332
378
 
333
379
        self.treeview.show()
334
380
 
335
 
        cell = gtk.CellRendererText()
 
381
        cell = Gtk.CellRendererText()
336
382
        cell.set_property("width-chars", 15)
337
 
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
338
 
        self.revno_column = gtk.TreeViewColumn("Revision No")
339
 
        self.revno_column.set_resizable(False)
340
 
        self.revno_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
341
 
        self.revno_column.set_fixed_width(cell.get_size(self.treeview)[2])
342
 
        self.revno_column.pack_start(cell, expand=True)
 
383
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
 
384
        self.revno_column = Gtk.TreeViewColumn("Revision No")
 
385
        self.revno_column.set_resizable(True)
 
386
        self.revno_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
 
387
        self.revno_column.set_fixed_width(
 
388
            cell.get_preferred_width(self.treeview)[1])
 
389
        self.revno_column.pack_start(cell, True)
343
390
        self.revno_column.add_attribute(cell, "text", treemodel.REVNO)
344
391
        self.treeview.append_column(self.revno_column)
345
392
 
346
393
        self.graph_cell = CellRendererGraph()
347
 
        self.graph_column = gtk.TreeViewColumn()
348
 
        self.graph_column.set_resizable(False)
349
 
        self.graph_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
350
 
        self.graph_column.pack_start(self.graph_cell, expand=True)
351
 
        self.graph_column.add_attribute(self.graph_cell, "node", treemodel.NODE)
352
 
        self.graph_column.add_attribute(self.graph_cell, "tags", treemodel.TAGS)
353
 
        self.graph_column.add_attribute(self.graph_cell, "in-lines", treemodel.LAST_LINES)
354
 
        self.graph_column.add_attribute(self.graph_cell, "out-lines", treemodel.LINES)
 
394
        self.graph_column = Gtk.TreeViewColumn()
 
395
        self.graph_column.set_resizable(True)
 
396
        self.graph_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
 
397
        self.graph_column.pack_start(self.graph_cell, True)
 
398
        self.graph_column.add_attribute(
 
399
            self.graph_cell, "node", treemodel.NODE)
 
400
        self.graph_column.add_attribute(
 
401
            self.graph_cell, "tags", treemodel.TAGS)
 
402
        self.graph_column.add_attribute(
 
403
            self.graph_cell, "in-lines", treemodel.LAST_LINES)
 
404
        self.graph_column.add_attribute(
 
405
            self.graph_cell, "out-lines", treemodel.LINES)
355
406
        self.treeview.append_column(self.graph_column)
356
407
 
357
 
        cell = gtk.CellRendererText()
 
408
        cell = Gtk.CellRendererText()
358
409
        cell.set_property("width-chars", 65)
359
 
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
360
 
        self.summary_column = gtk.TreeViewColumn("Summary")
361
 
        self.summary_column.set_resizable(False)
 
410
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
 
411
        self.summary_column = Gtk.TreeViewColumn("Summary")
 
412
        self.summary_column.set_resizable(True)
362
413
        self.summary_column.set_expand(True)
363
 
        self.summary_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
364
 
        self.summary_column.set_fixed_width(cell.get_size(self.treeview)[2])
365
 
        self.summary_column.pack_start(cell, expand=True)
 
414
        self.summary_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
 
415
        self.summary_column.set_fixed_width(
 
416
            cell.get_preferred_width(self.treeview)[1])
 
417
        self.summary_column.pack_start(cell, True)
366
418
        self.summary_column.add_attribute(cell, "markup", treemodel.SUMMARY)
367
419
        self.treeview.append_column(self.summary_column)
368
420
 
369
 
        cell = gtk.CellRendererText()
 
421
        cell = Gtk.CellRendererText()
370
422
        cell.set_property("width-chars", 15)
371
 
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
372
 
        self.committer_column = gtk.TreeViewColumn("Committer")
373
 
        self.committer_column.set_resizable(False)
374
 
        self.committer_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
375
 
        self.committer_column.set_fixed_width(200)
376
 
        self.committer_column.pack_start(cell, expand=True)
377
 
        self.committer_column.add_attribute(cell, "text", treemodel.COMMITTER)
378
 
        self.treeview.append_column(self.committer_column)
 
423
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
 
424
        self.authors_column = Gtk.TreeViewColumn("Author(s)")
 
425
        self.authors_column.set_resizable(False)
 
426
        self.authors_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
 
427
        self.authors_column.set_fixed_width(200)
 
428
        self.authors_column.pack_start(cell, True)
 
429
        self.authors_column.add_attribute(cell, "text", treemodel.AUTHORS)
 
430
        self.treeview.append_column(self.authors_column)
379
431
 
380
 
        cell = gtk.CellRendererText()
 
432
        cell = Gtk.CellRendererText()
381
433
        cell.set_property("width-chars", 20)
382
 
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
383
 
        self.date_column = gtk.TreeViewColumn("Date")
 
434
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
 
435
        self.date_column = Gtk.TreeViewColumn("Date")
384
436
        self.date_column.set_visible(False)
385
 
        self.date_column.set_resizable(False)
386
 
        self.date_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
 
437
        self.date_column.set_resizable(True)
 
438
        self.date_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
387
439
        self.date_column.set_fixed_width(130)
388
 
        self.date_column.pack_start(cell, expand=True)
 
440
        self.date_column.pack_start(cell, True)
389
441
        self.date_column.add_attribute(cell, "text", treemodel.TIMESTAMP)
390
442
        self.treeview.append_column(self.date_column)
391
 
        
 
443
 
392
444
        return self.treeview
393
445
 
394
446
    def _on_selection_changed(self, treeview):
395
447
        """callback for when the treeview changes."""
396
448
        (path, focus) = treeview.get_cursor()
397
 
        if path is not None:
398
 
            self.iter = self.model.get_iter(path)
 
449
        if (path is not None) and (path != self._prev_cursor_path):
 
450
            self._prev_cursor_path = path # avoid emitting twice per click
 
451
            self.path = path
399
452
            self.emit('revision-selected')
400
453
 
401
454
    def _on_revision_selected(self, widget, event):
402
 
        from bzrlib.plugins.gtk.revisionmenu import RevisionPopupMenu
 
455
        from bzrlib.plugins.gtk.revisionmenu import RevisionMenu
403
456
        if event.button == 3:
404
 
            menu = RevisionPopupMenu(self.branch.repository, 
405
 
                [self.get_revision().revision_id],
406
 
                self.branch)
 
457
            revs = []
 
458
            rev = self.get_revision()
 
459
            if rev is not None:
 
460
                revs.append(rev.revision_id)
 
461
            menu = RevisionMenu(self.branch.repository, revs, self.branch)
407
462
            menu.connect('tag-added', lambda w, t, r: self.add_tag(t, r))
408
 
            menu.popup(None, None, None, event.button, event.get_time())
 
463
            menu.popup(None, None, None, None, event.button, event.get_time())
409
464
 
410
465
    def _on_revision_activated(self, widget, path, col):
411
466
        self.emit('revision-activated', path, col)