/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: 2006-06-19 16:38:46 UTC
  • mfrom: (59.2.4 bzr-gtk)
  • Revision ID: jelmer@samba.org-20060619163846-16ecedf9ca4b3d1f
[merge] gannotate/gdiff improvements from Aaron.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""GTK+ frontends to Bazaar commands """
18
18
from bzrlib.commands import Command, register_command, display_command
19
 
from bzrlib.errors import NotVersionedError, BzrCommandError
 
19
from bzrlib.errors import NotVersionedError, BzrCommandError, NoSuchFile
20
20
from bzrlib.commands import Command, register_command
21
21
from bzrlib.option import Option
22
22
from bzrlib.branch import Branch
51
51
    
52
52
    Otherwise, all changes for the tree are listed.
53
53
    """
54
 
    takes_args = []
 
54
    takes_args = ['filename?']
55
55
    takes_options = ['revision']
56
56
 
57
57
    @display_command
58
 
    def run(self, revision=None, file_list=None):
 
58
    def run(self, revision=None, filename=None):
59
59
        wt = WorkingTree.open_containing(".")[0]
60
60
        branch = wt.branch
61
61
        if revision is not None:
77
77
        window = DiffWindow()
78
78
        window.connect("destroy", lambda w: gtk.main_quit())
79
79
        window.set_diff("Working Tree", tree1, tree2)
 
80
        if filename is not None:
 
81
            tree_filename = tree1.relpath(filename)
 
82
            try:
 
83
                window.set_file(tree_filename)
 
84
            except NoSuchFile:
 
85
                if (tree1.inventory.path2id(tree_filename) is None and 
 
86
                    tree2.inventory.path2id(tree_filename) is None):
 
87
                    raise NotVersionedError(filename)
 
88
                raise BzrCommandError('No changes found for file "%s"' % 
 
89
                                      filename)
80
90
        window.show()
81
91
 
82
92
        gtk.main()
129
139
    Browse changes to FILENAME line by line in a GTK+ window.
130
140
    """
131
141
 
132
 
    takes_args = ["filename"]
 
142
    takes_args = ["filename", "line?"]
133
143
    takes_options = [
134
144
        Option("all", help="show annotations on all lines"),
135
145
        Option("plain", help="don't highlight annotation lines"),
138
148
    ]
139
149
    aliases = ["gblame", "gpraise"]
140
150
    
141
 
    def run(self, filename, all=False, plain=False, line=1):
 
151
    def run(self, filename, all=False, plain=False, line='1'):
142
152
        import pygtk
143
153
        pygtk.require("2.0")
144
154
 
148
158
            if str(e) == "could not open display":
149
159
                raise NoDisplayError
150
160
 
 
161
        try:
 
162
            line = int(line)
 
163
        except ValueError:
 
164
            raise BzrCommandError('Line argument ("%s") is not a number.' % 
 
165
                                  line)
 
166
 
151
167
        from annotate.gannotate import GAnnotateWindow
152
168
        from annotate.config import GAnnotateConfig
153
169