~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/inventory_ui.py

  • Committer: Robey Pointer
  • Date: 2007-01-24 18:45:06 UTC
  • Revision ID: robey@lag.net-20070124184506-k58akd932ohgn7h3
clean up homepage for 1.1 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import time
26
26
 
27
27
import turbogears
28
 
from cherrypy import InternalError, session
 
28
from cherrypy import HTTPRedirect, session
29
29
 
30
30
from loggerhead import util
31
31
 
52
52
        z = time.time()
53
53
        h = self._branch.get_history()
54
54
        util.set_context(kw)
 
55
        
 
56
        if len(args) > 0:
 
57
            revid = h.fix_revid(args[0])
 
58
        else:
 
59
            revid = None
 
60
        
 
61
        file_id = kw.get('file_id', None)
 
62
        sort_type = kw.get('sort', None)
55
63
 
56
 
        h._branch.lock_read()
57
64
        try:
58
 
            if len(args) > 0:
59
 
                revid = h.fix_revid(args[0])
60
 
            else:
61
 
                revid = h.last_revid
62
 
 
63
 
            try:
64
 
                inv = h.get_inventory(revid)
65
 
            except:
66
 
                self.log.exception('Exception fetching changes')
67
 
                raise InternalError('Could not fetch changes')
68
 
 
69
 
            file_id = kw.get('file_id', inv.root.file_id)
70
 
            sort_type = kw.get('sort', None)
71
 
 
72
 
            # no navbar for revisions
73
 
            navigation = util.Container()
74
 
 
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 ])
78
 
 
79
 
            path = inv.id2path(file_id)
80
 
            if not path.startswith('/'):
81
 
                path = '/' + path
82
 
            idpath = inv.get_idpath(file_id)
83
 
            if len(idpath) > 1:
84
 
                updir = dirname(path)
85
 
                updir_file_id = idpath[-2]
86
 
            else:
87
 
                updir = None
88
 
                updir_file_id = None
89
 
            if updir == '/':
90
 
                updir_file_id = None
91
 
 
92
 
            vals = {
93
 
                'branch': self._branch,
94
 
                'util': util,
95
 
                'revid': revid,
96
 
                'change': change,
97
 
                'file_id': file_id,
98
 
                'path': path,
99
 
                'updir': updir,
100
 
                'updir_file_id': updir_file_id,
101
 
                'filelist': h.get_filelist(inv, file_id, sort_type),
102
 
                'history': h,
103
 
                'posixpath': posixpath,
104
 
                'navigation': navigation,
105
 
            }
106
 
            h.flush_cache()
107
 
            self.log.info('/inventory %r: %r secs' % (revid, time.time() - z))
108
 
            return vals
109
 
        finally:
110
 
            h._branch.unlock()
 
65
            revid_list, revid = h.get_file_view(revid, file_id)
 
66
            rev = h.get_revision(revid)
 
67
            inv = h.get_inventory(revid)
 
68
        except Exception, x:
 
69
            self.log.error('Exception fetching changes: %s' % (x,))
 
70
            util.log_exception(self.log)
 
71
            raise HTTPRedirect(self._branch.url('/changes'))
 
72
 
 
73
        # no navbar for revisions
 
74
        navigation = util.Container()
 
75
 
 
76
        change = h.get_changes([ revid ])[0]
 
77
        # add parent & merge-point branch-nick info, in case it's useful
 
78
        h.get_branch_nicks([ change ])
 
79
        
 
80
        path = inv.id2path(file_id)
 
81
        if not path.startswith('/'):
 
82
            path = '/' + path
 
83
        idpath = inv.get_idpath(file_id)
 
84
        if len(idpath) > 1:
 
85
            updir = dirname(path)
 
86
            updir_file_id = idpath[-2]
 
87
        else:
 
88
            updir = None
 
89
            updir_file_id = None
 
90
        if updir == '/':
 
91
            updir_file_id = None
 
92
 
 
93
        vals = {
 
94
            'branch': self._branch,
 
95
            'util': util,
 
96
            'revid': revid,
 
97
            'change': change,
 
98
            'file_id': file_id,
 
99
            'path': path,
 
100
            'updir': updir,
 
101
            'updir_file_id': updir_file_id,
 
102
            'filelist': h.get_filelist(inv, path, sort_type),
 
103
            'history': h,
 
104
            'posixpath': posixpath,
 
105
            'navigation': navigation,
 
106
        }
 
107
        h.flush_cache()
 
108
        self.log.info('/inventory %r: %r secs' % (revid, time.time() - z))
 
109
        return vals