/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: Aaron Bentley
  • Date: 2007-01-17 06:42:55 UTC
  • mto: This revision was merged to the branch mainline in revision 129.
  • Revision ID: aaron.bentley@utoronto.ca-20070117064255-x4gznz5e0lyjq3gk
Remove usused span selector

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 
15
15
"""GTK+ frontends to Bazaar commands """
16
16
 
 
17
from bzrlib import errors
17
18
from bzrlib.commands import Command, register_command, display_command
18
19
from bzrlib.errors import NotVersionedError, BzrCommandError, NoSuchFile
19
20
from bzrlib.commands import Command, register_command
22
23
from bzrlib.workingtree import WorkingTree
23
24
from bzrlib.bzrdir import BzrDir
24
25
 
25
 
__version__ = '0.11.0'
 
26
__version__ = '0.13.0'
26
27
 
27
28
class cmd_gbranch(Command):
28
29
    """GTK+ branching.
38
39
            if str(e) == "could not open display":
39
40
                raise NoDisplayError
40
41
 
41
 
        from clone import CloneDialog
 
42
        from bzrlib.plugins.gtk.olive.branch import BranchDialog
42
43
 
43
 
        window = CloneDialog()
44
 
        if window.run() == gtk.RESPONSE_OK:
45
 
            bzrdir = BzrDir.open(window.url)
46
 
            bzrdir.sprout(window.dest_path)
 
44
        window = BranchDialog('.')
 
45
        window.display()
47
46
 
48
47
register_command(cmd_gbranch)
49
48
 
73
72
            tree1 = wt
74
73
            tree2 = tree1.basis_tree()
75
74
 
76
 
        from bzrlib.plugins.gtk.viz.diffwin import DiffWindow
 
75
        from viz.diffwin import DiffWindow
77
76
        import gtk
78
77
        window = DiffWindow()
79
78
        window.connect("destroy", lambda w: gtk.main_quit())
80
79
        window.set_diff("Working Tree", tree1, tree2)
81
80
        if filename is not None:
82
 
            tree_filename = tree1.relpath(filename)
 
81
            tree_filename = wt.relpath(filename)
83
82
            try:
84
83
                window.set_file(tree_filename)
85
84
            except NoSuchFile:
145
144
        Option("all", help="show annotations on all lines"),
146
145
        Option("plain", help="don't highlight annotation lines"),
147
146
        Option("line", type=int, argname="lineno",
148
 
               help="jump to specified line number")
 
147
               help="jump to specified line number"),
 
148
        "revision",
149
149
    ]
150
150
    aliases = ["gblame", "gpraise"]
151
151
    
152
 
    def run(self, filename, all=False, plain=False, line='1'):
 
152
    def run(self, filename, all=False, plain=False, line='1', revision=None):
153
153
        import pygtk
154
154
        pygtk.require("2.0")
155
155
 
168
168
        from annotate.gannotate import GAnnotateWindow
169
169
        from annotate.config import GAnnotateConfig
170
170
 
171
 
        (wt, path) = WorkingTree.open_containing(filename)
172
 
        branch = wt.branch
 
171
        try:
 
172
            (tree, path) = WorkingTree.open_containing(filename)
 
173
            branch = tree.branch
 
174
        except errors.NoWorkingTree:
 
175
            (branch, path) = Branch.open_containing(filename)
 
176
            tree = branch.basis_tree()
173
177
 
174
 
        file_id = wt.path2id(path)
 
178
        file_id = tree.path2id(path)
175
179
 
176
180
        if file_id is None:
177
181
            raise NotVersionedError(filename)
 
182
        if revision is not None:
 
183
            if len(revision) != 1:
 
184
                raise BzrCommandError("Only 1 revion may be specified.")
 
185
            revision_id = revision[0].in_history(branch).rev_id
 
186
            tree = branch.repository.revision_tree(revision_id)
 
187
        else:
 
188
            revision_id = getattr(tree, 'get_revision_id', lambda: None)()
178
189
 
179
190
        window = GAnnotateWindow(all, plain)
180
191
        window.connect("destroy", lambda w: gtk.main_quit())
183
194
        window.show()
184
195
        branch.lock_read()
185
196
        try:
186
 
            window.annotate(branch, file_id)
 
197
            window.annotate(tree, branch, file_id)
187
198
        finally:
188
199
            branch.unlock()
189
200
        window.jump_to_line(line)
201
212
    takes_options = []
202
213
 
203
214
    def run(self, filename=None):
 
215
        import os
204
216
        import pygtk
205
217
        pygtk.require("2.0")
206
218
 
210
222
            if str(e) == "could not open display":
211
223
                raise NoDisplayError
212
224
 
213
 
        from commit import GCommitDialog
 
225
        from olive.commit import CommitDialog
214
226
        from bzrlib.commit import Commit
215
 
        from bzrlib.errors import (BzrCommandError, PointlessCommit, ConflictsInTree, 
216
 
           StrictCommitFailed)
217
 
 
218
 
        (wt, path) = WorkingTree.open_containing(filename)
219
 
        branch = wt.branch
220
 
 
221
 
        file_id = wt.path2id(path)
222
 
 
223
 
        if file_id is None:
224
 
            raise NotVersionedError(filename)
225
 
 
226
 
        dialog = GCommitDialog(wt)
227
 
        dialog.set_title(path + " - Commit")
228
 
        if dialog.run() != gtk.RESPONSE_CANCEL:
229
 
            Commit().commit(working_tree=wt,message=dialog.message,
230
 
                specific_files=dialog.specific_files)
 
227
        from bzrlib.errors import (BzrCommandError,
 
228
                                   NotBranchError,
 
229
                                   NoWorkingTree,
 
230
                                   PointlessCommit,
 
231
                                   ConflictsInTree,
 
232
                                   StrictCommitFailed)
 
233
 
 
234
        wt = None
 
235
        branch = None
 
236
        try:
 
237
            (wt, path) = WorkingTree.open_containing(filename)
 
238
            branch = wt.branch
 
239
        except NotBranchError, e:
 
240
            path = e.path
 
241
        except NoWorkingTree, e:
 
242
            path = e.base
 
243
            try:
 
244
                (branch, path) = Branch.open_containing(path)
 
245
            except NotBranchError, e:
 
246
                path = e.path
 
247
 
 
248
        dialog = CommitDialog(wt, path, not branch)
 
249
        if dialog.display():
 
250
            dialog.window.connect("destroy", lambda w: gtk.main_quit())
 
251
            gtk.main()
231
252
 
232
253
register_command(cmd_gcommit)
233
254