/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Jelmer Vernooij
  • Date: 2007-03-06 13:48:35 UTC
  • mfrom: (157.1.9 trunk)
  • Revision ID: jelmer@samba.org-20070306134835-4e3gg9sq0ovvzwad
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
if __name__ != 'bzrlib.plugins.gtk':
57
57
    warning("Not running as bzrlib.plugins.gtk, things may break.")
58
58
 
59
 
from bzrlib import errors
 
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
 
60
68
from bzrlib.commands import Command, register_command, display_command
61
69
from bzrlib.errors import NotVersionedError, BzrCommandError, NoSuchFile
62
70
from bzrlib.commands import Command, register_command
63
71
from bzrlib.option import Option
64
 
from bzrlib.branch import Branch
65
 
from bzrlib.workingtree import WorkingTree
66
72
from bzrlib.bzrdir import BzrDir
67
73
 
68
74
import os.path
130
136
    
131
137
    """
132
138
    takes_args = [ "location?" ]
133
 
    
 
139
 
134
140
    def run(self, location="."):
135
 
        (branch, path) = Branch.open_containing(location)
136
 
        
 
141
        (br, path) = branch.Branch.open_containing(location)
 
142
 
137
143
        pygtk = import_pygtk()
138
144
        try:
139
145
            import gtk
144
150
        from push import PushDialog
145
151
 
146
152
        set_ui_factory()
147
 
        dialog = PushDialog(branch)
 
153
        dialog = PushDialog(br)
148
154
        dialog.run()
149
155
 
150
156
register_command(cmd_gpush)
160
166
    @display_command
161
167
    def run(self, revision=None, filename=None):
162
168
        set_ui_factory()
163
 
        wt = WorkingTree.open_containing(".")[0]
 
169
        wt = workingtree.WorkingTree.open_containing(".")[0]
164
170
        branch = wt.branch
165
171
        if revision is not None:
166
172
            if len(revision) == 1:
215
221
 
216
222
    def run(self, location=".", revision=None, limit=None):
217
223
        set_ui_factory()
218
 
        (branch, path) = Branch.open_containing(location)
219
 
        branch.lock_read()
220
 
        branch.repository.lock_read()
 
224
        (br, path) = branch.Branch.open_containing(location)
 
225
        br.lock_read()
 
226
        br.repository.lock_read()
221
227
        try:
222
228
            if revision is None:
223
 
                revid = branch.last_revision()
 
229
                revid = br.last_revision()
224
230
                if revid is None:
225
231
                    return
226
232
            else:
227
 
                (revno, revid) = revision[0].in_history(branch)
 
233
                (revno, revid) = revision[0].in_history(br)
228
234
 
229
235
            from viz.branchwin import BranchWindow
230
236
            import gtk
231
237
                
232
238
            pp = BranchWindow()
233
 
            pp.set_branch(branch, revid, limit)
 
239
            pp.set_branch(br, revid, limit)
234
240
            pp.connect("destroy", lambda w: gtk.main_quit())
235
241
            pp.show()
236
242
            gtk.main()
237
243
        finally:
238
 
            branch.repository.unlock()
239
 
            branch.unlock()
 
244
            br.repository.unlock()
 
245
            br.unlock()
240
246
 
241
247
 
242
248
register_command(cmd_visualise)
277
283
        from annotate.config import GAnnotateConfig
278
284
 
279
285
        try:
280
 
            (tree, path) = WorkingTree.open_containing(filename)
281
 
            branch = tree.branch
 
286
            (tree, path) = workingtree.WorkingTree.open_containing(filename)
 
287
            br = tree.branch
282
288
        except errors.NoWorkingTree:
283
 
            (branch, path) = Branch.open_containing(filename)
284
 
            tree = branch.basis_tree()
 
289
            (br, path) = branch.Branch.open_containing(filename)
 
290
            tree = br.basis_tree()
285
291
 
286
292
        file_id = tree.path2id(path)
287
293
 
290
296
        if revision is not None:
291
297
            if len(revision) != 1:
292
298
                raise BzrCommandError("Only 1 revion may be specified.")
293
 
            revision_id = revision[0].in_history(branch).rev_id
294
 
            tree = branch.repository.revision_tree(revision_id)
 
299
            revision_id = revision[0].in_history(br).rev_id
 
300
            tree = br.repository.revision_tree(revision_id)
295
301
        else:
296
302
            revision_id = getattr(tree, 'get_revision_id', lambda: None)()
297
303
 
300
306
        window.set_title(path + " - gannotate")
301
307
        config = GAnnotateConfig(window)
302
308
        window.show()
303
 
        branch.lock_read()
 
309
        br.lock_read()
304
310
        try:
305
 
            window.annotate(tree, branch, file_id)
 
311
            window.annotate(tree, br, file_id)
306
312
        finally:
307
 
            branch.unlock()
 
313
            br.unlock()
308
314
        window.jump_to_line(line)
309
315
        
310
316
        gtk.main()
341
347
                                   StrictCommitFailed)
342
348
 
343
349
        wt = None
344
 
        branch = None
 
350
        br = None
345
351
        try:
346
 
            (wt, path) = WorkingTree.open_containing(filename)
347
 
            branch = wt.branch
 
352
            (wt, path) = workingtree.WorkingTree.open_containing(filename)
 
353
            br = wt.branch
348
354
        except NotBranchError, e:
349
355
            path = e.path
350
356
        except NoWorkingTree, e:
351
357
            path = e.base
352
358
            try:
353
 
                (branch, path) = Branch.open_containing(path)
 
359
                (br, path) = branch.Branch.open_containing(path)
354
360
            except NotBranchError, e:
355
361
                path = e.path
356
362
 
357
363
 
358
 
        commit = CommitDialog(wt, path, not branch)
 
364
        commit = CommitDialog(wt, path, not br)
359
365
        commit.run()
360
366
 
361
367
register_command(cmd_gcommit)
382
388
 
383
389
        set_ui_factory()
384
390
        from status import StatusDialog
385
 
        (wt, wt_path) = WorkingTree.open_containing(path)
 
391
        (wt, wt_path) = workingtree.WorkingTree.open_containing(path)
386
392
        status = StatusDialog(wt, wt_path)
387
393
        status.connect("destroy", gtk.main_quit)
388
394
        status.run()
389
395
 
390
396
register_command(cmd_gstatus)
391
397
 
 
398
class cmd_gconflicts(Command):
 
399
    """ GTK+ push.
 
400
    
 
401
    """
 
402
    def run(self):
 
403
        (wt, path) = workingtree.WorkingTree.open_containing('.')
 
404
        
 
405
        pygtk = import_pygtk()
 
406
        try:
 
407
            import gtk
 
408
        except RuntimeError, e:
 
409
            if str(e) == "could not open display":
 
410
                raise NoDisplayError
 
411
 
 
412
        from bzrlib.plugins.gtk.conflicts import ConflictsDialog
 
413
 
 
414
        set_ui_factory()
 
415
        dialog = ConflictsDialog(wt)
 
416
        dialog.run()
 
417
 
 
418
register_command(cmd_gconflicts)
392
419
 
393
420
import gettext
394
421
gettext.install('olive-gtk')