/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

Remove last references to ID.children.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
    )
80
80
 
81
81
 
82
 
def import_git_blob(texts, mapping, path, basename, (base_hexsha, hexsha), 
83
 
        base_inv, base_inv_shamap, base_ie, parent_id, revision_id,
 
82
def import_git_blob(texts, mapping, path, name, (base_hexsha, hexsha), 
 
83
        base_inv, base_inv_shamap, parent_id, revision_id,
84
84
        parent_invs, lookup_object, (base_mode, mode)):
85
85
    """Import a git blob object into a bzr repository.
86
86
 
97
97
        cls = InventoryLink
98
98
    else:
99
99
        cls = InventoryFile
100
 
    ie = cls(file_id, basename, parent_id)
 
100
    ie = cls(file_id, name.decode("utf-8"), parent_id)
101
101
    ie.executable = mode_is_executable(mode)
102
 
    if base_hexsha == hexsha and base_ie.kind == ie.kind:
 
102
    if base_hexsha == hexsha and mode_kind(base_mode) == mode_kind(mode):
 
103
        base_ie = base_inv[base_inv.path2id(path)]
103
104
        ie.text_size = base_ie.text_size
104
105
        ie.text_sha1 = base_ie.text_sha1
105
106
        ie.symlink_target = base_ie.symlink_target
164
165
    internal = False
165
166
 
166
167
 
167
 
def import_git_submodule(texts, mapping, path, basename, (base_hexsha, hexsha),
 
168
def import_git_submodule(texts, mapping, path, name, (base_hexsha, hexsha),
168
169
    base_inv, parent_id, revision_id, parent_invs, lookup_object,
169
170
    (base_mode, mode)):
170
171
    if base_hexsha == hexsha and base_mode == mode:
171
172
        return [], {}, {}
172
173
    file_id = mapping.generate_file_id(path)
173
 
    ie = TreeReference(file_id, basename, parent_id)
 
174
    ie = TreeReference(file_id, name.decode("utf-8"), parent_id)
174
175
    ie.revision = revision_id
175
176
    if base_hexsha is None:
176
177
        oldpath = None
196
197
    return ret
197
198
 
198
199
 
199
 
def import_git_tree(texts, mapping, path, basename, (base_hexsha, hexsha),
200
 
        base_inv, base_inv_shamap, base_ie, parent_id, revision_id, parent_invs,
 
200
def import_git_tree(texts, mapping, path, name, (base_hexsha, hexsha),
 
201
        base_inv, base_inv_shamap, parent_id, revision_id, parent_invs,
201
202
    lookup_object, (base_mode, mode), allow_submodules=False):
202
203
    """Import a git tree object into a bzr repository.
203
204
 
213
214
    invdelta = []
214
215
    file_id = mapping.generate_file_id(path)
215
216
    # We just have to hope this is indeed utf-8:
216
 
    ie = InventoryDirectory(file_id, basename, parent_id)
 
217
    ie = InventoryDirectory(file_id, name.decode("utf-8"), parent_id)
217
218
    tree = lookup_object(hexsha)
218
219
    if base_hexsha is None:
219
220
        base_tree = None
232
233
        invdelta.append((old_path, path, ie.file_id, ie))
233
234
    else:
234
235
        old_path = path # Renames aren't supported yet
235
 
    if base_ie is not None and base_ie.kind == "directory":
236
 
        base_children = base_ie.children
237
 
    else:
238
 
        base_children = {}
239
236
    # Remember for next time
240
237
    existing_children = set()
241
238
    child_modes = {}
242
239
    shamap = {}
243
240
    for child_mode, name, child_hexsha in tree.entries():
244
 
        basename = name.decode("utf-8")
245
241
        existing_children.add(name)
246
242
        child_path = posixpath.join(path, name)
247
243
        if type(base_tree) is Tree:
255
251
            child_base_mode = 0
256
252
        if stat.S_ISDIR(child_mode):
257
253
            subinvdelta, grandchildmodes, subshamap = import_git_tree(
258
 
                    texts, mapping, child_path, basename,
 
254
                    texts, mapping, child_path, name,
259
255
                    (child_base_hexsha, child_hexsha),
260
 
                    base_inv, base_inv_shamap, base_children.get(basename),
 
256
                    base_inv, base_inv_shamap, 
261
257
                    file_id, revision_id, parent_invs, lookup_object,
262
258
                    (child_base_mode, child_mode),
263
259
                    allow_submodules=allow_submodules)
265
261
            if not allow_submodules:
266
262
                raise SubmodulesRequireSubtrees()
267
263
            subinvdelta, grandchildmodes, subshamap = import_git_submodule(
268
 
                    texts, mapping, child_path, basename,
 
264
                    texts, mapping, child_path, name,
269
265
                    (child_base_hexsha, child_hexsha),
270
266
                    base_inv, file_id, revision_id, parent_invs, lookup_object,
271
267
                    (child_base_mode, child_mode))
272
268
        else:
273
269
            subinvdelta, subshamap = import_git_blob(texts, mapping,
274
 
                    child_path, basename, (child_base_hexsha, child_hexsha),
 
270
                    child_path, name, (child_base_hexsha, child_hexsha),
275
271
                    base_inv, base_inv_shamap,
276
 
                    base_children.get(basename), file_id,
 
272
                    file_id,
277
273
                    revision_id, parent_invs, lookup_object,
278
274
                    (child_base_mode, child_mode))
279
275
            grandchildmodes = {}
301
297
    parent_invs = parent_invs_cache.get_inventories(rev.parent_ids)
302
298
    if parent_invs == []:
303
299
        base_inv = Inventory(root_id=None)
304
 
        base_ie = None
305
300
        base_inv_shamap = None # Should never be accessed
306
301
        base_tree = None
307
302
        base_mode = None
308
303
    else:
309
304
        base_inv = parent_invs[0]
310
 
        base_ie = base_inv.root
311
305
        base_inv_shamap = target_git_object_retriever._idmap.get_inventory_sha_map(base_inv.revision_id)
312
306
        base_tree = lookup_object(o.parents[0]).tree
313
307
        base_mode = stat.S_IFDIR
314
308
    inv_delta, unusual_modes, shamap = import_git_tree(repo.texts,
315
309
            mapping, "", u"", (base_tree, o.tree), base_inv, base_inv_shamap,
316
 
            base_ie, None, rev.revision_id, parent_invs, lookup_object,
 
310
            None, rev.revision_id, parent_invs, lookup_object,
317
311
            (base_mode, stat.S_IFDIR),
318
312
            allow_submodules=getattr(repo._format, "supports_tree_reference", False))
319
313
    entries = []
404
398
    del checked
405
399
    # Order the revisions
406
400
    # Create the inventory objects
407
 
    batch_size = 100
 
401
    batch_size = 1000
408
402
    revision_ids = topo_sort(graph)
409
403
    pack_hints = []
410
404
    if limit is not None: