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
@turbogears.expose(html='loggerhead.templates.annotate')
50
def default(self, *args, **kw):
52
h = self._branch.get_history()
36
class AnnotateUI (TemplatedBranchView):
38
template_path = 'loggerhead.templates.annotate'
40
def get_values(self, h, args, kw, headers):
55
42
revid = h.fix_revid(args[0])
48
path = '/'.join(args[1:])
49
if not path.startswith('/'):
59
52
file_id = kw.get('file_id', None)
53
if (file_id is None) and (path is None):
54
raise HTTPBadRequest('No file_id or filename provided to annotate')
60
56
if file_id is None:
61
raise HTTPRedirect(self._branch.url('/changes'))
57
file_id = h.get_file_id(revid, path)
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'))
70
59
# no navbar for revisions
71
60
navigation = util.Container()
73
path = h.get_path(revid, file_id)
63
path = h.get_path(revid, file_id)
74
64
filename = os.path.basename(path)
77
'branch': self._branch,
80
68
'file_id': file_id,
82
70
'filename': filename,
84
71
'navigation': navigation,
85
72
'change': h.get_changes([ revid ])[0],
86
73
'contents': list(h.annotate_file(file_id, revid)),
89
self.log.info('/annotate: %r secs' % (time.time() - z,))