/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

Return inventory entries when creating git objects for a revision.

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
    :param parent_invshamaps: parent inventory SHA Map
122
122
    :param unusual_modes: Unusual file modes
123
123
    :param iter_files_bytes: Repository.iter_files_bytes-like callback
124
 
    :return: Yields (path, object) entries
 
124
    :return: Yields (path, object, ie) entries
125
125
    """
126
126
    new_trees = {}
127
127
    new_blobs = []
155
155
                        ie.symlink_target == pie.symlink_target):
156
156
                        break
157
157
            else:
158
 
                yield path, blob
 
158
                yield path, blob, ie
159
159
                new_trees[urlutils.dirname(path)] = ie.parent_id
160
160
            shamap[ie.file_id] = blob.id
161
161
        elif ie.kind == "directory":
179
179
        else:
180
180
            raise AssertionError(ie.kind)
181
181
    
182
 
    for (path, fid), chunks in iter_files_bytes(
 
182
    for (path, ie), chunks in iter_files_bytes(
183
183
        [(ie.file_id, ie.revision, (path, ie.file_id))
184
184
            for (path, ie) in new_blobs]):
185
185
        obj = Blob()
186
186
        obj.data = "".join(chunks)
187
 
        yield path, obj
188
 
        shamap[fid] = obj.id
 
187
        yield path, obj, ie
 
188
        shamap[ie.file_id] = obj.id
189
189
 
190
190
    for fid in unusual_modes:
191
191
        new_trees[inv.id2path(fid)] = inv[fid].parent_id
217
217
        assert ie.kind == "directory"
218
218
        obj = directory_to_tree(ie, ie_to_hexsha, unusual_modes)
219
219
        if obj is not None:
220
 
            yield path, obj
 
220
            yield path, obj, ie
221
221
            shamap[ie.file_id] = obj.id
222
222
 
223
223
 
293
293
            [p for p in rev.parent_ids if p in present_parents])
294
294
        parent_invshamaps = [self._idmap.get_inventory_sha_map(r) for r in rev.parent_ids if r in present_parents]
295
295
        tree_sha = None
296
 
        for path, obj in _inventory_to_objects(inv, parent_invs,
 
296
        for path, obj, ie in _inventory_to_objects(inv, parent_invs,
297
297
                parent_invshamaps, unusual_modes,
298
298
                self.repository.iter_files_bytes, has_ghost_parents):
299
 
            yield path, obj
 
299
            yield path, obj, ie
300
300
            if path == "":
301
301
                tree_sha = obj.id
302
302
        if tree_sha is None:
311
311
            pass
312
312
        else:
313
313
            _check_expected_sha(foreign_revid, commit_obj)
314
 
        yield None, commit_obj
 
314
        yield None, commit_obj, None
315
315
 
316
316
    def _update_sha_map_revision(self, revid):
317
317
        rev = self.repository.get_revision(revid)
318
318
        inv = self.parent_invs_cache.get_inventory(rev.revision_id)
319
319
        commit_obj = None
320
320
        entries = []
321
 
        for path, obj in self._revision_to_objects(rev, inv):
 
321
        for path, obj, ie in self._revision_to_objects(rev, inv):
322
322
            if obj.type_name == "commit":
323
323
                commit_obj = obj
324
324
            elif obj.type_name in ("blob", "tree"):
325
 
                file_id = inv.path2id(path)
326
 
                ie = inv[file_id]
327
325
                if obj.type_name == "blob":
328
326
                    revision = ie.revision
329
327
                else:
330
328
                    revision = revid
331
 
                entries.append((file_id, obj.type_name, obj.id, revision))
 
329
                entries.append((ie.file_id, obj.type_name, obj.id, revision))
332
330
            else:
333
331
                raise AssertionError
334
332
        self._idmap.add_entries(revid, rev.parent_ids, commit_obj.id, 
513
511
                pb.update("generating git objects", i, len(todo))
514
512
                rev = self.repository.get_revision(revid)
515
513
                inv = self.parent_invs_cache.get_inventory(revid)
516
 
                for path, obj in self._revision_to_objects(rev, inv):
 
514
                for path, obj, ie in self._revision_to_objects(rev, inv):
517
515
                    ret.append((obj, path))
518
516
        finally:
519
517
            pb.finished()