/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

Avoid reading everything into memory when accessing objects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
134
134
    :param object_iter: Iterator over Git objects.
135
135
    """
136
136
    # TODO: a more (memory-)efficient implementation of this
137
 
    objects = {}
138
 
    for i, (o, _) in enumerate(object_iter):
139
 
        if pb is not None:
140
 
            pb.update("fetching objects", i, len(object_iter)) 
141
 
        objects[o.id] = o
142
137
    graph = []
143
138
    root_trees = {}
144
139
    revisions = {}
145
140
    # Find and convert commit objects
146
 
    for o in objects.itervalues():
 
141
    for o in object_iter.iterobjects():
147
142
        if isinstance(o, Commit):
148
143
            rev = mapping.import_commit(o)
149
 
            root_trees[rev.revision_id] = objects[o.tree]
 
144
            root_trees[rev.revision_id] = object_iter[o.tree]
150
145
            revisions[rev.revision_id] = rev
151
146
            graph.append((rev.revision_id, rev.parent_ids))
152
147
    # Order the revisions
162
157
        inv = Inventory()
163
158
        inv.revision_id = rev.revision_id
164
159
        def lookup_object(sha):
165
 
            if sha in objects:
166
 
                return objects[sha]
 
160
            if sha in object_iter:
 
161
                return object_iter[sha]
167
162
            return reconstruct_git_object(repo, mapping, sha)
168
163
        parent_invs = [repo.get_inventory(r) for r in rev.parent_ids]
169
164
        import_git_tree(repo, mapping, "", root_tree, inv, parent_invs,