~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/changecache.py

  • Committer: Robey Pointer
  • Date: 2007-05-21 07:43:39 UTC
  • Revision ID: robey@lag.net-20070521074339-3wh6r0grwfzkvspj
bug 98826: allow "head:" to be used as a valid revid to represent the current
branch head.

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
 
        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)
 
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)
105
96
            
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 changes is None:
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()
 
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
117
116
    
118
117
    @with_lock
119
118
    def full(self, get_diffs=False):