82
75
def set_ui_factory():
84
from ui import GtkUIFactory
76
pygtk = import_pygtk()
77
from olive.ui import GtkUIFactory
86
79
bzrlib.ui.ui_factory = GtkUIFactory()
89
class GTKCommand(Command):
90
"""Abstract class providing GTK specific run commands."""
92
def open_display(self):
93
pygtk = import_pygtk()
96
except RuntimeError, e:
97
if str(e) == "could not open display":
104
dialog = self.get_gtk_dialog(os.path.abspath('.'))
108
class cmd_gbranch(GTKCommand):
82
class cmd_gbranch(Command):
109
83
"""GTK+ branching.
113
def get_gtk_dialog(self, path):
114
from bzrlib.plugins.gtk.branch import BranchDialog
115
return BranchDialog(path)
118
class cmd_gcheckout(GTKCommand):
123
def get_gtk_dialog(self, path):
124
from bzrlib.plugins.gtk.checkout import CheckoutDialog
125
return CheckoutDialog(path)
129
class cmd_gpush(GTKCommand):
133
takes_args = [ "location?" ]
135
def run(self, location="."):
136
(br, path) = branch.Branch.open_containing(location)
138
from push import PushDialog
139
dialog = PushDialog(br)
144
class cmd_gdiff(GTKCommand):
88
pygtk = import_pygtk()
91
except RuntimeError, e:
92
if str(e) == "could not open display":
95
from bzrlib.plugins.gtk.olive.branch import BranchDialog
98
dialog = BranchDialog(os.path.abspath('.'))
99
dialog.window.connect("destroy", lambda w: gtk.main_quit())
104
register_command(cmd_gbranch)
106
class cmd_gdiff(Command):
145
107
"""Show differences in working tree in a GTK+ Window.
147
109
Otherwise, all changes for the tree are listed.
153
115
def run(self, revision=None, filename=None):
155
wt = workingtree.WorkingTree.open_containing(".")[0]
159
if revision is not None:
160
if len(revision) == 1:
162
revision_id = revision[0].in_history(branch).rev_id
163
tree2 = branch.repository.revision_tree(revision_id)
164
elif len(revision) == 2:
165
revision_id_0 = revision[0].in_history(branch).rev_id
166
tree2 = branch.repository.revision_tree(revision_id_0)
167
revision_id_1 = revision[1].in_history(branch).rev_id
168
tree1 = branch.repository.revision_tree(revision_id_1)
117
wt = WorkingTree.open_containing(".")[0]
119
if revision is not None:
120
if len(revision) == 1:
171
tree2 = tree1.basis_tree()
173
from diff import DiffWindow
175
window = DiffWindow()
176
window.connect("destroy", gtk.main_quit)
177
window.set_diff("Working Tree", tree1, tree2)
178
if filename is not None:
179
tree_filename = wt.relpath(filename)
181
window.set_file(tree_filename)
183
if (tree1.path2id(tree_filename) is None and
184
tree2.path2id(tree_filename) is None):
185
raise NotVersionedError(filename)
186
raise BzrCommandError('No changes found for file "%s"' %
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)
131
tree2 = tree1.basis_tree()
133
from viz.diffwin import DiffWindow
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)
141
window.set_file(tree_filename)
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"' %
152
register_command(cmd_gdiff)
195
154
class cmd_visualise(Command):
196
155
"""Graphically visualise this branch.
211
170
def run(self, location=".", revision=None, limit=None):
213
(br, path) = branch.Branch.open_containing(location)
215
br.repository.lock_read()
172
(branch, path) = Branch.open_containing(location)
174
branch.repository.lock_read()
217
176
if revision is None:
218
revid = br.last_revision()
177
revid = branch.last_revision()
219
178
if revid is None:
222
(revno, revid) = revision[0].in_history(br)
181
(revno, revid) = revision[0].in_history(branch)
224
from viz.branchwin import BranchWindow
183
from viz.bzrkapp import BzrkApp
228
pp.set_branch(br, revid, limit)
229
pp.connect("destroy", lambda w: gtk.main_quit())
186
app.show(branch, revid, limit)
233
br.repository.unlock()
237
class cmd_gannotate(GTKCommand):
188
branch.repository.unlock()
193
register_command(cmd_visualise)
195
class cmd_gannotate(Command):
238
196
"""GTK+ annotate.
240
198
Browse changes to FILENAME line by line in a GTK+ window.
286
251
window.set_title(path + " - gannotate")
287
252
config = GAnnotateConfig(window)
293
window.annotate(tree, br, file_id)
294
window.jump_to_line(line)
256
window.annotate(tree, branch, file_id)
303
class cmd_gcommit(GTKCommand):
259
window.jump_to_line(line)
263
register_command(cmd_gannotate)
265
class cmd_gcommit(Command):
304
266
"""GTK+ commit dialog
306
268
Graphical user interface for committing revisions"""
310
271
takes_options = []
312
273
def run(self, filename=None):
315
from commit import CommitDialog
275
pygtk = import_pygtk()
279
except RuntimeError, e:
280
if str(e) == "could not open display":
284
from olive.commit import CommitDialog
285
from bzrlib.commit import Commit
316
286
from bzrlib.errors import (BzrCommandError,
323
(wt, path) = workingtree.WorkingTree.open_containing(filename)
296
(wt, path) = WorkingTree.open_containing(filename)
298
except NotBranchError, e:
325
300
except NoWorkingTree, e:
327
(br, path) = branch.Branch.open_containing(path)
329
commit = CommitDialog(wt, path, not br)
303
(branch, path) = Branch.open_containing(path)
304
except NotBranchError, e:
308
commit = CommitDialog(wt, path, not branch)
334
class cmd_gstatus(GTKCommand):
335
"""GTK+ status dialog
337
Graphical user interface for showing status
341
takes_args = ['PATH?']
344
def run(self, path='.'):
346
gtk = self.open_display()
347
from status import StatusDialog
348
(wt, wt_path) = workingtree.WorkingTree.open_containing(path)
349
status = StatusDialog(wt, wt_path)
350
status.connect("destroy", gtk.main_quit)
355
class cmd_gconflicts(GTKCommand):
360
(wt, path) = workingtree.WorkingTree.open_containing('.')
362
from bzrlib.plugins.gtk.conflicts import ConflictsDialog
363
dialog = ConflictsDialog(wt)
368
class cmd_gpreferences(GTKCommand):
369
""" GTK+ preferences dialog.
374
from bzrlib.plugins.gtk.preferences import PreferencesWindow
375
dialog = PreferencesWindow()
380
class cmd_gmissing(Command):
381
""" GTK+ missing revisions dialog.
384
takes_args = ["other_branch?"]
385
def run(self, other_branch=None):
386
pygtk = import_pygtk()
389
except RuntimeError, e:
390
if str(e) == "could not open display":
393
from bzrlib.plugins.gtk.missing import MissingWindow
394
from bzrlib.branch import Branch
396
local_branch = Branch.open_containing(".")[0]
397
if other_branch is None:
398
other_branch = local_branch.get_parent()
400
if other_branch is None:
401
raise errors.BzrCommandError("No peer location known or specified.")
402
remote_branch = Branch.open_containing(other_branch)[0]
404
local_branch.lock_read()
406
remote_branch.lock_read()
408
dialog = MissingWindow(local_branch, remote_branch)
411
remote_branch.unlock()
413
local_branch.unlock()
416
class cmd_ginit(GTKCommand):
419
from initialize import InitDialog
420
dialog = InitDialog(os.path.abspath(os.path.curdir))
424
class cmd_gtags(GTKCommand):
426
br = branch.Branch.open_containing('.')[0]
428
gtk = self.open_display()
429
from tags import TagsWindow
430
window = TagsWindow(br)
452
register_command(cmd)
455
class cmd_commit_notify(GTKCommand):
456
"""Run the bzr commit notifier.
458
This is a background program which will pop up a notification on the users
459
screen when a commit occurs.
463
gtk = self.open_display()
468
from bzrlib.bzrdir import BzrDir
469
from bzrlib import errors
470
from bzrlib.osutils import format_date
471
from bzrlib.transport import get_transport
472
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
474
from bzrlib.plugins.dbus import activity
475
bus = dbus.SessionBus()
476
# get the object so we can subscribe to callbacks from it.
477
broadcast_service = bus.get_object(
478
activity.Broadcast.DBUS_NAME,
479
activity.Broadcast.DBUS_PATH)
480
def catch_branch(revision_id, urls):
481
# TODO: show all the urls, or perhaps choose the 'best'.
484
if isinstance(revision_id, unicode):
485
revision_id = revision_id.encode('utf8')
486
transport = get_transport(url)
487
a_dir = BzrDir.open_from_transport(transport)
488
branch = a_dir.open_branch()
489
revno = branch.revision_id_to_revno(revision_id)
490
revision = branch.repository.get_revision(revision_id)
491
summary = 'New revision %d in %s' % (revno, url)
492
body = 'Committer: %s\n' % revision.committer
493
body += 'Date: %s\n' % format_date(revision.timestamp,
496
body += revision.message
497
body = cgi.escape(body)
498
nw = pynotify.Notification(summary, body)
504
broadcast_service.connect_to_signal("Revision", catch_branch,
505
dbus_interface=activity.Broadcast.DBUS_INTERFACE)
506
pynotify.init("bzr commit-notify")
509
register_command(cmd_commit_notify)
513
gettext.install('olive-gtk')
311
register_command(cmd_gcommit)
516
313
class NoDisplayError(BzrCommandError):
517
314
"""gtk could not find a proper display"""