/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

Add FOSDEM roundtripping notes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
            raise AssertionError("Unknown blob kind, perms=%r." % (mode,))
127
127
 
128
128
 
129
 
def import_git_objects(repo, mapping, num_objects, object_iter, pb=None):
 
129
def import_git_objects(repo, mapping, object_iter, pb=None):
130
130
    """Import a set of git objects into a bzr repository.
131
131
 
132
132
    :param repo: Bazaar repository
133
133
    :param mapping: Mapping to use
134
 
    :param num_objects: Number of objects.
135
134
    :param object_iter: Iterator over Git objects.
136
135
    """
137
136
    # TODO: a more (memory-)efficient implementation of this
138
 
    objects = {}
139
 
    for i, (o, _) in enumerate(object_iter):
140
 
        if pb is not None:
141
 
            pb.update("fetching objects", i, num_objects) 
142
 
        objects[o.id] = o
143
137
    graph = []
144
138
    root_trees = {}
145
139
    revisions = {}
146
140
    # Find and convert commit objects
147
 
    for o in objects.itervalues():
 
141
    for o in object_iter.iterobjects():
148
142
        if isinstance(o, Commit):
149
143
            rev = mapping.import_commit(o)
150
 
            root_trees[rev.revision_id] = objects[o.tree]
 
144
            root_trees[rev.revision_id] = object_iter[o.tree]
151
145
            revisions[rev.revision_id] = rev
152
146
            graph.append((rev.revision_id, rev.parent_ids))
153
147
    # Order the revisions
163
157
        inv = Inventory()
164
158
        inv.revision_id = rev.revision_id
165
159
        def lookup_object(sha):
166
 
            if sha in objects:
167
 
                return objects[sha]
 
160
            if sha in object_iter:
 
161
                return object_iter[sha]
168
162
            return reconstruct_git_object(repo, mapping, sha)
169
163
        parent_invs = [repo.get_inventory(r) for r in rev.parent_ids]
170
164
        import_git_tree(repo, mapping, "", root_tree, inv, parent_invs, 
224
218
            try:
225
219
                self.target.start_write_group()
226
220
                try:
227
 
                    (num_objects, objects_iter) = \
228
 
                            self.source.fetch_objects(determine_wants, 
 
221
                    objects_iter = self.source.fetch_objects(determine_wants, 
229
222
                                graph_walker, progress)
230
 
                    import_git_objects(self.target, mapping, num_objects, 
231
 
                                       objects_iter, pb)
 
223
                    import_git_objects(self.target, mapping, objects_iter, pb)
232
224
                finally:
233
225
                    self.target.commit_write_group()
234
226
            finally: