14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
__version__ = "0.7pre"
17
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."