/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

Keep inventory entry children around once we've fetched them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
    )
85
85
 
86
86
 
87
 
def import_git_blob(texts, mapping, path, hexsha, base_inv, parent_id, 
 
87
def import_git_blob(texts, mapping, path, hexsha, base_inv, base_ie, parent_id, 
88
88
    revision_id, parent_invs, shagitmap, lookup_object, executable, symlink):
89
89
    """Import a git blob object into a bzr repository.
90
90
 
102
102
    ie = cls(file_id, urlutils.basename(path).decode("utf-8"), parent_id)
103
103
    ie.executable = executable
104
104
    # See if this has changed at all
105
 
    try:
106
 
        base_ie = base_inv[file_id]
107
 
    except NoSuchId:
108
 
        base_ie = None
 
105
    if base_ie is None:
109
106
        base_sha = None
110
107
    else:
111
108
        try:
171
168
    return (invdelta, shamap)
172
169
 
173
170
 
174
 
def import_git_submodule(texts, mapping, path, hexsha, base_inv, parent_id, 
 
171
def import_git_submodule(texts, mapping, path, hexsha, base_inv, base_ie, parent_id, 
175
172
    revision_id, parent_invs, shagitmap, lookup_object):
176
173
    raise NotImplementedError(import_git_submodule)
177
174
 
187
184
    return ret
188
185
 
189
186
 
190
 
def import_git_tree(texts, mapping, path, hexsha, base_inv, parent_id, 
 
187
def import_git_tree(texts, mapping, path, hexsha, base_inv, base_ie, parent_id, 
191
188
    revision_id, parent_invs, shagitmap, lookup_object):
192
189
    """Import a git tree object into a bzr repository.
193
190
 
202
199
    # We just have to hope this is indeed utf-8:
203
200
    ie = InventoryDirectory(file_id, urlutils.basename(path.decode("utf-8")), 
204
201
        parent_id)
205
 
    try:
206
 
        base_ie = base_inv[file_id]
207
 
    except NoSuchId:
 
202
    if base_ie is None:
208
203
        # Newly appeared here
209
 
        base_ie = None
210
204
        ie.revision = revision_id
211
205
        texts.add_lines((file_id, ie.revision), (), [])
212
206
        invdelta.append((None, path, file_id, ie))
224
218
            ie.revision = revision_id
225
219
            texts.add_lines((ie.file_id, ie.revision), (), [])
226
220
            invdelta.append((base_inv.id2path(ie.file_id), path, ie.file_id, ie))
 
221
    if base_ie is not None and base_ie.kind == "directory":
 
222
        base_children = base_ie.children
 
223
    else:
 
224
        base_children = {}
227
225
    # Remember for next time
228
226
    existing_children = set()
229
227
    child_modes = {}
236
234
        if stat.S_ISDIR(mode):
237
235
            subinvdelta, grandchildmodes, subshamap = import_git_tree(
238
236
                    texts, mapping, child_path, child_hexsha, base_inv, 
239
 
                    file_id, revision_id, parent_invs, shagitmap, lookup_object)
 
237
                    base_children.get(name), file_id, revision_id, parent_invs, shagitmap,
 
238
                    lookup_object)
240
239
            invdelta.extend(subinvdelta)
241
240
            child_modes.update(grandchildmodes)
242
241
            shamap.extend(subshamap)
243
242
        elif S_ISGITLINK(mode): # submodule
244
243
            subinvdelta, grandchildmodes, subshamap = import_git_submodule(
245
 
                    texts, mapping, child_path, child_hexsha, base_inv,
 
244
                    texts, mapping, child_path, child_hexsha, base_inv, base_ie.get(name),
246
245
                    file_id, revision_id, parent_invs, shagitmap, lookup_object)
247
246
            invdelta.extend(subinvdelta)
248
247
            child_modes.update(grandchildmodes)
249
248
            shamap.extend(subshamap)
250
249
        else:
251
250
            subinvdelta, subshamap = import_git_blob(texts, mapping, 
252
 
                    child_path, child_hexsha, base_inv, file_id, revision_id, 
253
 
                    parent_invs, shagitmap, lookup_object, 
 
251
                    child_path, child_hexsha, base_inv, base_children.get(name), file_id,
 
252
                    revision_id, parent_invs, shagitmap, lookup_object, 
254
253
                    mode_is_executable(mode), stat.S_ISLNK(mode))
255
254
            invdelta.extend(subinvdelta)
256
255
            shamap.extend(subshamap)
259
258
            child_modes[child_path] = mode
260
259
    # Remove any children that have disappeared
261
260
    if base_ie is not None and base_ie.kind == "directory":
262
 
        invdelta.extend(remove_disappeared_children(base_inv, base_ie.children,
 
261
        invdelta.extend(remove_disappeared_children(base_inv, base_children,
263
262
                                                    existing_children))
264
263
    shamap.append((hexsha, "tree", (file_id, revision_id)))
265
264
    return invdelta, child_modes, shamap
330
329
                parent_invs_cache[parent_id] = parent_inv
331
330
        if parent_invs == []:
332
331
            base_inv = Inventory(root_id=None)
 
332
            base_ie = None
333
333
        else:
334
334
            base_inv = parent_invs[0]
 
335
            base_ie = base_inv.root
335
336
        inv_delta, unusual_modes, shamap = import_git_tree(repo.texts, 
336
 
                mapping, "", root_trees[revid], base_inv, None, revid, 
 
337
                mapping, "", root_trees[revid], base_inv, base_ie, None, revid, 
337
338
                parent_invs, target_git_object_retriever._idmap, lookup_object)
338
339
        target_git_object_retriever._idmap.add_entries(shamap)
339
340
        if unusual_modes != {}: