2
# Copyright (C) 2010 Canonical Ltd.
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
from loggerhead.controllers.view_ui import ViewUI
20
from loggerhead import util
22
class AnnotateUI(ViewUI):
24
def annotate_file(self, info):
25
file_id = info['file_id']
26
revid = info['change'].revid
28
tree = self.tree_for(file_id, revid)
31
last_line_revid = None
33
for line_revid, text in tree.annotate_iter(file_id):
34
if line_revid == last_line_revid:
35
# remember which lines have a new revno and which don't
40
last_line_revid = line_revid
41
if line_revid in change_cache:
42
change = change_cache[line_revid]
44
change = self._history.get_changes([line_revid])[0]
45
change_cache[line_revid] = change
48
parity=parity, new_rev=new_rev, change=change)
50
def get_values(self, path, kwargs, headers):
51
values = super(AnnotateUI, self).get_values(path, kwargs, headers)
52
values['annotated'] = self.annotate_file(values)