1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Graphical support for Bazaar using GTK.
This plugin includes:
gannotate GTK+ annotate.
gbranch GTK+ branching.
gcheckout GTK+ checkout.
gcommit GTK+ commit dialog.
gconflicts GTK+ conflicts.
gdiff Show differences in working tree in a GTK+ Window.
ginit Initialise a new branch.
gloom GTK+ loom browse dialog
gmerge GTK+ merge dialog
gmissing GTK+ missing revisions dialog.
gpreferences GTK+ preferences dialog.
gpush GTK+ push.
gsend GTK+ send merge directive.
gstatus GTK+ status dialog.
gtags Manage branch tags.
visualise Graphically visualise this branch.
"""
import os
import sys
if getattr(sys, "frozen", None) is not None: # we run bzr.exe
# FIXME: Unless a better packaging solution is found, the following
# provides a workaround for https://bugs.launchpad.net/bzr/+bug/388790 Also
# see https://code.edge.launchpad.net/~vila/bzr-gtk/388790-windows-setup
# for more details about while it's needed.
# NOTE: _lib must be ahead of bzrlib or sax.saxutils (in olive) fails
here = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(here, '_lib'))
sys.path.append(os.path.join(here, '_lib/gtk-2.0'))
import bzrlib
import bzrlib.api
from bzrlib import (
branch,
config,
errors,
)
from bzrlib.commands import plugin_cmds
from info import (
bzr_plugin_version as version_info,
bzr_compatible_versions,
)
if version_info[3] == 'final':
version_string = '%d.%d.%d' % version_info[:3]
else:
version_string = '%d.%d.%d%s%d' % version_info
__version__ = version_string
bzrlib.api.require_any_api(bzrlib, bzr_compatible_versions)
if __name__ != 'bzrlib.plugins.gtk':
from bzrlib.trace import warning
warning("Not running as bzrlib.plugins.gtk, things may break.")
def import_pygtk():
try:
import pygtk
except ImportError:
raise errors.BzrCommandError("PyGTK not installed.")
pygtk.require('2.0')
return pygtk
def set_ui_factory():
import_pygtk()
from ui import GtkUIFactory
import bzrlib.ui
bzrlib.ui.ui_factory = GtkUIFactory()
def data_basedirs():
return [os.path.dirname(__file__),
"/usr/share/bzr-gtk",
"/usr/local/share/bzr-gtk"]
def data_path(*args):
for basedir in data_basedirs():
path = os.path.join(basedir, *args)
if os.path.exists(path):
return path
return None
def icon_path(*args):
return data_path(os.path.join('icons', *args))
def open_display():
pygtk = import_pygtk()
try:
import gtk
except RuntimeError, e:
if str(e) == "could not open display":
raise NoDisplayError
set_ui_factory()
return gtk
commands = {
"gannotate": ["gblame", "gpraise"],
"gbranch": [],
"gcheckout": [],
"gcommit": ["gci"],
"gconflicts": [],
"gdiff": [],
"ginit": [],
"gmerge": [],
"gmissing": [],
"gpreferences": [],
"gpush": [],
"gsend": [],
"gstatus": ["gst"],
"gtags": [],
"visualise": ["visualize", "vis", "viz", 'glog'],
}
try:
from bzrlib.plugins import loom
except ImportError:
pass # Loom plugin doesn't appear to be present
else:
commands["gloom"] = []
for cmd, aliases in commands.iteritems():
plugin_cmds.register_lazy("cmd_%s" % cmd, aliases,
"bzrlib.plugins.gtk.commands")
def save_commit_messages(*args):
from bzrlib.plugins.gtk import commit
commit.save_commit_messages(*args)
branch.Branch.hooks.install_named_hook('post_uncommit',
save_commit_messages,
"Saving commit messages for gcommit")
class NoDisplayError(errors.BzrCommandError):
"""gtk could not find a proper display"""
def __str__(self):
return "No DISPLAY. Unable to run GTK+ application."
credential_store_registry = getattr(config, "credential_store_registry", None)
if credential_store_registry is not None:
try:
credential_store_registry.register_lazy(
"gnome-keyring", "bzrlib.plugins.gtk.keyring", "GnomeKeyringCredentialStore",
help="The GNOME Keyring.", fallback=True)
except TypeError:
# Fallback credentials stores were introduced in Bazaar 1.15
credential_store_registry.register_lazy(
"gnome-keyring", "bzrlib.plugins.gtk.keyring", "GnomeKeyringCredentialStore",
help="The GNOME Keyring.")
def load_tests(basic_tests, module, loader):
testmod_names = [
'tests',
]
import sys
default_encoding = sys.getdefaultencoding()
try:
result = basic_tests
try:
import_pygtk()
except errors.BzrCommandError:
return basic_tests
basic_tests.addTest(loader.loadTestsFromModuleNames(
["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
finally:
if sys.getdefaultencoding() != default_encoding:
reload(sys)
sys.setdefaultencoding(default_encoding)
return basic_tests
def _i18n(text):
# Stub until we support proper i18n
return text
|