/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 convenience method for getting missing objects iterator.

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
                tuple(parent_keys), ie.text_sha1, chunks)])
156
156
    invdelta = []
157
157
    if base_hexsha is not None:
158
 
        old_path = path.decode("utf-8") # Renames are not supported yet
 
158
        old_path = path # Renames are not supported yet
159
159
        if stat.S_ISDIR(base_mode):
160
160
            invdelta.extend(remove_disappeared_children(base_inv, old_path,
161
161
                lookup_object(base_hexsha), [], lookup_object))
162
162
    else:
163
163
        old_path = None
164
 
    new_path = path.decode("utf-8")
165
 
    invdelta.append((old_path, new_path, file_id, ie))
 
164
    invdelta.append((old_path, path, file_id, ie))
166
165
    if base_hexsha != hexsha:
167
 
        store_updater.add_object(blob, ie, path)
 
166
        store_updater.add_object(blob, ie)
168
167
    return invdelta
169
168
 
170
169
 
198
197
 
199
198
    :param base_inv: Base inventory against which to generate the 
200
199
        inventory delta.
201
 
    :param path: Path to process (unicode)
 
200
    :param path: Path to process
202
201
    :param base_tree: Git Tree base object
203
202
    :param existing_children: Children that still exist
204
203
    :param lookup_object: Lookup a git object by its SHA1
205
204
    :return: Inventory delta, as list
206
205
    """
207
 
    assert type(path) is unicode
208
206
    ret = []
209
207
    for name, mode, hexsha in base_tree.iteritems():
210
208
        if name in existing_children:
226
224
    """Import a git tree object into a bzr repository.
227
225
 
228
226
    :param texts: VersionedFiles object to add to
229
 
    :param path: Path in the tree (str)
230
 
    :param name: Name of the tree (str)
 
227
    :param path: Path in the tree
231
228
    :param tree: A git tree object
232
229
    :param base_inv: Base inventory against which to return inventory delta
233
230
    :return: Inventory delta for this subtree
234
231
    """
235
 
    assert type(path) is str
236
 
    assert type(name) is str
237
232
    if base_hexsha == hexsha and base_mode == mode:
238
233
        # If nothing has changed since the base revision, we're done
239
234
        return [], {}
247
242
        old_path = None # Newly appeared here
248
243
    else:
249
244
        base_tree = lookup_object(base_hexsha)
250
 
        old_path = path.decode("utf-8") # Renames aren't supported yet
251
 
    new_path = path.decode("utf-8")
 
245
        old_path = path # Renames aren't supported yet
252
246
    if base_tree is None or type(base_tree) is not Tree:
253
247
        ie.revision = revision_id
254
 
        invdelta.append((old_path, new_path, ie.file_id, ie))
 
248
        invdelta.append((old_path, path, ie.file_id, ie))
255
249
        texts.insert_record_stream([
256
250
            ChunkedContentFactory((ie.file_id, ie.revision), (), None, [])])
257
251
    # Remember for next time
295
289
            child_modes[child_path] = child_mode
296
290
    # Remove any children that have disappeared
297
291
    if base_tree is not None and type(base_tree) is Tree:
298
 
        invdelta.extend(remove_disappeared_children(base_inv, old_path,
 
292
        invdelta.extend(remove_disappeared_children(base_inv, old_path, 
299
293
            base_tree, existing_children, lookup_object))
300
 
    store_updater.add_object(tree, ie, path)
 
294
    store_updater.add_object(tree, ie)
301
295
    return invdelta, child_modes
302
296
 
303
297
 
356
350
        base_tree = lookup_object(o.parents[0]).tree
357
351
        base_mode = stat.S_IFDIR
358
352
    store_updater = target_git_object_retriever._get_updater(rev)
359
 
    store_updater.add_object(o, None, None)
360
 
    fileid_map = mapping.get_fileid_map(lookup_object, o.tree)
 
353
    store_updater.add_object(o, None)
 
354
    lookup_file_id = mapping.get_fileid_map(lookup_object, o.tree).lookup_file_id
361
355
    inv_delta, unusual_modes = import_git_tree(repo.texts,
362
 
            mapping, "", "", (base_tree, o.tree), base_inv,
 
356
            mapping, "", u"", (base_tree, o.tree), base_inv, 
363
357
            None, rev.revision_id, [p.inventory for p in parent_trees],
364
358
            lookup_object, (base_mode, stat.S_IFDIR), store_updater,
365
 
            fileid_map.lookup_file_id,
 
359
            lookup_file_id,
366
360
            allow_submodules=getattr(repo._format, "supports_tree_reference", False))
367
361
    store_updater.finish()
368
362
    if unusual_modes != {}:
375
369
        basis_id = NULL_REVISION
376
370
        base_inv = None
377
371
    rev.inventory_sha1, inv = repo.add_inventory_by_delta(basis_id,
378
 
              inv_delta, rev.revision_id, rev.parent_ids, base_inv)
 
372
              inv_delta, rev.revision_id, rev.parent_ids,
 
373
              base_inv)
379
374
    ret_tree = RevisionTree(repo, inv, rev.revision_id)
380
375
    trees_cache.add(ret_tree)
381
376
    repo.add_revision(rev.revision_id, rev)
643
638
            determine_wants = lambda x: [y for y in args if not y in r.object_store]
644
639
        return self.fetch_objects(determine_wants, mapping)[0]
645
640
 
 
641
 
646
642
    @staticmethod
647
643
    def is_compatible(source, target):
648
644
        """Be compatible with GitRepository."""