22
22
gcommit GTK+ commit dialog.
23
23
gconflicts GTK+ conflicts.
24
24
gdiff Show differences in working tree in a GTK+ Window.
25
ghandle-patch Display and optionally merge a merge directive or patch.
25
26
ginit Initialise a new branch.
26
27
gmissing GTK+ missing revisions dialog.
27
28
gpreferences GTK+ preferences dialog.
39
version_info = (0, 95, 0, 'dev', 1)
40
version_info = (0, 94, 0, 'rc', 1)
41
42
if version_info[3] == 'final':
42
43
version_string = '%d.%d.%d' % version_info[:3]
123
pygtk = import_pygtk()
126
except RuntimeError, e:
127
if str(e) == "could not open display":
133
123
class GTKCommand(Command):
134
124
"""Abstract class providing GTK specific run commands."""
126
def open_display(self):
127
pygtk = import_pygtk()
130
except RuntimeError, e:
131
if str(e) == "could not open display":
138
138
dialog = self.get_gtk_dialog(os.path.abspath('.'))
169
169
def run(self, location="."):
170
170
(br, path) = branch.Branch.open_containing(location)
172
172
from push import PushDialog
173
173
dialog = PushDialog(br.repository, br.last_revision(), br)
193
193
if revision is not None:
194
194
if len(revision) == 1:
196
revision_id = revision[0].as_revision_id(tree1.branch)
196
revision_id = revision[0].in_history(branch).rev_id
197
197
tree2 = branch.repository.revision_tree(revision_id)
198
198
elif len(revision) == 2:
199
revision_id_0 = revision[0].as_revision_id(branch)
199
revision_id_0 = revision[0].in_history(branch).rev_id
200
200
tree2 = branch.repository.revision_tree(revision_id_0)
201
revision_id_1 = revision[1].as_revision_id(branch)
201
revision_id_1 = revision[1].in_history(branch).rev_id
202
202
tree1 = branch.repository.revision_tree(revision_id_1)
261
261
if revision is None:
262
262
revids.append(br.last_revision())
264
revids.append(revision[0].as_revision_id(br))
264
(revno, revid) = revision[0].in_history(br)
266
267
pp = start_viz_window(br, revids, limit)
267
268
pp.connect("destroy", lambda w: gtk.main_quit())
286
287
aliases = ["gblame", "gpraise"]
288
289
def run(self, filename, all=False, plain=False, line='1', revision=None):
290
gtk = self.open_display()
311
312
if revision is not None:
312
313
if len(revision) != 1:
313
314
raise BzrCommandError("Only 1 revion may be specified.")
314
revision_id = revision[0].as_revision_id(br)
315
revision_id = revision[0].in_history(br).rev_id
315
316
tree = br.repository.revision_tree(revision_id)
317
318
revision_id = getattr(tree, 'get_revision_id', lambda: None)()
359
360
except NoWorkingTree, e:
360
361
from dialog import error_dialog
361
error_dialog(_i18n('Directory does not have a working tree'),
362
_i18n('Operation aborted.'))
362
error_dialog(_('Directory does not have a working tree'),
363
_('Operation aborted.'))
363
364
return 1 # should this be retval=3?
365
366
# It is a good habit to keep things locked for the duration, but it
387
388
def run(self, path='.', revision=None):
390
gtk = self.open_display()
390
391
from status import StatusDialog
391
392
(wt, wt_path) = workingtree.WorkingTree.open_containing(path)
393
394
if revision is not None:
395
revision_id = revision[0].as_revision_id(wt.branch)
396
revision_id = revision[0].in_history(wt.branch).rev_id
397
398
from bzrlib.errors import BzrError
398
399
raise BzrError('Revision %r doesn\'t exist' % revision[0].user_spec )
412
413
(br, path) = branch.Branch.open_containing(".")
414
gtk = self.open_display()
414
415
from bzrlib.plugins.gtk.mergedirective import SendMergeDirectiveDialog
415
416
from StringIO import StringIO
416
417
dialog = SendMergeDirectiveDialog(br)
536
537
from notify import NotifyPopupMenu
538
gtk = self.open_display()
538
539
menu = NotifyPopupMenu()
539
540
icon = gtk.status_icon_new_from_file(icon_path("bzr-icon-64.png"))
540
541
icon.connect('popup-menu', menu.display)
692
693
register_command(cmd_test_gtk)
696
class cmd_ghandle_patch(GTKCommand):
697
"""Display a patch or merge directive, possibly merging.
699
This is a helper, meant to be launched from other programs like browsers
700
or email clients. Since these programs often do not allow parameters to
701
be provided, a "handle-patch" script is included.
704
takes_args = ['path']
708
from bzrlib.plugins.gtk.diff import (DiffWindow,
709
MergeDirectiveWindow)
710
lines = open(path, 'rb').readlines()
711
lines = [l.replace('\r\n', '\n') for l in lines]
713
directive = merge_directive.MergeDirective.from_lines(lines)
714
except errors.NotAMergeDirective:
715
window = DiffWindow()
716
window.set_diff_text(path, lines)
718
window = MergeDirectiveWindow(directive, path)
719
window.set_diff_text(path, directive.patch.splitlines(True))
721
gtk = self.open_display()
722
window.connect("destroy", gtk.main_quit)
724
from dialog import error_dialog
725
error_dialog('Error', str(e))
730
register_command(cmd_ghandle_patch)
697
734
gettext.install('olive-gtk')
699
# Let's create a specialized alias to protect '_' from being erased by other
700
# uses of '_' as an anonymous variable (think pdb for one).
701
_i18n = gettext.gettext
703
737
class NoDisplayError(BzrCommandError):
704
738
"""gtk could not find a proper display"""