17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
from paste.httpexceptions import HTTPServerError
25
from bzrlib.revision import is_null as is_null_rev
28
from cherrypy import InternalError, session
27
30
from loggerhead import util
28
from loggerhead.controllers import TemplatedBranchView
31
33
log = logging.getLogger("loggerhead.controllers")
36
38
path = posixpath.dirname(path)
40
class InventoryUI(TemplatedBranchView):
42
template_path = 'loggerhead.templates.inventory'
44
def get_values(self, h, args, kw, headers):
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()
46
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')
50
72
# no navbar for revisions
51
73
navigation = util.Container()
52
# Directory Breadcrumbs
53
directory_breadcrumbs = util.directory_breadcrumbs(
54
self._branch.friendly_name,
58
if not is_null_rev(revid):
60
inv = h.get_inventory(revid)
62
self.log.exception('Exception fetching changes')
63
raise HTTPServerError('Could not fetch changes')
65
file_id = kw.get('file_id', inv.root.file_id)
66
start_revid = kw.get('start_revid', None)
67
sort_type = kw.get('sort', None)
69
change = h.get_changes([ revid ])[0]
70
# add parent & merge-point branch-nick info, in case it's useful
71
h.get_branch_nicks([ change ])
73
path = inv.id2path(file_id)
74
if not path.startswith('/'):
76
idpath = inv.get_idpath(file_id)
79
updir_file_id = idpath[-2]
86
# Create breadcrumb trail for the path within the branch
87
branch_breadcrumbs = util.branch_breadcrumbs(path, inv, 'files')
88
filelist = h.get_filelist(inv, file_id, sort_type)
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]
98
88
updir_file_id = None
99
branch_breadcrumbs = []
103
93
'branch': self._branch,
110
100
'updir_file_id': updir_file_id,
111
'filelist': filelist,
101
'filelist': h.get_filelist(inv, path, sort_type),
113
103
'posixpath': posixpath,
114
104
'navigation': navigation,
115
'url': self._branch.context_url,
116
'start_revid': start_revid,
117
'fileview_active': True,
118
'directory_breadcrumbs': directory_breadcrumbs,
119
'branch_breadcrumbs': branch_breadcrumbs,
107
self.log.info('/inventory %r: %r secs' % (revid, time.time() - z))