/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/gannotate.py

  • Committer: Martin Pool
  • Date: 2010-05-27 03:07:30 UTC
  • mfrom: (688.1.5 201956-help)
  • Revision ID: mbp@canonical.com-20100527030730-os0opv1xroetccm9
Make find/goto more discoverable

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import pango
24
24
import re
25
25
 
26
 
from bzrlib import patiencediff
 
26
from bzrlib import patiencediff, tsort
27
27
from bzrlib.errors import NoSuchRevision
28
28
from bzrlib.revision import NULL_REVISION, CURRENT_REVISION
29
29
 
30
 
from bzrlib.plugins.gtk.annotate.colormap import AnnotateColorSaturation
 
30
from colormap import AnnotateColorMap, AnnotateColorSaturation
31
31
from bzrlib.plugins.gtk.revisionview import RevisionView
32
32
from bzrlib.plugins.gtk.window import Window
33
33
 
49
49
        self.all = all
50
50
        self.plain = plain
51
51
        self._branch = branch
52
 
 
 
52
        
53
53
        Window.__init__(self, parent)
54
 
 
 
54
        
55
55
        self.set_icon(self.render_icon(gtk.STOCK_FIND, gtk.ICON_SIZE_BUTTON))
56
56
        self.annotate_colormap = AnnotateColorSaturation()
57
57
 
68
68
        self.revisionview.set_file_id(file_id)
69
69
        self.revision_id = getattr(tree, 'get_revision_id', 
70
70
                                   lambda: CURRENT_REVISION)()
71
 
 
 
71
        
72
72
        # [revision id, line number, author, revno, highlight color, line]
73
73
        self.annomodel = gtk.ListStore(gobject.TYPE_STRING,
74
 
                                       gobject.TYPE_INT,
 
74
                                       gobject.TYPE_STRING,
75
75
                                       gobject.TYPE_STRING,
76
76
                                       gobject.TYPE_STRING,
77
77
                                       gobject.TYPE_STRING,
78
78
                                       gobject.TYPE_STRING)
79
 
 
 
79
        
80
80
        last_seen = None
81
81
        try:
82
82
            branch.lock_read()
86
86
            for revision_id, revno in revno_map.iteritems():
87
87
                self.dotted[revision_id] = '.'.join(str(num) for num in revno)
88
88
            for line_no, (revision, revno, line)\
89
 
                in enumerate(self._annotate(tree, file_id)):
 
89
                    in enumerate(self._annotate(tree, file_id)):
90
90
                if revision.revision_id == last_seen and not self.all:
91
91
                    revno = author = ""
92
92
                else:
102
102
                                       revno,
103
103
                                       None,
104
104
                                       line.rstrip("\r\n")
105
 
                                       ])
 
105
                                      ])
106
106
                self.annotations.append(revision)
107
107
 
108
108
            if not self.plain:
125
125
            # bar?
126
126
            print("gannotate: Line number %d does't exist. Defaulting to "
127
127
                  "line 1." % lineno)
128
 
            return
 
128
            return
129
129
        else:
130
130
            row = lineno - 1
131
131
 
218
218
        hbox.pack_start(self.goto_button, expand=False, fill=True)
219
219
        hbox.show()
220
220
        vbox.pack_start(hbox, expand=False, fill=True)
221
 
 
 
221
        
222
222
        self.pane = pane = gtk.VPaned()
223
223
        pane.add1(swbox)
224
224
        pane.add2(self.revisionview)
260
260
            else:
261
261
                tree2 = repository.revision_tree(NULL_REVISION)
262
262
        from bzrlib.plugins.gtk.diff import DiffWindow
263
 
        window = DiffWindow(self)
 
263
        window = DiffWindow()
264
264
        window.set_diff("Diff for line %d" % (row+1), tree1, tree2)
265
265
        window.set_file(tree1.id2path(self.file_id))
266
266
        window.show()
318
318
        col.add_attribute(cell, "text", TEXT_LINE_COL)
319
319
        tv.append_column(col)
320
320
 
321
 
        # interactive substring search
322
 
        def search_equal_func(model, column, key, iter):
323
 
            return model.get_value(iter, TEXT_LINE_COL).lower().find(key.lower()) == -1
324
 
 
325
 
        tv.set_enable_search(True)
326
 
        tv.set_search_equal_func(search_equal_func)
 
321
        # FIXME: Now that C-f is now used for search by text we
 
322
        # may as well disable the auto search.
 
323
        tv.set_search_column(LINE_NUM_COL)
327
324
 
328
325
        return tv
329
326
 
535
532
 
536
533
    def _match(self, model, iterator, column):
537
534
        matching_case = self._match_case.get_active()
538
 
        cell_value, = model.get(iterator, column)
 
535
        string, = model.get(iterator, column)
539
536
        key = self._entry.get_text()
540
 
        if column == LINE_NUM_COL:
541
 
            # FIXME: For goto-line there are faster algorithms than searching 
542
 
            # every line til we find the right one! -- mbp 2011-01-27
543
 
            return key.strip() == str(cell_value)
544
 
        elif self._regexp.get_active():
 
537
        if self._regexp.get_active():
545
538
            if matching_case:
546
 
                match = re.compile(key).search(cell_value, 1)
 
539
                match = re.compile(key).search(string, 1)
547
540
            else:
548
 
                match = re.compile(key, re.I).search(cell_value, 1)
 
541
                match = re.compile(key, re.I).search(string, 1)
549
542
        else:
550
543
            if not matching_case:
551
 
                cell_value = cell_value.lower()
 
544
                string = string.lower()
552
545
                key = key.lower()
553
 
            match = cell_value.find(key) != -1
 
546
            match = string.find(key) != -1
554
547
 
555
548
        return match
556
549