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)
36
class AnnotateUI (TemplatedBranchView):
38
template_path = 'loggerhead.templates.annotate'
40
def get_values(self, h, args, kw, response):
42
class AnnotateUI (object):
44
@turbogears.expose(html='loggerhead.templates.annotate')
45
def default(self, *args, **kw):
47
h = util.get_history()
42
50
revid = h.fix_revid(args[0])
48
path = '/'.join(args[1:])
49
if not path.startswith('/'):
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')
57
file_id = h.get_file_id(revid, path)
54
path = kw.get('path', None)
55
if (path == '/') or (path == '') or (path is None):
56
raise HTTPRedirect(turbogears.url('/changes'))
59
revlist, revid = h.get_navigation(revid, path)
60
file_id = h.get_inventory(revid).path2id(path)
62
log.error('Exception fetching changes: %r, %s' % (x, x))
63
raise HTTPRedirect(turbogears.url('/changes'))
59
65
# no navbar for revisions
60
66
navigation = util.Container()
63
path = h.get_path(revid, file_id)
64
filename = os.path.basename(path)
69
'branch_name': util.get_config().get('branch_name'),
71
74
'navigation': navigation,
72
'change': h.get_changes([ revid ])[0],
75
'change': h.get_change(revid),
73
76
'contents': list(h.annotate_file(file_id, revid)),
79
log.info('/annotate: %r secs' % (time.time() - z,))