2
# Copyright (C) 2006 Robey Pointer <robey@lag.net>
3
# Copyright (C) 2006 Goffredo Baroncelli <kreijack@inwind.it>
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
from cherrypy import InternalError, session
30
from loggerhead import util
33
log = logging.getLogger("loggerhead.controllers")
36
while path.endswith('/'):
38
path = posixpath.dirname(path)
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()
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)
67
inv = h.get_inventory(revid)
69
self.log.exception('Exception fetching changes')
70
raise InternalError('Could not fetch changes')
72
# no navbar for revisions
73
navigation = util.Container()
75
change = h.get_changes([ revid ])[0]
76
# add parent & merge-point branch-nick info, in case it's useful
77
h.get_branch_nicks([ change ])
79
path = inv.id2path(file_id)
80
if not path.startswith('/'):
82
idpath = inv.get_idpath(file_id)
85
updir_file_id = idpath[-2]
93
'branch': self._branch,
100
'updir_file_id': updir_file_id,
101
'filelist': h.get_filelist(inv, path, sort_type),
103
'posixpath': posixpath,
104
'navigation': navigation,
107
self.log.info('/inventory %r: %r secs' % (revid, time.time() - z))