17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
from cherrypy import HTTPRedirect, session
25
from cherrypy import InternalError
30
27
from loggerhead import util
28
from loggerhead.templatefunctions import templatefunctions
33
31
log = logging.getLogger("loggerhead.controllers")
42
40
class InventoryUI (object):
44
@turbogears.expose(html='loggerhead.templates.inventory')
42
def __init__(self, branch):
47
@util.strip_whitespace
48
@turbogears.expose(html='zpt:loggerhead.templates.inventory')
45
49
def default(self, *args, **kw):
47
h = util.get_history()
50
revid = h.fix_revid(args[0])
54
path = kw.get('path', None)
55
if (path == '/') or (path == ''):
51
h = self._branch.get_history()
59
revlist, revid = h.get_navigation(revid, path)
60
rev = h.get_revision(revid)
61
inv = h.get_inventory(revid)
63
log.error('Exception fetching changes: %r, %s' % (x, x))
64
raise HTTPRedirect(turbogears.url('/changes'))
70
file_id = inv.path2id(path)
72
# no navbar for revisions
73
navigation = util.Container()
75
# add parent & merge-point branch-nick info, in case it's useful
76
change = h.get_change(revid)
77
for p in change.parents:
78
p.branch_nick = h.get_change(p.revid).branch_nick
79
for p in change.merge_points:
80
p.branch_nick = h.get_change(p.revid).branch_nick
83
'branch_name': util.get_config().get('branch_name'),
88
'updir': dirname(path),
89
'filelist': h.get_filelist(inv, path),
91
'posixpath': posixpath,
92
'navigation': navigation,
95
log.info('/inventory %r: %r secs' % (revid, time.time() - z))
57
revid = h.fix_revid(args[0])
62
inv = h.get_inventory(revid)
64
self.log.exception('Exception fetching changes')
65
raise InternalError('Could not fetch changes')
67
file_id = kw.get('file_id', inv.root.file_id)
68
start_revid = kw.get('start_revid', None)
69
sort_type = kw.get('sort', None)
71
# no navbar for revisions
72
navigation = util.Container()
74
change = h.get_changes([ revid ])[0]
75
# add parent & merge-point branch-nick info, in case it's useful
76
h.get_branch_nicks([ change ])
78
path = inv.id2path(file_id)
79
if not path.startswith('/'):
81
idpath = inv.get_idpath(file_id)
84
updir_file_id = idpath[-2]
92
'branch': self._branch,
99
'updir_file_id': updir_file_id,
100
'filelist': h.get_filelist(inv, file_id, sort_type),
102
'posixpath': posixpath,
103
'navigation': navigation,
104
'url': self._branch.context_url,
105
'start_revid': start_revid,
107
vals.update(templatefunctions)
109
self.log.info('/inventory %r: %r secs' % (revid, time.time() - z))