/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

  • Committer: Michael Hudson
  • Date: 2010-02-17 02:04:25 UTC
  • mto: (0.200.721 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: michael.hudson@canonical.com-20100217020425-1i19smhkatqsrg3v
this works for my tests, but i'm pretty sure it's wrong in general

Show diffs side-by-side

added added

removed removed

Lines of Context:
346
346
 
347
347
 
348
348
def import_git_objects(repo, mapping, object_iter, target_git_object_retriever,
349
 
        heads, pb=None):
 
349
        heads, pb=None, limit=None):
350
350
    """Import a set of git objects into a bzr repository.
351
351
 
352
352
    :param repo: Target Bazaar repository
396
396
    batch_size = 100
397
397
    revision_ids = topo_sort(graph)
398
398
    pack_hints = []
 
399
    if limit is not None:
 
400
        revision_ids = revision_ids[:limit]
399
401
    for offset in range(0, len(revision_ids), batch_size):
400
402
        repo.start_write_group()
401
403
        try:
405
407
                import_git_commit(repo, mapping, head, lookup_object,
406
408
                                  target_git_object_retriever,
407
409
                                  parent_invs_cache)
 
410
                last_imported = head
408
411
        except:
409
412
            repo.abort_write_group()
410
413
            raise
413
416
            if hint is not None:
414
417
                pack_hints.extend(hint)
415
418
    target_git_object_retriever._idmap.commit_write_group()
416
 
    return pack_hints
 
419
    return pack_hints, last_imported
417
420
 
418
421
 
419
422
class InterGitRepository(InterRepository):
456
459
            else:
457
460
                ret = [mapping.revision_id_bzr_to_foreign(revid)[0] for revid in interesting_heads if revid not in (None, NULL_REVISION)]
458
461
            return [rev for rev in ret if not self.target.has_revision(mapping.revision_id_foreign_to_bzr(rev))]
459
 
        pack_hint = self.fetch_objects(determine_wants, mapping, pb)
 
462
        pack_hint = self.fetch_objects(determine_wants, mapping, pb)[0]
460
463
        if pack_hint is not None and self.target._format.pack_compresses:
461
464
            self.target.pack(hint=pack_hint)
462
465
        if interesting_heads is not None:
490
493
        map(all_parents.update, parent_map.itervalues())
491
494
        return set(all_revs) - all_parents
492
495
 
493
 
    def fetch_objects(self, determine_wants, mapping, pb=None):
 
496
    def fetch_objects(self, determine_wants, mapping, pb=None, limit=None):
494
497
        def progress(text):
495
498
            report_git_progress(pb, text)
496
499
        store = BazaarObjectStore(self.target, mapping)
514
517
                            record_determine_wants, graph_walker,
515
518
                            store.get_raw, progress)
516
519
                return import_git_objects(self.target, mapping,
517
 
                    objects_iter, store, recorded_wants, pb)
 
520
                    objects_iter, store, recorded_wants, pb, limit)
518
521
            finally:
519
522
                if create_pb:
520
523
                    create_pb.finished()
534
537
    """InterRepository that copies revisions from a local Git into a non-Git
535
538
    repository."""
536
539
 
537
 
    def fetch_objects(self, determine_wants, mapping, pb=None):
 
540
    def fetch_objects(self, determine_wants, mapping, pb=None, limit=None):
538
541
        wants = determine_wants(self.source._git.get_refs())
539
542
        create_pb = None
540
543
        if pb is None:
545
548
            try:
546
549
                return import_git_objects(self.target, mapping,
547
550
                    self.source._git.object_store, target_git_object_retriever,
548
 
                    wants, pb)
 
551
                    wants, pb, limit)
549
552
            finally:
550
553
                self.target.unlock()
551
554
        finally:
604
607
            determine_wants = r.object_store.determine_wants_all
605
608
        else:
606
609
            determine_wants = lambda x: [y for y in args if not y in r.object_store]
607
 
        return self.fetch_objects(determine_wants, mapping)
 
610
        return self.fetch_objects(determine_wants, mapping)[0]
608
611
 
609
612
 
610
613
    @staticmethod