~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/changelog_ui.py

  • Committer: Michael Hudson
  • Date: 2007-05-30 09:03:52 UTC
  • mfrom: (128.1.15 testing)
  • Revision ID: michael.hudson@canonical.com-20070530090352-2hdhyvs7jxgpoz1e
merge in the fix for #92435 too

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
        z = time.time()
40
40
        h = self._branch.get_history()
41
41
        config = self._branch.config
 
42
        
 
43
        if len(args) > 0:
 
44
            revid = h.fix_revid(args[0])
 
45
        else:
 
46
            revid = None
42
47
 
43
 
        h._branch.lock_read()
 
48
        file_id = kw.get('file_id', None)
 
49
        query = kw.get('q', None)
 
50
        start_revid = h.fix_revid(kw.get('start_revid', None))
 
51
        orig_start_revid = start_revid
 
52
        pagesize = int(config.get('pagesize', '20'))
 
53
        search_failed = False
 
54
        
44
55
        try:
45
 
            if len(args) > 0:
46
 
                revid = h.fix_revid(args[0])
 
56
            revid, start_revid, revid_list = h.get_view(revid, start_revid, file_id, query)
 
57
            kw['start_revid'] = start_revid
 
58
            util.set_context(kw)
 
59
            
 
60
            if (query is not None) and (len(revid_list) == 0):
 
61
                search_failed = True
 
62
 
 
63
            if len(revid_list) == 0:
 
64
                scan_list = revid_list
47
65
            else:
48
 
                revid = None
49
 
 
50
 
            file_id = kw.get('file_id', None)
51
 
            query = kw.get('q', None)
52
 
            start_revid = h.fix_revid(kw.get('start_revid', None))
53
 
            orig_start_revid = start_revid
54
 
            pagesize = int(config.get('pagesize', '20'))
55
 
            search_failed = False
56
 
 
57
 
            try:
58
 
                revid, start_revid, revid_list = h.get_view(revid, start_revid, file_id, query)
59
 
                kw['start_revid'] = start_revid
60
 
                util.set_context(kw)
61
 
 
62
 
                if (query is not None) and (len(revid_list) == 0):
63
 
                    search_failed = True
64
 
 
65
 
                if len(revid_list) == 0:
66
 
                    scan_list = revid_list
67
 
                else:
68
 
                    if revid in revid_list: # XXX is this always true?
69
 
                        i = revid_list.index(revid)
70
 
                    else:
71
 
                        i = None
72
 
                    scan_list = revid_list[i:]
73
 
                change_list = scan_list[:pagesize]
74
 
                changes = list(h.get_changes(change_list))
75
 
                h.add_changes(changes)
76
 
            except:
77
 
                self.log.exception('Exception fetching changes')
78
 
                raise InternalError('Could not fetch changes')
79
 
 
80
 
            navigation = util.Container(pagesize=pagesize, revid=revid, start_revid=start_revid, revid_list=revid_list,
81
 
                                        file_id=file_id, scan_url='/changes', branch=self._branch, feed=True)
82
 
            if query is not None:
83
 
                navigation.query = query
84
 
            util.fill_in_navigation(navigation)
85
 
 
86
 
            # add parent & merge-point branch-nick info, in case it's useful
87
 
            h.get_branch_nicks(changes)
88
 
 
89
 
            # does every change on this page have the same committer?  if so,
90
 
            # tell the template to show committer info in the "details block"
91
 
            # instead of on each line.
92
 
            all_same_author = True
93
 
 
94
 
            if changes:
95
 
                author = changes[0].author
96
 
                for e in changes[1:]:
97
 
                    if e.author != author:
98
 
                        all_same_author = False
99
 
                        break
100
 
 
101
 
            vals = {
102
 
                'branch': self._branch,
103
 
                'changes': changes,
104
 
                'util': util,
105
 
                'history': h,
106
 
                'revid': revid,
107
 
                'navigation': navigation,
108
 
                'file_id': file_id,
109
 
                'start_revid': start_revid,
110
 
                'viewing_from': (orig_start_revid is not None) and (orig_start_revid != h.last_revid),
111
 
                'query': query,
112
 
                'search_failed': search_failed,
113
 
                'all_same_author': all_same_author,
114
 
            }
115
 
            h.flush_cache()
116
 
            self.log.info('/changes %r: %r secs' % (revid, time.time() - z))
117
 
            return vals
118
 
        finally:
119
 
            h._branch.unlock()
 
66
                scan_list = revid_list[h.get_revid_sequence(revid_list, revid):]
 
67
            entry_list = scan_list[:pagesize]
 
68
            entries = h.get_changes(entry_list)
 
69
        except:
 
70
##             import sys
 
71
##             print sys.exc_info()[2]
 
72
##             import pdb; pdb.post_mortem(sys.exc_info()[2])
 
73
            self.log.exception('Exception fetching changes')
 
74
            raise InternalError('Could not fetch changes')
 
75
 
 
76
        navigation = util.Container(pagesize=pagesize, revid=revid, start_revid=start_revid, revid_list=revid_list,
 
77
                                    file_id=file_id, scan_url='/changes', branch=self._branch, feed=True)
 
78
        if query is not None:
 
79
            navigation.query = query
 
80
        util.fill_in_navigation(h, navigation)
 
81
        
 
82
        entries = list(entries)
 
83
        # add parent & merge-point branch-nick info, in case it's useful
 
84
        h.get_branch_nicks(entries)
 
85
 
 
86
        vals = {
 
87
            'branch': self._branch,
 
88
            'changes': list(entries),
 
89
            'util': util,
 
90
            'history': h,
 
91
            'revid': revid,
 
92
            'navigation': navigation,
 
93
            'file_id': file_id,
 
94
            'start_revid': start_revid,
 
95
            'viewing_from': (orig_start_revid is not None) and (orig_start_revid != h.last_revid),
 
96
            'query': query,
 
97
            'search_failed': search_failed,
 
98
        }
 
99
        h.flush_cache()
 
100
        self.log.info('/changes %r: %r secs' % (revid, time.time() - z))
 
101
        return vals