17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
from cherrypy import HTTPRedirect, session
26
from cherrypy import HTTPError
30
28
from loggerhead import util
29
from loggerhead.templatefunctions import templatefunctions
33
32
log = logging.getLogger("loggerhead.controllers")
47
46
self.log = branch.log
49
48
@util.strip_whitespace
50
@turbogears.expose(html='loggerhead.templates.annotate')
49
@turbogears.expose(html='zpt:loggerhead.templates.annotate')
51
50
def default(self, *args, **kw):
53
52
h = self._branch.get_history()
54
53
util.set_context(kw)
57
revid = h.fix_revid(args[0])
61
file_id = kw.get('file_id', None)
63
raise HTTPRedirect(self._branch.url('/changes'))
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
# no navbar for revisions
73
navigation = util.Container()
75
path = h.get_path(revid, file_id)
76
filename = os.path.basename(path)
79
'branch': self._branch,
86
'navigation': navigation,
87
'change': h.get_changes([ revid ])[0],
88
'contents': list(h.annotate_file(file_id, revid)),
91
self.log.info('/annotate: %r secs' % (time.time() - z,))
58
revid = h.fix_revid(args[0])
64
path = '/'.join(args[1:])
65
if not path.startswith('/'):
68
file_id = kw.get('file_id', None)
69
if (file_id is None) and (path is None):
70
raise HTTPError(400, 'No file_id or filename provided to annotate')
73
file_id = h.get_file_id(revid, path)
75
# no navbar for revisions
76
navigation = util.Container()
79
path = h.get_path(revid, file_id)
80
filename = os.path.basename(path)
83
'branch': self._branch,
90
'navigation': navigation,
91
'change': h.get_changes([ revid ])[0],
92
'contents': list(h.annotate_file(file_id, revid)),
93
'url': self._branch.context_url,
95
vals.update(templatefunctions)
97
self.log.info('/annotate: %r secs' % (time.time() - z,))