/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/changecache.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:
87
87
        else:
88
88
            cache = shelve.open(self._changes_filename, 'c', protocol=2)
89
89
 
90
 
        out = []
91
 
        fetch_list = []
92
 
        sfetch_list = []
93
 
        for revid in revid_list:
94
 
            # if the revid is in unicode, use the utf-8 encoding as the key
95
 
            srevid = util.to_utf8(revid)
96
 
            
97
 
            if srevid in cache:
98
 
                out.append(cache[srevid])
99
 
            else:
100
 
                #self.log.debug('Entry cache miss: %r' % (revid,))
101
 
                out.append(None)
102
 
                fetch_list.append(revid)
103
 
                sfetch_list.append(srevid)
104
 
        
105
 
        if len(fetch_list) > 0:
106
 
            # some revisions weren't in the cache; fetch them
107
 
            changes = self.history.get_changes_uncached(fetch_list, get_diffs)
108
 
            if changes is None:
109
 
                return changes
110
 
            for i in xrange(len(revid_list)):
111
 
                if out[i] is None:
112
 
                    cache[sfetch_list.pop(0)] = out[i] = changes.pop(0)
113
 
        
114
 
        cache.close()
115
 
        return out
 
90
        try:
 
91
            out = []
 
92
            fetch_list = []
 
93
            sfetch_list = []
 
94
            for revid in revid_list:
 
95
                # if the revid is in unicode, use the utf-8 encoding as the key
 
96
                srevid = util.to_utf8(revid)
 
97
 
 
98
                if srevid in cache:
 
99
                    out.append(cache[srevid])
 
100
                else:
 
101
                    #self.log.debug('Entry cache miss: %r' % (revid,))
 
102
                    out.append(None)
 
103
                    fetch_list.append(revid)
 
104
                    sfetch_list.append(srevid)
 
105
 
 
106
            if len(fetch_list) > 0:
 
107
                # some revisions weren't in the cache; fetch them
 
108
                changes = self.history.get_changes_uncached(fetch_list, get_diffs)
 
109
                if len(changes) == 0:
 
110
                    return changes
 
111
                for i in xrange(len(revid_list)):
 
112
                    if out[i] is None:
 
113
                        cache[sfetch_list.pop(0)] = out[i] = changes.pop(0)
 
114
            return out
 
115
        finally:
 
116
            cache.close()
116
117
    
117
118
    @with_lock
118
119
    def full(self, get_diffs=False):