~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/inventory_ui.py

  • Committer: Marius Kruger
  • Date: 2008-09-06 20:17:56 UTC
  • mto: This revision was merged to the branch mainline in revision 219.
  • Revision ID: amanic@gmail.com-20080906201756-ocqnga9vu1uj425t
Add alternative insallation notes and mention the --prefix option in README.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import logging
21
21
import posixpath
22
22
 
23
 
from paste.httpexceptions import HTTPNotFound, HTTPServerError
24
 
 
25
 
from bzrlib.revision import is_null as is_null_rev
 
23
from paste.httpexceptions import HTTPServerError
26
24
 
27
25
from loggerhead import util
28
26
from loggerhead.controllers import TemplatedBranchView
47
45
        else:
48
46
            revid = h.last_revid
49
47
 
 
48
        try:
 
49
            inv = h.get_inventory(revid)
 
50
        except:
 
51
            self.log.exception('Exception fetching changes')
 
52
            raise HTTPServerError('Could not fetch changes')
 
53
 
 
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)
 
57
 
50
58
        # no navbar for revisions
51
59
        navigation = util.Container()
52
 
        # Directory Breadcrumbs
53
 
        directory_breadcrumbs = util.directory_breadcrumbs(
54
 
                self._branch.friendly_name,
55
 
                self._branch.is_root,
56
 
                'files')
57
 
 
58
 
        if not is_null_rev(revid):
59
 
            try:
60
 
                inv = h.get_inventory(revid)
61
 
            except:
62
 
                self.log.exception('Exception fetching changes')
63
 
                raise HTTPServerError('Could not fetch changes')
64
 
 
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)
68
 
 
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 ])
72
 
 
73
 
            path = inv.id2path(file_id)
74
 
            if not path.startswith('/'):
75
 
                path = '/' + path
76
 
            idpath = inv.get_idpath(file_id)
77
 
            if len(idpath) > 1:
78
 
                updir = dirname(path)
79
 
                updir_file_id = idpath[-2]
80
 
            else:
81
 
                updir = None
82
 
                updir_file_id = None
83
 
            if updir == '/':
84
 
                updir_file_id = None
85
 
 
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)
 
60
 
 
61
        change = h.get_changes([ revid ])[0]
 
62
        # add parent & merge-point branch-nick info, in case it's useful
 
63
        h.get_branch_nicks([ change ])
 
64
 
 
65
        path = inv.id2path(file_id)
 
66
        if not path.startswith('/'):
 
67
            path = '/' + path
 
68
        idpath = inv.get_idpath(file_id)
 
69
        if len(idpath) > 1:
 
70
            updir = dirname(path)
 
71
            updir_file_id = idpath[-2]
89
72
        else:
90
 
            inv = None
91
 
            file_id = None
92
 
            start_revid = None
93
 
            sort_type = None
94
 
            change = None
95
 
            path = "/"
96
 
            idpath = None
97
73
            updir = None
98
74
            updir_file_id = None
99
 
            branch_breadcrumbs = []
100
 
            filelist = []
 
75
        if updir == '/':
 
76
            updir_file_id = None
101
77
 
102
78
        return {
103
79
            'branch': self._branch,
108
84
            'path': path,
109
85
            'updir': updir,
110
86
            'updir_file_id': updir_file_id,
111
 
            'filelist': filelist,
 
87
            'filelist': h.get_filelist(inv, file_id, sort_type),
112
88
            'history': h,
113
89
            'posixpath': posixpath,
114
90
            'navigation': navigation,
115
91
            'url': self._branch.context_url,
116
92
            'start_revid': start_revid,
117
93
            'fileview_active': True,
118
 
            'directory_breadcrumbs': directory_breadcrumbs,
119
 
            'branch_breadcrumbs': branch_breadcrumbs,
120
94
        }