/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

mention the requirement to install Dulwich.

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, object_iter, pb=None):
 
129
def import_git_objects(repo, mapping, num_objects, 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.
134
135
    :param object_iter: Iterator over Git objects.
135
136
    """
136
137
    # 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
137
143
    graph = []
138
144
    root_trees = {}
139
145
    revisions = {}
140
146
    # Find and convert commit objects
141
 
    for o in object_iter.iterobjects():
 
147
    for o in objects.itervalues():
142
148
        if isinstance(o, Commit):
143
149
            rev = mapping.import_commit(o)
144
 
            root_trees[rev.revision_id] = object_iter[o.tree]
 
150
            root_trees[rev.revision_id] = objects[o.tree]
145
151
            revisions[rev.revision_id] = rev
146
152
            graph.append((rev.revision_id, rev.parent_ids))
147
153
    # Order the revisions
157
163
        inv = Inventory()
158
164
        inv.revision_id = rev.revision_id
159
165
        def lookup_object(sha):
160
 
            if sha in object_iter:
161
 
                return object_iter[sha]
 
166
            if sha in objects:
 
167
                return objects[sha]
162
168
            return reconstruct_git_object(repo, mapping, sha)
163
169
        parent_invs = [repo.get_inventory(r) for r in rev.parent_ids]
164
170
        import_git_tree(repo, mapping, "", root_tree, inv, parent_invs, 
218
224
            try:
219
225
                self.target.start_write_group()
220
226
                try:
221
 
                    objects_iter = self.source.fetch_objects(determine_wants, 
 
227
                    (num_objects, objects_iter) = \
 
228
                            self.source.fetch_objects(determine_wants, 
222
229
                                graph_walker, progress)
223
 
                    import_git_objects(self.target, mapping, objects_iter, pb)
 
230
                    import_git_objects(self.target, mapping, num_objects, 
 
231
                                       objects_iter, pb)
224
232
                finally:
225
233
                    self.target.commit_write_group()
226
234
            finally: