/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 __init__.py

  • Committer: Jelmer Vernooij
  • Date: 2007-02-01 15:50:40 UTC
  • Revision ID: jelmer@samba.org-20070201155040-3hq4mfbxs99kzazy
add framework for tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
# along with this program; if not, write to the Free Software
13
13
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
14
14
 
15
 
"""Graphical support for Bazaar using GTK.
16
 
 
17
 
This plugin includes:
18
 
commit-notify     Start the graphical notifier of commits.
19
 
gannotate         GTK+ annotate. 
20
 
gbranch           GTK+ branching. 
21
 
gcheckout         GTK+ checkout. 
22
 
gcommit           GTK+ commit dialog 
23
 
gconflicts        GTK+ push. 
24
 
gdiff             Show differences in working tree in a GTK+ Window. 
25
 
ginit             Initialise a new branch.
26
 
gmissing          GTK+ missing revisions dialog. 
27
 
gpreferences      GTK+ preferences dialog. 
28
 
gpush             GTK+ push. 
29
 
gstatus           GTK+ status dialog 
30
 
gtags             Manage branch tags.
31
 
visualise         Graphically visualise this branch. 
32
 
"""
 
15
"""GTK+ frontends to Bazaar commands """
33
16
 
34
17
import bzrlib
35
18
 
36
 
__version__ = '0.19.0'
 
19
__version__ = '0.15.0'
37
20
version_info = tuple(int(n) for n in __version__.split('.'))
38
21
 
39
22
 
47
30
    """
48
31
    desired_plus = (desired[0], desired[1]+1)
49
32
    bzrlib_version = bzrlib.version_info[:2]
50
 
    if bzrlib_version == desired or (bzrlib_version == desired_plus and
51
 
                                     bzrlib.version_info[3] == 'dev'):
 
33
    if bzrlib_version == desired:
52
34
        return
53
35
    try:
54
36
        from bzrlib.trace import warning
56
38
        # get the message out any way we can
57
39
        from warnings import warn as warning
58
40
    if bzrlib_version < desired:
59
 
        from bzrlib.errors import BzrError
60
41
        warning('Installed bzr version %s is too old to be used with bzr-gtk'
61
42
                ' %s.' % (bzrlib.__version__, __version__))
62
 
        raise BzrError('Version mismatch: %r' % version_info)
 
43
        # Not using BzrNewError, because it may not exist.
 
44
        raise Exception, ('Version mismatch', version_info)
63
45
    else:
64
46
        warning('bzr-gtk is not up to date with installed bzr version %s.'
65
47
                ' \nThere should be a newer version available, e.g. %i.%i.' 
66
48
                % (bzrlib.__version__, bzrlib_version[0], bzrlib_version[1]))
67
 
 
68
 
 
69
 
## check_bzrlib_version(version_info[:2]) REMOVE
70
 
 
71
 
from bzrlib.trace import warning
72
 
if __name__ != 'bzrlib.plugins.gtk':
73
 
    warning("Not running as bzrlib.plugins.gtk, things may break.")
74
 
 
75
 
from bzrlib.lazy_import import lazy_import
76
 
lazy_import(globals(), """
77
 
from bzrlib import (
78
 
    branch,
79
 
    errors,
80
 
    workingtree,
81
 
    )
82
 
""")
83
 
 
 
49
        if bzrlib_version != desired_plus:
 
50
            raise Exception, 'Version mismatch'
 
51
 
 
52
 
 
53
check_bzrlib_version(version_info[:2])
 
54
 
 
55
from bzrlib import errors
84
56
from bzrlib.commands import Command, register_command, display_command
85
57
from bzrlib.errors import NotVersionedError, BzrCommandError, NoSuchFile
 
58
from bzrlib.commands import Command, register_command
86
59
from bzrlib.option import Option
 
60
from bzrlib.branch import Branch
 
61
from bzrlib.workingtree import WorkingTree
 
62
from bzrlib.bzrdir import BzrDir
87
63
 
88
64
import os.path
89
65
 
97
73
 
98
74
 
99
75
def set_ui_factory():
100
 
    import_pygtk()
101
 
    from ui import GtkUIFactory
 
76
    pygtk = import_pygtk()
 
77
    from olive.ui import GtkUIFactory
102
78
    import bzrlib.ui
103
79
    bzrlib.ui.ui_factory = GtkUIFactory()
104
80
 
105
81
 
106
 
class GTKCommand(Command):
107
 
    """Abstract class providing GTK specific run commands."""
108
 
 
109
 
    def open_display(self):
110
 
        pygtk = import_pygtk()
111
 
        try:
112
 
            import gtk
113
 
        except RuntimeError, e:
114
 
            if str(e) == "could not open display":
115
 
                raise NoDisplayError
116
 
        set_ui_factory()
117
 
        return gtk
118
 
 
119
 
    def run(self):
120
 
        self.open_display()
121
 
        dialog = self.get_gtk_dialog(os.path.abspath('.'))
122
 
        dialog.run()
123
 
 
124
 
 
125
 
class cmd_gbranch(GTKCommand):
 
82
class cmd_gbranch(Command):
126
83
    """GTK+ branching.
127
84
    
128
85
    """
129
86
 
130
 
    def get_gtk_dialog(self, path):
131
 
        from bzrlib.plugins.gtk.branch import BranchDialog
132
 
        return BranchDialog(path)
133
 
 
134
 
 
135
 
class cmd_gcheckout(GTKCommand):
136
 
    """ GTK+ checkout.
137
 
    
138
 
    """
139
 
    
140
 
    def get_gtk_dialog(self, path):
141
 
        from bzrlib.plugins.gtk.checkout import CheckoutDialog
142
 
        return CheckoutDialog(path)
143
 
 
144
 
 
145
 
 
146
 
class cmd_gpush(GTKCommand):
147
 
    """ GTK+ push.
148
 
    
149
 
    """
150
 
    takes_args = [ "location?" ]
151
 
 
152
 
    def run(self, location="."):
153
 
        (br, path) = branch.Branch.open_containing(location)
154
 
        self.open_display()
155
 
        from push import PushDialog
156
 
        dialog = PushDialog(br.repository, br.last_revision(), br)
157
 
        dialog.run()
158
 
 
159
 
 
160
 
 
161
 
class cmd_gdiff(GTKCommand):
 
87
    def run(self):
 
88
        pygtk = import_pygtk()
 
89
        try:
 
90
            import gtk
 
91
        except RuntimeError, e:
 
92
            if str(e) == "could not open display":
 
93
                raise NoDisplayError
 
94
 
 
95
        from bzrlib.plugins.gtk.olive.branch import BranchDialog
 
96
 
 
97
        set_ui_factory()
 
98
        dialog = BranchDialog(os.path.abspath('.'))
 
99
        dialog.window.connect("destroy", lambda w: gtk.main_quit())
 
100
        dialog.display()
 
101
        
 
102
        gtk.main()
 
103
 
 
104
register_command(cmd_gbranch)
 
105
 
 
106
class cmd_gdiff(Command):
162
107
    """Show differences in working tree in a GTK+ Window.
163
108
    
164
109
    Otherwise, all changes for the tree are listed.
169
114
    @display_command
170
115
    def run(self, revision=None, filename=None):
171
116
        set_ui_factory()
172
 
        wt = workingtree.WorkingTree.open_containing(".")[0]
173
 
        wt.lock_read()
174
 
        try:
175
 
            branch = wt.branch
176
 
            if revision is not None:
177
 
                if len(revision) == 1:
178
 
                    tree1 = wt
179
 
                    revision_id = revision[0].in_history(branch).rev_id
180
 
                    tree2 = branch.repository.revision_tree(revision_id)
181
 
                elif len(revision) == 2:
182
 
                    revision_id_0 = revision[0].in_history(branch).rev_id
183
 
                    tree2 = branch.repository.revision_tree(revision_id_0)
184
 
                    revision_id_1 = revision[1].in_history(branch).rev_id
185
 
                    tree1 = branch.repository.revision_tree(revision_id_1)
186
 
            else:
 
117
        wt = WorkingTree.open_containing(".")[0]
 
118
        branch = wt.branch
 
119
        if revision is not None:
 
120
            if len(revision) == 1:
187
121
                tree1 = wt
188
 
                tree2 = tree1.basis_tree()
189
 
 
190
 
            from diff import DiffWindow
191
 
            import gtk
192
 
            window = DiffWindow()
193
 
            window.connect("destroy", gtk.main_quit)
194
 
            window.set_diff("Working Tree", tree1, tree2)
195
 
            if filename is not None:
196
 
                tree_filename = wt.relpath(filename)
197
 
                try:
198
 
                    window.set_file(tree_filename)
199
 
                except NoSuchFile:
200
 
                    if (tree1.path2id(tree_filename) is None and 
201
 
                        tree2.path2id(tree_filename) is None):
202
 
                        raise NotVersionedError(filename)
203
 
                    raise BzrCommandError('No changes found for file "%s"' % 
204
 
                                          filename)
205
 
            window.show()
206
 
 
207
 
            gtk.main()
208
 
        finally:
209
 
            wt.unlock()
210
 
 
211
 
 
212
 
def start_viz_window(branch, revision, limit=None):
213
 
    """Start viz on branch with revision revision.
214
 
    
215
 
    :return: The viz window object.
216
 
    """
217
 
    from viz.branchwin import BranchWindow
218
 
    branch.lock_read()
219
 
    pp = BranchWindow()
220
 
    pp.set_branch(branch, revision, limit)
221
 
    # cleanup locks when the window is closed
222
 
    pp.connect("destroy", lambda w: branch.unlock())
223
 
    return pp
224
 
 
 
122
                revision_id = revision[0].in_history(branch).rev_id
 
123
                tree2 = branch.repository.revision_tree(revision_id)
 
124
            elif len(revision) == 2:
 
125
                revision_id_0 = revision[0].in_history(branch).rev_id
 
126
                tree2 = branch.repository.revision_tree(revision_id_0)
 
127
                revision_id_1 = revision[1].in_history(branch).rev_id
 
128
                tree1 = branch.repository.revision_tree(revision_id_1)
 
129
        else:
 
130
            tree1 = wt
 
131
            tree2 = tree1.basis_tree()
 
132
 
 
133
        from viz.diffwin import DiffWindow
 
134
        import gtk
 
135
        window = DiffWindow()
 
136
        window.connect("destroy", lambda w: gtk.main_quit())
 
137
        window.set_diff("Working Tree", tree1, tree2)
 
138
        if filename is not None:
 
139
            tree_filename = wt.relpath(filename)
 
140
            try:
 
141
                window.set_file(tree_filename)
 
142
            except NoSuchFile:
 
143
                if (tree1.inventory.path2id(tree_filename) is None and 
 
144
                    tree2.inventory.path2id(tree_filename) is None):
 
145
                    raise NotVersionedError(filename)
 
146
                raise BzrCommandError('No changes found for file "%s"' % 
 
147
                                      filename)
 
148
        window.show()
 
149
 
 
150
        gtk.main()
 
151
 
 
152
register_command(cmd_gdiff)
225
153
 
226
154
class cmd_visualise(Command):
227
155
    """Graphically visualise this branch.
234
162
    """
235
163
    takes_options = [
236
164
        "revision",
237
 
        Option('limit', "Maximum number of revisions to display.",
 
165
        Option('limit', "maximum number of revisions to display",
238
166
               int, 'count')]
239
167
    takes_args = [ "location?" ]
240
168
    aliases = [ "visualize", "vis", "viz" ]
241
169
 
242
170
    def run(self, location=".", revision=None, limit=None):
243
171
        set_ui_factory()
244
 
        (br, path) = branch.Branch.open_containing(location)
245
 
        br.lock_read()
 
172
        (branch, path) = Branch.open_containing(location)
 
173
        branch.lock_read()
 
174
        branch.repository.lock_read()
246
175
        try:
247
176
            if revision is None:
248
 
                revid = br.last_revision()
 
177
                revid = branch.last_revision()
249
178
                if revid is None:
250
179
                    return
251
180
            else:
252
 
                (revno, revid) = revision[0].in_history(br)
 
181
                (revno, revid) = revision[0].in_history(branch)
253
182
 
254
 
            import gtk
255
 
            pp = start_viz_window(br, revid, limit)
256
 
            pp.connect("destroy", lambda w: gtk.main_quit())
257
 
            pp.show()
258
 
            gtk.main()
 
183
            from viz.bzrkapp import BzrkApp
 
184
                
 
185
            app = BzrkApp()
 
186
            app.show(branch, revid, limit)
259
187
        finally:
260
 
            br.unlock()
261
 
 
262
 
 
263
 
class cmd_gannotate(GTKCommand):
 
188
            branch.repository.unlock()
 
189
            branch.unlock()
 
190
        app.main()
 
191
 
 
192
 
 
193
register_command(cmd_visualise)
 
194
 
 
195
class cmd_gannotate(Command):
264
196
    """GTK+ annotate.
265
197
    
266
198
    Browse changes to FILENAME line by line in a GTK+ window.
268
200
 
269
201
    takes_args = ["filename", "line?"]
270
202
    takes_options = [
271
 
        Option("all", help="Show annotations on all lines."),
272
 
        Option("plain", help="Don't highlight annotation lines."),
 
203
        Option("all", help="show annotations on all lines"),
 
204
        Option("plain", help="don't highlight annotation lines"),
273
205
        Option("line", type=int, argname="lineno",
274
 
               help="Jump to specified line number."),
 
206
               help="jump to specified line number"),
275
207
        "revision",
276
208
    ]
277
209
    aliases = ["gblame", "gpraise"]
278
210
    
279
211
    def run(self, filename, all=False, plain=False, line='1', revision=None):
280
 
        gtk = self.open_display()
 
212
        pygtk = import_pygtk()
 
213
 
 
214
        try:
 
215
            import gtk
 
216
        except RuntimeError, e:
 
217
            if str(e) == "could not open display":
 
218
                raise NoDisplayError
 
219
        set_ui_factory()
281
220
 
282
221
        try:
283
222
            line = int(line)
287
226
 
288
227
        from annotate.gannotate import GAnnotateWindow
289
228
        from annotate.config import GAnnotateConfig
290
 
        from bzrlib.bzrdir import BzrDir
291
229
 
292
 
        wt, br, path = BzrDir.open_containing_tree_or_branch(filename)
293
 
        if wt is not None:
294
 
            tree = wt
295
 
        else:
296
 
            tree = br.basis_tree()
 
230
        try:
 
231
            (tree, path) = WorkingTree.open_containing(filename)
 
232
            branch = tree.branch
 
233
        except errors.NoWorkingTree:
 
234
            (branch, path) = Branch.open_containing(filename)
 
235
            tree = branch.basis_tree()
297
236
 
298
237
        file_id = tree.path2id(path)
299
238
 
302
241
        if revision is not None:
303
242
            if len(revision) != 1:
304
243
                raise BzrCommandError("Only 1 revion may be specified.")
305
 
            revision_id = revision[0].in_history(br).rev_id
306
 
            tree = br.repository.revision_tree(revision_id)
 
244
            revision_id = revision[0].in_history(branch).rev_id
 
245
            tree = branch.repository.revision_tree(revision_id)
307
246
        else:
308
247
            revision_id = getattr(tree, 'get_revision_id', lambda: None)()
309
248
 
312
251
        window.set_title(path + " - gannotate")
313
252
        config = GAnnotateConfig(window)
314
253
        window.show()
315
 
        br.lock_read()
316
 
        if wt is not None:
317
 
            wt.lock_read()
 
254
        branch.lock_read()
318
255
        try:
319
 
            window.annotate(tree, br, file_id)
320
 
            window.jump_to_line(line)
321
 
            gtk.main()
 
256
            window.annotate(tree, branch, file_id)
322
257
        finally:
323
 
            br.unlock()
324
 
            if wt is not None:
325
 
                wt.unlock()
326
 
 
327
 
 
328
 
 
329
 
class cmd_gcommit(GTKCommand):
 
258
            branch.unlock()
 
259
        window.jump_to_line(line)
 
260
        
 
261
        gtk.main()
 
262
 
 
263
register_command(cmd_gannotate)
 
264
 
 
265
class cmd_gcommit(Command):
330
266
    """GTK+ commit dialog
331
267
 
332
268
    Graphical user interface for committing revisions"""
333
269
    
334
 
    aliases = [ "gci" ]
335
270
    takes_args = []
336
271
    takes_options = []
337
272
 
338
273
    def run(self, filename=None):
339
274
        import os
340
 
        self.open_display()
341
 
        from commit import CommitDialog
 
275
        pygtk = import_pygtk()
 
276
 
 
277
        try:
 
278
            import gtk
 
279
        except RuntimeError, e:
 
280
            if str(e) == "could not open display":
 
281
                raise NoDisplayError
 
282
 
 
283
        set_ui_factory()
 
284
        from olive.commit import CommitDialog
 
285
        from bzrlib.commit import Commit
342
286
        from bzrlib.errors import (BzrCommandError,
343
287
                                   NotBranchError,
344
 
                                   NoWorkingTree)
 
288
                                   NoWorkingTree,
 
289
                                   PointlessCommit,
 
290
                                   ConflictsInTree,
 
291
                                   StrictCommitFailed)
345
292
 
346
293
        wt = None
347
 
        br = None
 
294
        branch = None
348
295
        try:
349
 
            (wt, path) = workingtree.WorkingTree.open_containing(filename)
350
 
            br = wt.branch
 
296
            (wt, path) = WorkingTree.open_containing(filename)
 
297
            branch = wt.branch
 
298
        except NotBranchError, e:
 
299
            path = e.path
351
300
        except NoWorkingTree, e:
352
301
            path = e.base
353
 
            (br, path) = branch.Branch.open_containing(path)
354
 
 
355
 
        commit = CommitDialog(wt, path, not br)
 
302
            try:
 
303
                (branch, path) = Branch.open_containing(path)
 
304
            except NotBranchError, e:
 
305
                path = e.path
 
306
 
 
307
 
 
308
        commit = CommitDialog(wt, path, not branch)
356
309
        commit.run()
357
310
 
358
 
 
359
 
 
360
 
class cmd_gstatus(GTKCommand):
361
 
    """GTK+ status dialog
362
 
 
363
 
    Graphical user interface for showing status 
364
 
    information."""
365
 
    
366
 
    aliases = [ "gst" ]
367
 
    takes_args = ['PATH?']
368
 
    takes_options = []
369
 
 
370
 
    def run(self, path='.'):
371
 
        import os
372
 
        gtk = self.open_display()
373
 
        from status import StatusDialog
374
 
        (wt, wt_path) = workingtree.WorkingTree.open_containing(path)
375
 
        status = StatusDialog(wt, wt_path)
376
 
        status.connect("destroy", gtk.main_quit)
377
 
        status.run()
378
 
 
379
 
 
380
 
 
381
 
class cmd_gconflicts(GTKCommand):
382
 
    """ GTK+ push.
383
 
    
384
 
    """
385
 
    def run(self):
386
 
        (wt, path) = workingtree.WorkingTree.open_containing('.')
387
 
        self.open_display()
388
 
        from bzrlib.plugins.gtk.conflicts import ConflictsDialog
389
 
        dialog = ConflictsDialog(wt)
390
 
        dialog.run()
391
 
 
392
 
 
393
 
 
394
 
class cmd_gpreferences(GTKCommand):
395
 
    """ GTK+ preferences dialog.
396
 
 
397
 
    """
398
 
    def run(self):
399
 
        self.open_display()
400
 
        from bzrlib.plugins.gtk.preferences import PreferencesWindow
401
 
        dialog = PreferencesWindow()
402
 
        dialog.run()
403
 
 
404
 
 
405
 
 
406
 
class cmd_gmissing(Command):
407
 
    """ GTK+ missing revisions dialog.
408
 
 
409
 
    """
410
 
    takes_args = ["other_branch?"]
411
 
    def run(self, other_branch=None):
412
 
        pygtk = import_pygtk()
413
 
        try:
414
 
            import gtk
415
 
        except RuntimeError, e:
416
 
            if str(e) == "could not open display":
417
 
                raise NoDisplayError
418
 
 
419
 
        from bzrlib.plugins.gtk.missing import MissingWindow
420
 
        from bzrlib.branch import Branch
421
 
 
422
 
        local_branch = Branch.open_containing(".")[0]
423
 
        if other_branch is None:
424
 
            other_branch = local_branch.get_parent()
425
 
            
426
 
            if other_branch is None:
427
 
                raise errors.BzrCommandError("No peer location known or specified.")
428
 
        remote_branch = Branch.open_containing(other_branch)[0]
429
 
        set_ui_factory()
430
 
        local_branch.lock_read()
431
 
        try:
432
 
            remote_branch.lock_read()
433
 
            try:
434
 
                dialog = MissingWindow(local_branch, remote_branch)
435
 
                dialog.run()
436
 
            finally:
437
 
                remote_branch.unlock()
438
 
        finally:
439
 
            local_branch.unlock()
440
 
 
441
 
 
442
 
class cmd_ginit(GTKCommand):
443
 
    def run(self):
444
 
        self.open_display()
445
 
        from initialize import InitDialog
446
 
        dialog = InitDialog(os.path.abspath(os.path.curdir))
447
 
        dialog.run()
448
 
 
449
 
 
450
 
class cmd_gtags(GTKCommand):
451
 
    def run(self):
452
 
        br = branch.Branch.open_containing('.')[0]
453
 
        
454
 
        gtk = self.open_display()
455
 
        from tags import TagsWindow
456
 
        window = TagsWindow(br)
457
 
        window.show()
458
 
        gtk.main()
459
 
 
460
 
 
461
 
commands = [
462
 
    cmd_gmissing, 
463
 
    cmd_gpreferences, 
464
 
    cmd_gconflicts, 
465
 
    cmd_gstatus,
466
 
    cmd_gcommit, 
467
 
    cmd_gannotate, 
468
 
    cmd_visualise, 
469
 
    cmd_gdiff,
470
 
    cmd_gpush, 
471
 
    cmd_gcheckout, 
472
 
    cmd_gbranch,
473
 
    cmd_ginit,
474
 
    cmd_gtags
475
 
    ]
476
 
 
477
 
for cmd in commands:
478
 
    register_command(cmd)
479
 
 
480
 
 
481
 
class cmd_commit_notify(GTKCommand):
482
 
    """Run the bzr commit notifier.
483
 
 
484
 
    This is a background program which will pop up a notification on the users
485
 
    screen when a commit occurs.
486
 
    """
487
 
 
488
 
    def run(self):
489
 
        from notify import NotifyPopupMenu
490
 
        gtk = self.open_display()
491
 
        menu = NotifyPopupMenu()
492
 
        icon = gtk.status_icon_new_from_file("bzr-icon-64.png")
493
 
        icon.connect('popup-menu', menu.display)
494
 
 
495
 
        import cgi
496
 
        import dbus
497
 
        import dbus.service
498
 
        import pynotify
499
 
        from bzrlib.bzrdir import BzrDir
500
 
        from bzrlib import errors
501
 
        from bzrlib.osutils import format_date
502
 
        from bzrlib.transport import get_transport
503
 
        if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
504
 
            import dbus.glib
505
 
        from bzrlib.plugins.dbus import activity
506
 
        bus = dbus.SessionBus()
507
 
        # get the object so we can subscribe to callbacks from it.
508
 
        broadcast_service = bus.get_object(
509
 
            activity.Broadcast.DBUS_NAME,
510
 
            activity.Broadcast.DBUS_PATH)
511
 
 
512
 
        def catch_branch(revision_id, urls):
513
 
            # TODO: show all the urls, or perhaps choose the 'best'.
514
 
            url = urls[0]
515
 
            try:
516
 
                if isinstance(revision_id, unicode):
517
 
                    revision_id = revision_id.encode('utf8')
518
 
                transport = get_transport(url)
519
 
                a_dir = BzrDir.open_from_transport(transport)
520
 
                branch = a_dir.open_branch()
521
 
                revno = branch.revision_id_to_revno(revision_id)
522
 
                revision = branch.repository.get_revision(revision_id)
523
 
                summary = 'New revision %d in %s' % (revno, url)
524
 
                body  = 'Committer: %s\n' % revision.committer
525
 
                body += 'Date: %s\n' % format_date(revision.timestamp,
526
 
                    revision.timezone)
527
 
                body += '\n'
528
 
                body += revision.message
529
 
                body = cgi.escape(body)
530
 
                nw = pynotify.Notification(summary, body)
531
 
                def start_viz(notification=None, action=None, data=None):
532
 
                    """Start the viz program."""
533
 
                    pp = start_viz_window(branch, revision_id)
534
 
                    pp.show()
535
 
                def start_branch(notification=None, action=None, data=None):
536
 
                    """Start a Branch dialog"""
537
 
                    from bzrlib.plugins.gtk.branch import BranchDialog
538
 
                    bd = BranchDialog(remote_path=url)
539
 
                    bd.run()
540
 
                nw.add_action("inspect", "Inspect", start_viz, None)
541
 
                nw.add_action("branch", "Branch", start_branch, None)
542
 
                nw.set_timeout(5000)
543
 
                nw.show()
544
 
            except Exception, e:
545
 
                print e
546
 
                raise
547
 
        broadcast_service.connect_to_signal("Revision", catch_branch,
548
 
            dbus_interface=activity.Broadcast.DBUS_INTERFACE)
549
 
        pynotify.init("bzr commit-notify")
550
 
        gtk.main()
551
 
 
552
 
register_command(cmd_commit_notify)
553
 
 
554
 
 
555
 
import gettext
556
 
gettext.install('olive-gtk')
557
 
 
 
311
register_command(cmd_gcommit)
558
312
 
559
313
class NoDisplayError(BzrCommandError):
560
314
    """gtk could not find a proper display"""
562
316
    def __str__(self):
563
317
        return "No DISPLAY. Unable to run GTK+ application."
564
318
 
565
 
 
566
319
def test_suite():
567
320
    from unittest import TestSuite
568
321
    import tests
569
 
    import sys
570
 
    default_encoding = sys.getdefaultencoding()
571
 
    try:
572
 
        result = TestSuite()
573
 
        result.addTest(tests.test_suite())
574
 
    finally:
575
 
        if sys.getdefaultencoding() != default_encoding:
576
 
            reload(sys)
577
 
            sys.setdefaultencoding(default_encoding)
 
322
    result = TestSuite()
 
323
    result.addTest(tests.test_suite())
578
324
    return result
 
325