~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

VF.get_sha1s needed changing to be stackable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1036
1036
            missing.difference_update(set(new_result))
1037
1037
        return result
1038
1038
 
1039
 
    def _get_record_map(self, keys):
 
1039
    def _get_record_map(self, keys, allow_missing=False):
1040
1040
        """Produce a dictionary of knit records.
1041
1041
        
1042
1042
        :return: {key:(record, record_details, digest, next)}
1049
1049
            next
1050
1050
                build-parent of the version, i.e. the leftmost ancestor.
1051
1051
                Will be None if the record is not a delta.
 
1052
        :param keys: The keys to build a map for
 
1053
        :param allow_missing: If some records are missing, rather than 
 
1054
            error, just return the data that could be generated.
1052
1055
        """
1053
 
        position_map = self._get_components_positions(keys)
 
1056
        position_map = self._get_components_positions(keys,
 
1057
            noraise=allow_missing)
1054
1058
        # key = component_id, r = record_details, i_m = index_memo, n = next
1055
1059
        records = [(key, i_m) for key, (r, i_m, n)
1056
1060
                             in position_map.iteritems()]
1142
1146
 
1143
1147
    def get_sha1s(self, keys):
1144
1148
        """See VersionedFiles.get_sha1s()."""
1145
 
        record_map = self._get_record_map(keys)
1146
 
        # record entry 2 is the 'digest'.
1147
 
        return [record_map[key][2] for key in keys]
 
1149
        missing = set(keys)
 
1150
        record_map = self._get_record_map(missing, allow_missing=True)
 
1151
        result = {}
 
1152
        for key, details in record_map.iteritems():
 
1153
            if key not in missing:
 
1154
                continue
 
1155
            # record entry 2 is the 'digest'.
 
1156
            result[key] = details[2]
 
1157
        missing.difference_update(set(result))
 
1158
        for source in self._fallback_vfs:
 
1159
            if not missing:
 
1160
                break
 
1161
            new_result = source.get_sha1s(missing)
 
1162
            result.update(new_result)
 
1163
            missing.difference_update(set(new_result))
 
1164
        return result
1148
1165
 
1149
1166
    def insert_record_stream(self, stream):
1150
1167
        """Insert a record stream into this container.