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