/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead/controllers/annotate_ui.py

merge from less-file-change-access.  i resolved a lot of conflicts but i'm
sure i missed something.  use at own risk for now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 = h.last_revid
60
 
 
61
 
        path = None
62
 
        if len(args) > 1:
63
 
            path = '/'.join(args[1:])
64
 
            if not path.startswith('/'):
65
 
                path = '/' + path
66
 
        
67
 
        file_id = kw.get('file_id', None)
68
 
        if (file_id is None) and (path is None):
69
 
            raise HTTPError(400, 'No file_id or filename provided to annotate')
70
 
 
71
 
        if file_id is None:
72
 
            file_id = h.get_file_id(revid, path)
73
 
            
74
 
        # no navbar for revisions
75
 
        navigation = util.Container()
76
 
        
77
 
        if path is None:
78
 
            path = h.get_path(revid, file_id)
79
 
        filename = os.path.basename(path)
80
 
 
81
 
        vals = {
82
 
            'branch': self._branch,
83
 
            'util': util,
84
 
            'revid': revid,
85
 
            'file_id': file_id,
86
 
            'path': path,
87
 
            'filename': filename,
88
 
            'history': h,
89
 
            'navigation': navigation,
90
 
            'change': h.get_changes([ revid ])[0],
91
 
            'contents': list(h.annotate_file(file_id, revid)),
92
 
        }
93
 
        h.flush_cache()
94
 
        self.log.info('/annotate: %r secs' % (time.time() - z,))
95
 
        return vals
 
55
 
 
56
        h._branch.lock_read()
 
57
        try:
 
58
            if len(args) > 0:
 
59
                revid = h.fix_revid(args[0])
 
60
            else:
 
61
                revid = h.last_revid
 
62
 
 
63
            path = None
 
64
            if len(args) > 1:
 
65
                path = '/'.join(args[1:])
 
66
                if not path.startswith('/'):
 
67
                    path = '/' + path
 
68
 
 
69
            file_id = kw.get('file_id', None)
 
70
            if (file_id is None) and (path is None):
 
71
                raise HTTPError(400, 'No file_id or filename provided to annotate')
 
72
 
 
73
            if file_id is None:
 
74
                file_id = h.get_file_id(revid, path)
 
75
 
 
76
            # no navbar for revisions
 
77
            navigation = util.Container()
 
78
 
 
79
            if path is None:
 
80
                path = h.get_path(revid, file_id)
 
81
            filename = os.path.basename(path)
 
82
 
 
83
            vals = {
 
84
                'branch': self._branch,
 
85
                'util': util,
 
86
                'revid': revid,
 
87
                'file_id': file_id,
 
88
                'path': path,
 
89
                'filename': filename,
 
90
                'history': h,
 
91
                'navigation': navigation,
 
92
                'change': h.get_changes([ revid ])[0],
 
93
                'contents': list(h.annotate_file(file_id, revid)),
 
94
            }
 
95
            h.flush_cache()
 
96
            self.log.info('/annotate: %r secs' % (time.time() - z,))
 
97
            return vals
 
98
        finally:
 
99
            h._branch.unlock()