/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: Szilveszter Farkas (Phanatic)
  • Date: 2006-12-01 18:02:11 UTC
  • mfrom: (66.2.6 trunk)
  • Revision ID: szilveszter.farkas@gmail.com-20061201180211-hakaxu53l6eodq2i
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import gtk
23
23
import pango
24
24
 
 
25
from bzrlib import tsort
25
26
from bzrlib.errors import NoSuchRevision
26
27
from bzrlib.revision import NULL_REVISION
27
28
 
57
58
        if self.plain:
58
59
            self.span_selector.hide()
59
60
 
60
 
    def annotate(self, branch, file_id):
 
61
    def annotate(self, branch, file_id, revision_id=None):
61
62
        self.revisions = {}
62
63
        self.annotations = []
63
64
        self.branch = branch
64
65
        self.file_id = file_id
 
66
        self.revision_id = revision_id
65
67
        
66
68
        # [revision id, line number, committer, revno, highlight color, line]
67
69
        self.annomodel = gtk.ListStore(gobject.TYPE_STRING,
76
78
            branch.lock_read()
77
79
            branch.repository.lock_read()
78
80
            for line_no, (revision, revno, line)\
79
 
                    in enumerate(self._annotate(branch, file_id)):
 
81
                    in enumerate(self._annotate(branch, file_id, revision_id)):
80
82
                if revision.revision_id == last_seen and not self.all:
81
83
                    revno = committer = ""
82
84
                else:
121
123
        self.annoview.set_cursor(row)
122
124
        self.annoview.scroll_to_cell(row, use_align=True)
123
125
 
124
 
    def _annotate(self, branch, file_id):
125
 
        rev_hist = branch.revision_history()
 
126
    def _dotted_revnos(self, repository, revision_id):
 
127
        """Return a dict of revision_id -> dotted revno
 
128
        
 
129
        :param repository: The repository to get the graph from
 
130
        :param revision_id: The last revision for which this info is needed
 
131
        """
 
132
        graph = repository.get_revision_graph(revision_id)
 
133
        dotted = {}
 
134
        for n, revision_id, d, revno, e in tsort.merge_sort(graph, 
 
135
            revision_id, generate_revno=True):
 
136
            dotted[revision_id] = '.'.join(str(num) for num in revno)
 
137
        return dotted
 
138
 
 
139
    def _annotate(self, branch, file_id, revision_id):
126
140
        repository = branch.repository
127
 
        rev_tree = repository.revision_tree(branch.last_revision())
128
 
        rev_id = rev_tree.inventory[file_id].revision
 
141
        if revision_id is None:
 
142
            revision_id = branch.last_revision()
 
143
        dotted = self._dotted_revnos(repository, revision_id)
 
144
        rev_tree = repository.revision_tree(revision_id)
 
145
        revision_id = rev_tree.inventory[file_id].revision
129
146
        weave = repository.weave_store.get_weave(file_id,
130
147
                                                 branch.get_transaction())
131
148
        
132
149
        revision_cache = RevisionCache(repository)
133
 
        for origin, text in weave.annotate_iter(rev_id):
 
150
        for origin, text in weave.annotate_iter(revision_id):
134
151
            rev_id = origin
135
152
            try:
136
153
                revision = revision_cache.get_revision(rev_id)
137
 
                if rev_id in rev_hist:
138
 
                    revno = branch.revision_id_to_revno(rev_id)
139
 
                else:
140
 
                    revno = "merge"
 
154
                revno = dotted.get(rev_id, 'merge')
 
155
                if len(revno) > 15:
 
156
                    revno = 'merge'
141
157
            except NoSuchRevision:
142
158
                revision = NoneRevision(rev_id)
143
159
                revno = "?"