/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to object_store.py

Eliminate InventorySHAMap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
            expected_sha))
113
113
 
114
114
 
115
 
def _inventory_to_objects(inv, parent_invs, parent_invshamaps,
 
115
def _inventory_to_objects(inv, parent_invs, idmap,
116
116
        unusual_modes, iter_files_bytes, has_ghost_parents):
117
117
    """Iterate over the objects that were introduced in a revision.
118
118
 
119
119
    :param inv: Inventory to process
120
120
    :param parent_invs: parent inventory SHA maps
121
 
    :param parent_invshamaps: parent inventory SHA Map
 
121
    :param idmap: id map
122
122
    :param unusual_modes: Unusual file modes
123
123
    :param iter_files_bytes: Repository.iter_files_bytes-like callback
124
124
    :return: Yields (path, object, ie) entries
129
129
    for path, ie in inv.entries():
130
130
        if ie.kind == "file":
131
131
            if ie.revision != inv.revision_id:
132
 
                for (pinv, pinvshamap) in zip(parent_invs, parent_invshamaps):
 
132
                for pinv in parent_invs:
133
133
                    try:
134
134
                        pie = pinv[ie.file_id]
135
135
                    except errors.NoSuchId:
137
137
                    else:
138
138
                        if (pie.text_sha1 == ie.text_sha1 and 
139
139
                            pie.kind == ie.kind):
140
 
                            shamap[ie.file_id] = pinvshamap.lookup_blob_id(
 
140
                            shamap[ie.file_id] = idmap.lookup_blob_id(
141
141
                                pie.file_id, pie.revision)
142
142
                            break
143
143
            if not ie.file_id in shamap:
159
159
                new_trees[urlutils.dirname(path)] = ie.parent_id
160
160
            shamap[ie.file_id] = blob.id
161
161
        elif ie.kind == "directory":
162
 
            for (pinv, pinvshamap) in zip(parent_invs, parent_invshamaps):
 
162
            for pinv in parent_invs:
163
163
                try:
164
164
                    pie = pinv[ie.file_id]
165
165
                except errors.NoSuchId:
168
168
                    if (pie.kind == ie.kind and 
169
169
                        pie.children.keys() == ie.children.keys()):
170
170
                        try:
171
 
                            shamap[ie.file_id] = pinvshamap.lookup_tree_id(
 
171
                            shamap[ie.file_id] = idmap.lookup_tree_id(
172
172
                                ie.file_id)
173
173
                        except (NotImplementedError, KeyError):
174
174
                            pass
325
325
        has_ghost_parents = (len(rev.parent_ids) < len(present_parents))
326
326
        parent_invs = self.parent_invs_cache.get_inventories(
327
327
            [p for p in rev.parent_ids if p in present_parents])
328
 
        parent_invshamaps = [self._idmap.get_inventory_sha_map(r) for r in rev.parent_ids if r in present_parents]
329
328
        tree_sha = None
330
329
        for path, obj, ie in _inventory_to_objects(inv, parent_invs,
331
 
                parent_invshamaps, unusual_modes,
 
330
                self._idmap, unusual_modes,
332
331
                self.repository.iter_files_bytes, has_ghost_parents):
333
332
            yield path, obj, ie
334
333
            if path == "":
337
336
            if not rev.parent_ids:
338
337
                tree_sha = Tree().id
339
338
            else:
340
 
                tree_sha = parent_invshamaps[0][inv.root.file_id]
 
339
                raise AssertionError
341
340
        commit_obj = self._revision_to_commit(rev, tree_sha)
342
341
        try:
343
 
            foreign_revid, mapping = mapping_registry.parse_revision_id(rev.revision_id)
 
342
            foreign_revid, mapping = mapping_registry.parse_revision_id(
 
343
                rev.revision_id)
344
344
        except errors.InvalidRevisionId:
345
345
            pass
346
346
        else:
383
383
        :param fileid: fileid in the tree.
384
384
        :param revision: Revision of the tree.
385
385
        """
386
 
        invshamap = self._idmap.get_inventory_sha_map(inv.revision_id)
387
386
        def get_ie_sha1(entry):
388
387
            if entry.kind == "directory":
389
388
                try:
390
 
                    return invshamap.lookup_tree_id(entry.file_id)
 
389
                    return self._idmap.lookup_tree_id(entry.file_id)
391
390
                except (NotImplementedError, KeyError):
392
391
                    obj = self._get_tree(entry.file_id, revid, inv,
393
392
                        unusual_modes)
396
395
                    else:
397
396
                        return obj.id
398
397
            elif entry.kind in ("file", "symlink"):
399
 
                return invshamap.lookup_blob_id(entry.file_id, entry.revision)
 
398
                return self._idmap.lookup_blob_id(entry.file_id, entry.revision)
400
399
            else:
401
400
                raise AssertionError("unknown entry kind '%s'" % entry.kind)
402
401
        tree = directory_to_tree(inv[fileid], get_ie_sha1, unusual_modes)