17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
from paste.httpexceptions import HTTPServerError
28
from cherrypy import InternalError, session
25
30
from loggerhead import util
26
from loggerhead.controllers import TemplatedBranchView
29
33
log = logging.getLogger("loggerhead.controllers")
34
38
path = posixpath.dirname(path)
38
class InventoryUI(TemplatedBranchView):
40
template_path = 'loggerhead.templates.inventory'
42
def get_values(self, h, args, kw, response):
42
class InventoryUI (object):
44
def __init__(self, branch):
49
@util.strip_whitespace
50
@turbogears.expose(html='loggerhead.templates.inventory')
51
def default(self, *args, **kw):
53
h = self._branch.get_history()
44
57
revid = h.fix_revid(args[0])
61
file_id = kw.get('file_id', None)
62
sort_type = kw.get('sort', None)
65
revid_list, revid = h.get_file_view(revid, file_id)
66
rev = h.get_revision(revid)
49
67
inv = h.get_inventory(revid)
51
69
self.log.exception('Exception fetching changes')
52
raise HTTPServerError('Could not fetch changes')
54
file_id = kw.get('file_id', inv.root.file_id)
55
start_revid = kw.get('start_revid', None)
56
sort_type = kw.get('sort', None)
70
raise InternalError('Could not fetch changes')
58
72
# no navbar for revisions
59
73
navigation = util.Container()
61
75
change = h.get_changes([ revid ])[0]
62
76
# add parent & merge-point branch-nick info, in case it's useful
63
77
h.get_branch_nicks([ change ])
65
79
path = inv.id2path(file_id)
66
80
if not path.startswith('/'):
86
100
'updir_file_id': updir_file_id,
87
'filelist': h.get_filelist(inv, file_id, sort_type),
101
'filelist': h.get_filelist(inv, path, sort_type),
89
103
'posixpath': posixpath,
90
104
'navigation': navigation,
91
'url': self._branch.context_url,
92
'start_revid': start_revid,
107
self.log.info('/inventory %r: %r secs' % (revid, time.time() - z))