/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 fetch.py

Cache trees rather than inventories.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
from bzrlib.revision import (
54
54
    NULL_REVISION,
55
55
    )
 
56
from bzrlib.revisiontree import (
 
57
    RevisionTree,
 
58
    )
56
59
from bzrlib.tsort import (
57
60
    topo_sort,
58
61
    )
70
73
    )
71
74
from bzrlib.plugins.git.object_store import (
72
75
    BazaarObjectStore,
73
 
    LRUInventoryCache,
 
76
    LRUTreeCache,
74
77
    )
75
78
from bzrlib.plugins.git.remote import (
76
79
    RemoteGitRepository,
272
275
 
273
276
 
274
277
def import_git_commit(repo, mapping, head, lookup_object,
275
 
                      target_git_object_retriever, parent_invs_cache):
 
278
                      target_git_object_retriever, trees_cache):
276
279
    o = lookup_object(head)
277
280
    rev = mapping.import_commit(o)
278
281
    # We have to do this here, since we have to walk the tree and
279
282
    # we need to make sure to import the blobs / trees with the right
280
283
    # path; this may involve adding them more than once.
281
 
    parent_invs = parent_invs_cache.get_inventories(rev.parent_ids)
282
 
    if parent_invs == []:
 
284
    parent_trees = trees_cache.revision_trees(rev.parent_ids)
 
285
    if parent_trees == []:
283
286
        base_inv = Inventory(root_id=None)
284
287
        base_tree = None
285
288
        base_mode = None
286
289
    else:
287
 
        base_inv = parent_invs[0]
 
290
        base_inv = parent_trees[0].inventory
288
291
        base_tree = lookup_object(o.parents[0]).tree
289
292
        base_mode = stat.S_IFDIR
290
293
    store_updater = target_git_object_retriever._get_updater(rev)
291
294
    store_updater.add_object(o, None)
292
295
    inv_delta, unusual_modes = import_git_tree(repo.texts,
293
296
            mapping, "", u"", (base_tree, o.tree), base_inv, 
294
 
            None, rev.revision_id, parent_invs, lookup_object,
295
 
            (base_mode, stat.S_IFDIR), store_updater,
 
297
            None, rev.revision_id, [p.inventory for p in parent_trees],
 
298
            lookup_object, (base_mode, stat.S_IFDIR), store_updater,
296
299
            allow_submodules=getattr(repo._format, "supports_tree_reference", False))
297
300
    store_updater.finish()
298
301
    if unusual_modes != {}:
307
310
    rev.inventory_sha1, inv = repo.add_inventory_by_delta(basis_id,
308
311
              inv_delta, rev.revision_id, rev.parent_ids,
309
312
              base_inv)
310
 
    parent_invs_cache.add(rev.revision_id, inv)
 
313
    trees_cache.add(RevisionTree(repo, inv, rev.revision_id))
311
314
    repo.add_revision(rev.revision_id, rev)
312
315
    if "verify" in debug.debug_flags:
313
316
        new_unusual_modes = mapping.export_unusual_file_modes(rev)
341
344
    graph = []
342
345
    checked = set()
343
346
    heads = list(set(heads))
344
 
    parent_invs_cache = LRUInventoryCache(repo)
 
347
    trees_cache = LRUTreeCache(repo)
345
348
    # Find and convert commit objects
346
349
    while heads:
347
350
        if pb is not None:
386
389
                                  len(revision_ids))
387
390
                    import_git_commit(repo, mapping, head, lookup_object,
388
391
                                      target_git_object_retriever,
389
 
                                      parent_invs_cache)
 
392
                                      trees_cache)
390
393
                    last_imported = head
391
394
            except:
392
395
                repo.abort_write_group()