58
59
self.span_selector.hide()
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
66
68
# [revision id, line number, committer, revno, highlight color, line]
67
69
self.annomodel = gtk.ListStore(gobject.TYPE_STRING,
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 = ""
121
123
self.annoview.set_cursor(row)
122
124
self.annoview.scroll_to_cell(row, use_align=True)
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
129
:param repository: The repository to get the graph from
130
:param revision_id: The last revision for which this info is needed
132
graph = repository.get_revision_graph(revision_id)
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)
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())
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):
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)
154
revno = dotted.get(rev_id, 'merge')
141
157
except NoSuchRevision:
142
158
revision = NoneRevision(rev_id)