/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

Actually use shagitmap again to look up trees.

Show diffs side-by-side

added added

removed removed

Lines of Context:
205
205
    return ret
206
206
 
207
207
 
208
 
def import_git_tree(texts, mapping, path, hexsha, base_inv, base_inv_trees,
 
208
def import_git_tree(texts, mapping, path, hexsha, base_inv, 
209
209
    base_ie, parent_id, revision_id, parent_invs, shagitmap, lookup_object,
210
210
    allow_submodules=False):
211
211
    """Import a git tree object into a bzr repository.
229
229
    else:
230
230
        # See if this has changed at all
231
231
        try:
232
 
            base_sha = base_inv_trees[file_id]
233
 
        except KeyError:
 
232
            base_sha = shagitmap.lookup_tree(file_id, revision_id)
 
233
        except (KeyError, NotImplementedError):
234
234
            pass
235
235
        else:
236
236
            if base_sha == hexsha:
256
256
        if stat.S_ISDIR(mode):
257
257
            subinvdelta, grandchildmodes, subshamap = import_git_tree(
258
258
                    texts, mapping, child_path, child_hexsha, base_inv,
259
 
                    base_inv_trees, base_children.get(basename), file_id,
 
259
                    base_children.get(basename), file_id,
260
260
                    revision_id, parent_invs, shagitmap, lookup_object,
261
261
                    allow_submodules=allow_submodules)
262
262
            invdelta.extend(subinvdelta)
295
295
 
296
296
 
297
297
def import_git_commit(repo, mapping, head, lookup_object,
298
 
                      target_git_object_retriever, parent_invs_cache,
299
 
                      parent_inv_trees_cache):
 
298
                      target_git_object_retriever, parent_invs_cache):
300
299
    o = lookup_object(head)
301
300
    rev = mapping.import_commit(o)
302
301
    # We have to do this here, since we have to walk the tree and
313
312
    if parent_invs == []:
314
313
        base_inv = Inventory(root_id=None)
315
314
        base_ie = None
316
 
        base_inv_trees = {}
317
315
    else:
318
316
        base_inv = parent_invs[0]
319
317
        base_ie = base_inv.root
320
 
        base_inv_trees = parent_inv_trees_cache.get(rev.parent_ids[0], {})
321
318
    inv_delta, unusual_modes, shamap = import_git_tree(repo.texts,
322
 
            mapping, "", o.tree, base_inv, base_inv_trees, base_ie, None,
 
319
            mapping, "", o.tree, base_inv, base_ie, None,
323
320
            rev.revision_id, parent_invs, target_git_object_retriever._idmap,
324
321
            lookup_object,
325
322
            allow_submodules=getattr(repo._format, "supports_tree_reference", False))
326
 
    parent_inv_trees_cache[rev.revision_id] = dict(base_inv_trees.iteritems())
327
 
    parent_inv_trees_cache[rev.revision_id].update(dict(
328
 
        ((key[0], hexsha) for (hexsha, kind, key) in shamap if kind == "tree")))
329
323
    target_git_object_retriever._idmap.add_entries(shamap)
330
324
    if unusual_modes != {}:
331
325
        for path, mode in unusual_modes.iteritems():
376
370
    heads = list(set(heads))
377
371
    parent_invs_cache = lru_cache.LRUSizeCache(compute_size=approx_inv_size,
378
372
                                               max_size=MAX_INV_CACHE_SIZE)
379
 
    parent_inv_trees_cache = lru_cache.LRUSizeCache(
380
 
        compute_size=approx_inv_size, max_size=MAX_INV_CACHE_SIZE)
381
373
    target_git_object_retriever.start_write_group() # FIXME: try/finally
382
374
    # Find and convert commit objects
383
375
    while heads:
421
413
                    pb.update("fetching revisions", offset+i, len(revision_ids))
422
414
                import_git_commit(repo, mapping, head, lookup_object,
423
415
                                  target_git_object_retriever,
424
 
                                  parent_invs_cache, parent_inv_trees_cache)
 
416
                                  parent_invs_cache)
425
417
                last_imported = head
426
418
        except:
427
419
            repo.abort_write_group()