bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
49
by Jelmer Vernooij
Merge in Dan Loda's gannotate plugin and put it in annotate/ |
1 |
# This program is free software; you can redistribute it and/or modify
|
2 |
# it under the terms of the GNU General Public License as published by
|
|
3 |
# the Free Software Foundation; either version 2 of the License, or
|
|
4 |
# (at your option) any later version.
|
|
5 |
||
6 |
# This program is distributed in the hope that it will be useful,
|
|
7 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
8 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
9 |
# GNU General Public License for more details.
|
|
10 |
||
11 |
# You should have received a copy of the GNU General Public License
|
|
12 |
# along with this program; if not, write to the Free Software
|
|
13 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
14 |
||
15 |
"""GTK+ frontends to Bazaar commands """
|
|
73
by Jelmer Vernooij
Release 0.9, list myself as maintainer. |
16 |
|
137
by Jelmer Vernooij
Warn about incompatible versions (taken from bzrtools, thanks Aaron). |
17 |
import bzrlib |
18 |
||
162
by Aaron Bentley
Update version to 0.16.0 |
19 |
__version__ = '0.16.0' |
137
by Jelmer Vernooij
Warn about incompatible versions (taken from bzrtools, thanks Aaron). |
20 |
version_info = tuple(int(n) for n in __version__.split('.')) |
21 |
||
22 |
||
23 |
def check_bzrlib_version(desired): |
|
24 |
"""Check that bzrlib is compatible. |
|
25 |
||
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.
|
|
30 |
"""
|
|
31 |
desired_plus = (desired[0], desired[1]+1) |
|
32 |
bzrlib_version = bzrlib.version_info[:2] |
|
33 |
if bzrlib_version == desired: |
|
34 |
return
|
|
35 |
try: |
|
36 |
from bzrlib.trace import warning |
|
37 |
except ImportError: |
|
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) |
|
45 |
else: |
|
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' |
|
51 |
||
52 |
||
53 |
check_bzrlib_version(version_info[:2]) |
|
54 |
||
146
by Jelmer Vernooij
Move more code to top-level directory. |
55 |
from bzrlib.trace import warning |
56 |
if __name__ != 'bzrlib.plugins.gtk': |
|
57 |
warning("Not running as bzrlib.plugins.gtk, things may break.") |
|
58 |
||
157.1.5
by Aaron Bentley
Use lazy_import to reduce rocks time by .015s |
59 |
from bzrlib.lazy_import import lazy_import |
60 |
lazy_import(globals(), """ |
|
61 |
from bzrlib import (
|
|
62 |
branch,
|
|
63 |
errors,
|
|
64 |
workingtree,
|
|
65 |
)
|
|
66 |
""") |
|
67 |
||
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
68 |
from bzrlib.commands import Command, register_command, display_command |
59.2.4
by Aaron Bentley
Teach gdiff to accept a single file argument |
69 |
from bzrlib.errors import NotVersionedError, BzrCommandError, NoSuchFile |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
70 |
from bzrlib.commands import Command, register_command |
71 |
from bzrlib.option import Option |
|
72 |
from bzrlib.bzrdir import BzrDir |
|
73 |
||
126.1.5
by Szilveszter Farkas (Phanatic)
bzr gbranch should work now (Fixed: #77751) |
74 |
import os.path |
75 |
||
66.2.20
by Aaron Bentley
Nicer error when PyGTK not installed |
76 |
def import_pygtk(): |
77 |
try: |
|
78 |
import pygtk |
|
79 |
except ImportError: |
|
80 |
raise errors.BzrCommandError("PyGTK not installed.") |
|
81 |
pygtk.require('2.0') |
|
82 |
return pygtk |
|
83 |
||
84 |
||
133
by Jelmer Vernooij
Actually use the ui factory. |
85 |
def set_ui_factory(): |
86 |
pygtk = import_pygtk() |
|
142
by Jelmer Vernooij
Move some files to the top-level directory, add first test. |
87 |
from ui import GtkUIFactory |
133
by Jelmer Vernooij
Actually use the ui factory. |
88 |
import bzrlib.ui |
89 |
bzrlib.ui.ui_factory = GtkUIFactory() |
|
90 |
||
91 |
||
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
92 |
class cmd_gbranch(Command): |
93 |
"""GTK+ branching. |
|
94 |
|
|
95 |
"""
|
|
96 |
||
97 |
def run(self): |
|
66.2.20
by Aaron Bentley
Nicer error when PyGTK not installed |
98 |
pygtk = import_pygtk() |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
99 |
try: |
100 |
import gtk |
|
101 |
except RuntimeError, e: |
|
102 |
if str(e) == "could not open display": |
|
103 |
raise NoDisplayError |
|
104 |
||
142
by Jelmer Vernooij
Move some files to the top-level directory, add first test. |
105 |
from bzrlib.plugins.gtk.branch import BranchDialog |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
106 |
|
133
by Jelmer Vernooij
Actually use the ui factory. |
107 |
set_ui_factory() |
126.1.5
by Szilveszter Farkas (Phanatic)
bzr gbranch should work now (Fixed: #77751) |
108 |
dialog = BranchDialog(os.path.abspath('.')) |
126.1.15
by Szilveszter Farkas (Phanatic)
Refactoring the Branch dialog. We also have a Revision Browser now. |
109 |
dialog.run() |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
110 |
|
111 |
register_command(cmd_gbranch) |
|
112 |
||
126.1.18
by Szilveszter Farkas (Phanatic)
Improved Branch dialog. Refactored Checkout dialog. |
113 |
class cmd_gcheckout(Command): |
114 |
""" GTK+ checkout. |
|
115 |
|
|
116 |
"""
|
|
117 |
||
118 |
def run(self): |
|
119 |
pygtk = import_pygtk() |
|
120 |
try: |
|
121 |
import gtk |
|
122 |
except RuntimeError, e: |
|
123 |
if str(e) == "could not open display": |
|
124 |
raise NoDisplayError |
|
125 |
||
142
by Jelmer Vernooij
Move some files to the top-level directory, add first test. |
126 |
from bzrlib.plugins.gtk.checkout import CheckoutDialog |
126.1.18
by Szilveszter Farkas (Phanatic)
Improved Branch dialog. Refactored Checkout dialog. |
127 |
|
128 |
set_ui_factory() |
|
129 |
dialog = CheckoutDialog(os.path.abspath('.')) |
|
130 |
dialog.run() |
|
131 |
||
132 |
register_command(cmd_gcheckout) |
|
133 |
||
126.1.19
by Szilveszter Farkas (Phanatic)
Refactored the Push dialog. Add 'gpush' command. |
134 |
class cmd_gpush(Command): |
135 |
""" GTK+ push. |
|
136 |
|
|
137 |
"""
|
|
138 |
takes_args = [ "location?" ] |
|
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
139 |
|
126.1.19
by Szilveszter Farkas (Phanatic)
Refactored the Push dialog. Add 'gpush' command. |
140 |
def run(self, location="."): |
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
141 |
(br, path) = branch.Branch.open_containing(location) |
142 |
||
126.1.19
by Szilveszter Farkas (Phanatic)
Refactored the Push dialog. Add 'gpush' command. |
143 |
pygtk = import_pygtk() |
144 |
try: |
|
145 |
import gtk |
|
146 |
except RuntimeError, e: |
|
147 |
if str(e) == "could not open display": |
|
148 |
raise NoDisplayError |
|
149 |
||
142
by Jelmer Vernooij
Move some files to the top-level directory, add first test. |
150 |
from push import PushDialog |
126.1.19
by Szilveszter Farkas (Phanatic)
Refactored the Push dialog. Add 'gpush' command. |
151 |
|
152 |
set_ui_factory() |
|
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
153 |
dialog = PushDialog(br) |
126.1.19
by Szilveszter Farkas (Phanatic)
Refactored the Push dialog. Add 'gpush' command. |
154 |
dialog.run() |
155 |
||
156 |
register_command(cmd_gpush) |
|
157 |
||
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
158 |
class cmd_gdiff(Command): |
159 |
"""Show differences in working tree in a GTK+ Window. |
|
160 |
|
|
161 |
Otherwise, all changes for the tree are listed.
|
|
162 |
"""
|
|
59.2.4
by Aaron Bentley
Teach gdiff to accept a single file argument |
163 |
takes_args = ['filename?'] |
58.1.1
by Aaron Bentley
gdiff takes -r arguments |
164 |
takes_options = ['revision'] |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
165 |
|
166 |
@display_command
|
|
59.2.4
by Aaron Bentley
Teach gdiff to accept a single file argument |
167 |
def run(self, revision=None, filename=None): |
133
by Jelmer Vernooij
Actually use the ui factory. |
168 |
set_ui_factory() |
157.1.5
by Aaron Bentley
Use lazy_import to reduce rocks time by .015s |
169 |
wt = workingtree.WorkingTree.open_containing(".")[0] |
161
by Aaron Bentley
Fix gannotate interaction with dirstate |
170 |
wt.lock_read() |
171 |
try: |
|
172 |
branch = wt.branch |
|
173 |
if revision is not None: |
|
174 |
if len(revision) == 1: |
|
175 |
tree1 = wt |
|
176 |
revision_id = revision[0].in_history(branch).rev_id |
|
177 |
tree2 = branch.repository.revision_tree(revision_id) |
|
178 |
elif len(revision) == 2: |
|
179 |
revision_id_0 = revision[0].in_history(branch).rev_id |
|
180 |
tree2 = branch.repository.revision_tree(revision_id_0) |
|
181 |
revision_id_1 = revision[1].in_history(branch).rev_id |
|
182 |
tree1 = branch.repository.revision_tree(revision_id_1) |
|
183 |
else: |
|
58.1.1
by Aaron Bentley
gdiff takes -r arguments |
184 |
tree1 = wt |
161
by Aaron Bentley
Fix gannotate interaction with dirstate |
185 |
tree2 = tree1.basis_tree() |
186 |
||
187 |
from diff import DiffWindow |
|
188 |
import gtk |
|
189 |
window = DiffWindow() |
|
190 |
window.connect("destroy", gtk.main_quit) |
|
191 |
window.set_diff("Working Tree", tree1, tree2) |
|
192 |
if filename is not None: |
|
193 |
tree_filename = wt.relpath(filename) |
|
194 |
try: |
|
195 |
window.set_file(tree_filename) |
|
196 |
except NoSuchFile: |
|
197 |
if (tree1.inventory.path2id(tree_filename) is None and |
|
198 |
tree2.inventory.path2id(tree_filename) is None): |
|
199 |
raise NotVersionedError(filename) |
|
200 |
raise BzrCommandError('No changes found for file "%s"' % |
|
201 |
filename) |
|
202 |
window.show() |
|
203 |
||
204 |
gtk.main() |
|
205 |
finally: |
|
206 |
wt.unlock() |
|
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
207 |
|
208 |
register_command(cmd_gdiff) |
|
209 |
||
210 |
class cmd_visualise(Command): |
|
211 |
"""Graphically visualise this branch. |
|
212 |
||
213 |
Opens a graphical window to allow you to see the history of the branch
|
|
214 |
and relationships between revisions in a visual manner,
|
|
215 |
||
216 |
The default starting point is latest revision on the branch, you can
|
|
217 |
specify a starting point with -r revision.
|
|
218 |
"""
|
|
219 |
takes_options = [ |
|
220 |
"revision", |
|
221 |
Option('limit', "maximum number of revisions to display", |
|
222 |
int, 'count')] |
|
223 |
takes_args = [ "location?" ] |
|
224 |
aliases = [ "visualize", "vis", "viz" ] |
|
225 |
||
226 |
def run(self, location=".", revision=None, limit=None): |
|
133
by Jelmer Vernooij
Actually use the ui factory. |
227 |
set_ui_factory() |
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
228 |
(br, path) = branch.Branch.open_containing(location) |
229 |
br.lock_read() |
|
230 |
br.repository.lock_read() |
|
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
231 |
try: |
232 |
if revision is None: |
|
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
233 |
revid = br.last_revision() |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
234 |
if revid is None: |
235 |
return
|
|
236 |
else: |
|
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
237 |
(revno, revid) = revision[0].in_history(br) |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
238 |
|
152
by Jelmer Vernooij
Cleanup some more code. |
239 |
from viz.branchwin import BranchWindow |
240 |
import gtk |
|
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
241 |
|
152
by Jelmer Vernooij
Cleanup some more code. |
242 |
pp = BranchWindow() |
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
243 |
pp.set_branch(br, revid, limit) |
152
by Jelmer Vernooij
Cleanup some more code. |
244 |
pp.connect("destroy", lambda w: gtk.main_quit()) |
245 |
pp.show() |
|
246 |
gtk.main() |
|
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
247 |
finally: |
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
248 |
br.repository.unlock() |
249 |
br.unlock() |
|
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
250 |
|
251 |
||
252 |
register_command(cmd_visualise) |
|
253 |
||
254 |
class cmd_gannotate(Command): |
|
255 |
"""GTK+ annotate. |
|
256 |
|
|
257 |
Browse changes to FILENAME line by line in a GTK+ window.
|
|
258 |
"""
|
|
259 |
||
59.2.1
by Aaron Bentley
Gannotate takes a line number |
260 |
takes_args = ["filename", "line?"] |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
261 |
takes_options = [ |
262 |
Option("all", help="show annotations on all lines"), |
|
263 |
Option("plain", help="don't highlight annotation lines"), |
|
264 |
Option("line", type=int, argname="lineno", |
|
66.2.1
by Aaron Bentley
Gannotate takes a revision argument |
265 |
help="jump to specified line number"), |
266 |
"revision", |
|
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
267 |
]
|
268 |
aliases = ["gblame", "gpraise"] |
|
269 |
||
66.2.1
by Aaron Bentley
Gannotate takes a revision argument |
270 |
def run(self, filename, all=False, plain=False, line='1', revision=None): |
66.2.20
by Aaron Bentley
Nicer error when PyGTK not installed |
271 |
pygtk = import_pygtk() |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
272 |
|
273 |
try: |
|
274 |
import gtk |
|
275 |
except RuntimeError, e: |
|
276 |
if str(e) == "could not open display": |
|
277 |
raise NoDisplayError |
|
133
by Jelmer Vernooij
Actually use the ui factory. |
278 |
set_ui_factory() |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
279 |
|
59.2.1
by Aaron Bentley
Gannotate takes a line number |
280 |
try: |
281 |
line = int(line) |
|
282 |
except ValueError: |
|
283 |
raise BzrCommandError('Line argument ("%s") is not a number.' % |
|
284 |
line) |
|
285 |
||
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
286 |
from annotate.gannotate import GAnnotateWindow |
287 |
from annotate.config import GAnnotateConfig |
|
288 |
||
161
by Aaron Bentley
Fix gannotate interaction with dirstate |
289 |
wt, br, path = BzrDir.open_containing_tree_or_branch(filename) |
290 |
if wt is not None: |
|
291 |
tree = wt |
|
292 |
else: |
|
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
293 |
tree = br.basis_tree() |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
294 |
|
66.2.18
by Aaron Bentley
Gannotate works with branches, not just trees |
295 |
file_id = tree.path2id(path) |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
296 |
|
297 |
if file_id is None: |
|
298 |
raise NotVersionedError(filename) |
|
66.2.1
by Aaron Bentley
Gannotate takes a revision argument |
299 |
if revision is not None: |
300 |
if len(revision) != 1: |
|
301 |
raise BzrCommandError("Only 1 revion may be specified.") |
|
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
302 |
revision_id = revision[0].in_history(br).rev_id |
303 |
tree = br.repository.revision_tree(revision_id) |
|
66.2.1
by Aaron Bentley
Gannotate takes a revision argument |
304 |
else: |
66.2.18
by Aaron Bentley
Gannotate works with branches, not just trees |
305 |
revision_id = getattr(tree, 'get_revision_id', lambda: None)() |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
306 |
|
307 |
window = GAnnotateWindow(all, plain) |
|
308 |
window.connect("destroy", lambda w: gtk.main_quit()) |
|
309 |
window.set_title(path + " - gannotate") |
|
310 |
config = GAnnotateConfig(window) |
|
311 |
window.show() |
|
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
312 |
br.lock_read() |
161
by Aaron Bentley
Fix gannotate interaction with dirstate |
313 |
if wt is not None: |
314 |
wt.lock_read() |
|
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
315 |
try: |
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
316 |
window.annotate(tree, br, file_id) |
161
by Aaron Bentley
Fix gannotate interaction with dirstate |
317 |
window.jump_to_line(line) |
318 |
gtk.main() |
|
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
319 |
finally: |
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
320 |
br.unlock() |
161
by Aaron Bentley
Fix gannotate interaction with dirstate |
321 |
if wt is not None: |
322 |
wt.unlock() |
|
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
323 |
|
324 |
register_command(cmd_gannotate) |
|
325 |
||
326 |
class cmd_gcommit(Command): |
|
327 |
"""GTK+ commit dialog |
|
328 |
||
329 |
Graphical user interface for committing revisions"""
|
|
330 |
||
145
by Jelmer Vernooij
Fix some strings, import. |
331 |
aliases = [ "gci" ] |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
332 |
takes_args = [] |
333 |
takes_options = [] |
|
334 |
||
335 |
def run(self, filename=None): |
|
93.1.17
by Alexander Belchenko
gcommit reworked again. |
336 |
import os |
66.2.20
by Aaron Bentley
Nicer error when PyGTK not installed |
337 |
pygtk = import_pygtk() |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
338 |
|
339 |
try: |
|
340 |
import gtk |
|
341 |
except RuntimeError, e: |
|
342 |
if str(e) == "could not open display": |
|
343 |
raise NoDisplayError |
|
344 |
||
133
by Jelmer Vernooij
Actually use the ui factory. |
345 |
set_ui_factory() |
142
by Jelmer Vernooij
Move some files to the top-level directory, add first test. |
346 |
from commit import CommitDialog |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
347 |
from bzrlib.commit import Commit |
93.1.17
by Alexander Belchenko
gcommit reworked again. |
348 |
from bzrlib.errors import (BzrCommandError, |
349 |
NotBranchError, |
|
350 |
NoWorkingTree, |
|
351 |
PointlessCommit, |
|
352 |
ConflictsInTree, |
|
353 |
StrictCommitFailed) |
|
354 |
||
355 |
wt = None |
|
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
356 |
br = None |
93.1.17
by Alexander Belchenko
gcommit reworked again. |
357 |
try: |
157.1.5
by Aaron Bentley
Use lazy_import to reduce rocks time by .015s |
358 |
(wt, path) = workingtree.WorkingTree.open_containing(filename) |
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
359 |
br = wt.branch |
93.1.17
by Alexander Belchenko
gcommit reworked again. |
360 |
except NotBranchError, e: |
361 |
path = e.path |
|
362 |
except NoWorkingTree, e: |
|
363 |
path = e.base |
|
364 |
try: |
|
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
365 |
(br, path) = branch.Branch.open_containing(path) |
93.1.17
by Alexander Belchenko
gcommit reworked again. |
366 |
except NotBranchError, e: |
367 |
path = e.path |
|
368 |
||
135
by Jelmer Vernooij
Throw out the old CommitDialog code and use the new code instead, also for 'gcommit'. |
369 |
|
157.2.1
by Vincent Ladeuil
Rename variable 'branch' to 'br' where it conflicts with 'branch' module |
370 |
commit = CommitDialog(wt, path, not br) |
135
by Jelmer Vernooij
Throw out the old CommitDialog code and use the new code instead, also for 'gcommit'. |
371 |
commit.run() |
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
372 |
|
373 |
register_command(cmd_gcommit) |
|
374 |
||
157
by Jelmer Vernooij
Add gstatus command. |
375 |
class cmd_gstatus(Command): |
376 |
"""GTK+ status dialog |
|
377 |
||
378 |
Graphical user interface for showing status
|
|
379 |
information."""
|
|
380 |
||
381 |
aliases = [ "gst" ] |
|
382 |
takes_args = ['PATH?'] |
|
383 |
takes_options = [] |
|
384 |
||
385 |
def run(self, path='.'): |
|
386 |
import os |
|
387 |
pygtk = import_pygtk() |
|
388 |
||
389 |
try: |
|
390 |
import gtk |
|
391 |
except RuntimeError, e: |
|
392 |
if str(e) == "could not open display": |
|
393 |
raise NoDisplayError |
|
394 |
||
395 |
set_ui_factory() |
|
396 |
from status import StatusDialog |
|
157.1.5
by Aaron Bentley
Use lazy_import to reduce rocks time by .015s |
397 |
(wt, wt_path) = workingtree.WorkingTree.open_containing(path) |
157
by Jelmer Vernooij
Add gstatus command. |
398 |
status = StatusDialog(wt, wt_path) |
399 |
status.connect("destroy", gtk.main_quit) |
|
400 |
status.run() |
|
401 |
||
402 |
register_command(cmd_gstatus) |
|
403 |
||
126.1.24
by Szilveszter Farkas (Phanatic)
Implemented Conflicts dialog. Added gconflicts command. |
404 |
class cmd_gconflicts(Command): |
405 |
""" GTK+ push. |
|
406 |
|
|
407 |
"""
|
|
408 |
def run(self): |
|
157.1.5
by Aaron Bentley
Use lazy_import to reduce rocks time by .015s |
409 |
(wt, path) = workingtree.WorkingTree.open_containing('.') |
126.1.24
by Szilveszter Farkas (Phanatic)
Implemented Conflicts dialog. Added gconflicts command. |
410 |
|
411 |
pygtk = import_pygtk() |
|
412 |
try: |
|
413 |
import gtk |
|
414 |
except RuntimeError, e: |
|
415 |
if str(e) == "could not open display": |
|
416 |
raise NoDisplayError |
|
417 |
||
418 |
from bzrlib.plugins.gtk.conflicts import ConflictsDialog |
|
419 |
||
420 |
set_ui_factory() |
|
421 |
dialog = ConflictsDialog(wt) |
|
422 |
dialog.run() |
|
423 |
||
424 |
register_command(cmd_gconflicts) |
|
157
by Jelmer Vernooij
Add gstatus command. |
425 |
|
171
by Jelmer Vernooij
Initial work on a preferences dialog in GTK+, including a list of plugins with metadata browser. |
426 |
class cmd_gpreferences(Command): |
427 |
""" GTK+ preferences dialog. |
|
428 |
||
429 |
"""
|
|
430 |
def run(self): |
|
431 |
pygtk = import_pygtk() |
|
432 |
try: |
|
433 |
import gtk |
|
434 |
except RuntimeError, e: |
|
435 |
if str(e) == "could not open display": |
|
436 |
raise NoDisplayError |
|
437 |
||
438 |
from bzrlib.plugins.gtk.preferences import PreferencesWindow |
|
439 |
||
440 |
set_ui_factory() |
|
441 |
dialog = PreferencesWindow() |
|
442 |
dialog.run() |
|
443 |
||
444 |
register_command(cmd_gpreferences) |
|
445 |
||
152
by Jelmer Vernooij
Cleanup some more code. |
446 |
import gettext |
447 |
gettext.install('olive-gtk') |
|
448 |
||
55.1.2
by Jelmer Vernooij
Move commands to top-level __init__ |
449 |
class NoDisplayError(BzrCommandError): |
450 |
"""gtk could not find a proper display""" |
|
451 |
||
452 |
def __str__(self): |
|
133
by Jelmer Vernooij
Actually use the ui factory. |
453 |
return "No DISPLAY. Unable to run GTK+ application." |
454 |
||
140
by Jelmer Vernooij
add framework for tests. |
455 |
def test_suite(): |
456 |
from unittest import TestSuite |
|
457 |
import tests |
|
163
by Aaron Bentley
Prevent test suite from causing default-encoding changes |
458 |
import sys |
459 |
default_encoding = sys.getdefaultencoding() |
|
460 |
try: |
|
461 |
result = TestSuite() |
|
462 |
result.addTest(tests.test_suite()) |
|
463 |
finally: |
|
464 |
reload(sys) |
|
465 |
sys.setdefaultencoding(default_encoding) |
|
140
by Jelmer Vernooij
add framework for tests. |
466 |
return result |