/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-07-15 18:12:57 UTC
  • Revision ID: jelmer@samba.org-20070715181257-g264qus2zyi3v39z
Add RevisionSelectionBox widget, use in TagDialog.

Show diffs side-by-side

added added

removed removed

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