15
15
"""GTK+ frontends to Bazaar commands """
19
__version__ = '0.15.0'
20
version_info = tuple(int(n) for n in __version__.split('.'))
23
def check_bzrlib_version(desired):
24
"""Check that bzrlib is compatible.
26
If version is < bzr-gtk version, assume incompatible.
27
If version == bzr-gtk version, assume completely compatible
28
If version == bzr-gtk version + 1, assume compatible, with deprecations
29
Otherwise, assume incompatible.
31
desired_plus = (desired[0], desired[1]+1)
32
bzrlib_version = bzrlib.version_info[:2]
33
if bzrlib_version == desired:
36
from bzrlib.trace import warning
38
# get the message out any way we can
39
from warnings import warn as warning
40
if bzrlib_version < desired:
41
warning('Installed bzr version %s is too old to be used with bzr-gtk'
42
' %s.' % (bzrlib.__version__, __version__))
43
# Not using BzrNewError, because it may not exist.
44
raise Exception, ('Version mismatch', version_info)
46
warning('bzr-gtk is not up to date with installed bzr version %s.'
47
' \nThere should be a newer version available, e.g. %i.%i.'
48
% (bzrlib.__version__, bzrlib_version[0], bzrlib_version[1]))
49
if bzrlib_version != desired_plus:
50
raise Exception, 'Version mismatch'
53
check_bzrlib_version(version_info[:2])
55
from bzrlib.trace import warning
56
if __name__ != 'bzrlib.plugins.gtk':
57
warning("Not running as bzrlib.plugins.gtk, things may break.")
59
17
from bzrlib import errors
60
18
from bzrlib.commands import Command, register_command, display_command
61
19
from bzrlib.errors import NotVersionedError, BzrCommandError, NoSuchFile
65
23
from bzrlib.workingtree import WorkingTree
66
24
from bzrlib.bzrdir import BzrDir
74
raise errors.BzrCommandError("PyGTK not installed.")
80
pygtk = import_pygtk()
81
from ui import GtkUIFactory
83
bzrlib.ui.ui_factory = GtkUIFactory()
26
__version__ = '0.13.0'
86
28
class cmd_gbranch(Command):
92
pygtk = import_pygtk()
95
38
except RuntimeError, e:
96
39
if str(e) == "could not open display":
97
40
raise NoDisplayError
99
from bzrlib.plugins.gtk.branch import BranchDialog
42
from bzrlib.plugins.gtk.olive.branch import BranchDialog
102
dialog = BranchDialog(os.path.abspath('.'))
44
window = BranchDialog('.')
105
47
register_command(cmd_gbranch)
107
class cmd_gcheckout(Command):
113
pygtk = import_pygtk()
116
except RuntimeError, e:
117
if str(e) == "could not open display":
120
from bzrlib.plugins.gtk.checkout import CheckoutDialog
123
dialog = CheckoutDialog(os.path.abspath('.'))
126
register_command(cmd_gcheckout)
128
class cmd_gpush(Command):
132
takes_args = [ "location?" ]
134
def run(self, location="."):
135
(branch, path) = Branch.open_containing(location)
137
pygtk = import_pygtk()
140
except RuntimeError, e:
141
if str(e) == "could not open display":
144
from push import PushDialog
147
dialog = PushDialog(branch)
150
register_command(cmd_gpush)
152
49
class cmd_gdiff(Command):
153
50
"""Show differences in working tree in a GTK+ Window.
214
110
aliases = [ "visualize", "vis", "viz" ]
216
112
def run(self, location=".", revision=None, limit=None):
218
113
(branch, path) = Branch.open_containing(location)
219
114
branch.lock_read()
220
115
branch.repository.lock_read()
255
150
aliases = ["gblame", "gpraise"]
257
152
def run(self, filename, all=False, plain=False, line='1', revision=None):
258
pygtk = import_pygtk()
262
158
except RuntimeError, e:
263
159
if str(e) == "could not open display":
264
160
raise NoDisplayError
327
222
if str(e) == "could not open display":
328
223
raise NoDisplayError
331
from commit import CommitDialog
225
from olive.commit import CommitDialog
332
226
from bzrlib.commit import Commit
333
227
from bzrlib.errors import (BzrCommandError,
351
245
except NotBranchError, e:
355
commit = CommitDialog(wt, path, not branch)
248
dialog = CommitDialog(wt, path, not branch)
250
dialog.window.connect("destroy", lambda w: gtk.main_quit())
358
253
register_command(cmd_gcommit)
361
256
"""gtk could not find a proper display"""
363
258
def __str__(self):
364
return "No DISPLAY. Unable to run GTK+ application."
367
from unittest import TestSuite
370
result.addTest(tests.test_suite())
259
return "No DISPLAY. gannotate is disabled."