17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
from cherrypy import HTTPRedirect, session
23
from paste.httpexceptions import HTTPBadRequest
25
from loggerhead.controllers import TemplatedBranchView
30
26
from loggerhead import util
33
log = logging.getLogger("loggerhead.controllers")
36
30
while path.endswith('/'):
38
32
path = posixpath.dirname(path)
42
class AnnotateUI (object):
44
def __init__(self, branch):
49
@util.strip_whitespace
50
@turbogears.expose(html='loggerhead.templates.annotate')
51
def default(self, *args, **kw):
53
h = self._branch.get_history()
35
class AnnotateUI (TemplatedBranchView):
37
template_path = 'loggerhead.templates.annotate'
39
def get_values(self, h, args, kw, headers):
57
41
revid = h.fix_revid(args[0])
47
path = '/'.join(args[1:])
48
if not path.startswith('/'):
61
51
file_id = kw.get('file_id', None)
52
if (file_id is None) and (path is None):
53
raise HTTPBadRequest('No file_id or filename provided to annotate')
62
55
if file_id is None:
63
raise HTTPRedirect(self._branch.url('/changes'))
56
file_id = h.get_file_id(revid, path)
66
revid_list, revid = h.get_file_view(revid, file_id)
68
self.log.error('Exception fetching changes: %s' % (x,))
69
util.log_exception(self.log)
70
raise HTTPRedirect(self._branch.url('/changes'))
72
58
# no navbar for revisions
73
59
navigation = util.Container()
75
path = h.get_path(revid, file_id)
62
path = h.get_path(revid, file_id)
76
63
filename = os.path.basename(path)
79
'branch': self._branch,
82
67
'file_id': file_id,
84
69
'filename': filename,
86
70
'navigation': navigation,
87
71
'change': h.get_changes([ revid ])[0],
88
72
'contents': list(h.annotate_file(file_id, revid)),
73
'fileview_active': True,
91
self.log.info('/annotate: %r secs' % (time.time() - z,))