/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 annotate/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2012-07-09 15:23:26 UTC
  • mto: This revision was merged to the branch mainline in revision 794.
  • Revision ID: jelmer@samba.org-20120709152326-dzxb8zoz0btull7n
Remove bzr-notify.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
16
16
 
17
 
__version__ = "0.7pre"
18
17
__author__ = "Dan Loda <danloda@gmail.com>"
19
18
 
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
24
 
 
25
 
 
26
 
class cmd_gannotate(Command):
27
 
    """GTK+ annotate.
28
 
    
29
 
    Browse changes to FILENAME line by line in a GTK+ window.
30
 
    """
31
 
 
32
 
    takes_args = ["filename"]
33
 
    takes_options = [
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")
38
 
    ]
39
 
    aliases = ["gblame", "gpraise"]
40
 
    
41
 
    def run(self, filename, all=False, plain=False, line=1):
42
 
        import pygtk
43
 
        pygtk.require("2.0")
44
 
 
45
 
        try:
46
 
            import gtk
47
 
        except RuntimeError, e:
48
 
            if str(e) == "could not open display":
49
 
                raise NoDisplayError
50
 
 
51
 
        from gannotate import GAnnotateWindow
52
 
        from config import GAnnotateConfig
53
 
 
54
 
        (wt, path) = WorkingTree.open_containing(filename)
55
 
        branch = wt.branch
56
 
 
57
 
        file_id = wt.path2id(path)
58
 
 
59
 
        if file_id is None:
60
 
            raise NotVersionedError(filename)
61
 
 
62
 
        window = GAnnotateWindow(all, plain)
63
 
        window.connect("destroy", lambda w: gtk.main_quit())
64
 
        window.set_title(path + " - gannotate")
65
 
        config = GAnnotateConfig(window)
66
 
        window.show()
67
 
        branch.lock_read()
68
 
        try:
69
 
            window.annotate(branch, file_id)
70
 
        finally:
71
 
            branch.unlock()
72
 
        window.jump_to_line(line)
73
 
        
74
 
        gtk.main()
75
 
 
76
 
 
77
 
register_command(cmd_gannotate)
78
 
 
79
 
 
80
 
class NoDisplayError(BzrCommandError):
81
 
    """gtk could not find a proper display"""
82
 
 
83
 
    def __str__(self):
84
 
        return "No DISPLAY. gannotate is disabled."
85