1
# Copyright (C) 2005 Dan Loda <danloda@gmail.com>
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
__version__ = "0.7pre"
18
__author__ = "Dan Loda <danloda@gmail.com>"
20
from bzrlib.workingtree import WorkingTree
21
from bzrlib.commands import Command, register_command
22
from bzrlib.errors import NotVersionedError, BzrCommandError
23
from bzrlib.option import Option
26
class cmd_gannotate(Command):
29
Browse changes to FILENAME line by line in a GTK+ window.
32
takes_args = ["filename"]
34
Option("all", help="show annotations on all lines"),
35
Option("plain", help="don't highlight annotation lines"),
36
Option("line", type=int, argname="lineno",
37
help="jump to specified line number")
39
aliases = ["gblame", "gpraise"]
41
def run(self, filename, all=False, plain=False, line=1):
47
except RuntimeError, e:
48
if str(e) == "could not open display":
51
from gannotate import GAnnotateWindow
52
from config import GAnnotateConfig
54
(wt, path) = WorkingTree.open_containing(filename)
57
file_id = wt.path2id(path)
60
raise NotVersionedError(filename)
62
window = GAnnotateWindow(all, plain)
63
window.connect("destroy", lambda w: gtk.main_quit())
64
window.set_title(path + " - gannotate")
65
config = GAnnotateConfig(window)
69
window.annotate(branch, file_id)
72
window.jump_to_line(line)
77
register_command(cmd_gannotate)
80
class NoDisplayError(BzrCommandError):
81
"""gtk could not find a proper display"""
84
return "No DISPLAY. gannotate is disabled."