/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

Fix regression in git-import.

Show diffs side-by-side

added added

removed removed

Lines of Context:
486
486
        :param mapping: BzrGitMapping to use
487
487
        :param pb: Optional progress bar
488
488
        :param limit: Maximum number of commits to import.
489
 
        :return: Tuple with pack hint and last imported revision id
 
489
        :return: Tuple with pack hint, last imported revision id and remote refs
490
490
        """
491
491
        raise NotImplementedError(self.fetch_objects)
492
492
 
500
500
            interesting_heads = fetch_spec.heads
501
501
        else:
502
502
            interesting_heads = None
503
 
        self._refs = {}
504
503
        def determine_wants(refs):
505
 
            self._refs = refs
506
504
            if interesting_heads is None:
507
505
                ret = [sha for (ref, sha) in refs.iteritems() if not ref.endswith("^{}")]
508
506
            else:
509
507
                ret = [self.source.lookup_bzr_revision_id(revid)[0] for revid in interesting_heads if revid not in (None, NULL_REVISION)]
510
508
            return [rev for rev in ret if not self.target.has_revision(self.source.lookup_foreign_revision_id(rev))]
511
 
        (pack_hint, _) = self.fetch_objects(determine_wants, mapping, pb)
 
509
        (pack_hint, _, remote_refs) = self.fetch_objects(determine_wants, mapping, pb)
512
510
        if pack_hint is not None and self.target._format.pack_compresses:
513
511
            self.target.pack(hint=pack_hint)
514
 
        return self._refs
 
512
        return remote_refs
515
513
 
516
514
 
517
515
_GIT_PROGRESS_RE = re.compile(r"(.*?): +(\d+)% \((\d+)/(\d+)\)")
569
567
                objects_iter = self.source.fetch_objects(
570
568
                    wants_recorder, graph_walker, store.get_raw,
571
569
                    progress)
572
 
                return import_git_objects(self.target, mapping,
 
570
                (pack_hint, last_rev) = import_git_objects(self.target, mapping,
573
571
                    objects_iter, store, wants_recorder.wants, pb, limit)
 
572
                return (pack_hint, last_rev, wants_recorder.remote_refs)
574
573
            finally:
575
574
                if create_pb:
576
575
                    create_pb.finished()
592
591
 
593
592
    def fetch_objects(self, determine_wants, mapping, pb=None, limit=None):
594
593
        """See `InterGitNonGitRepository`."""
595
 
        wants = determine_wants(self.source._git.get_refs())
 
594
        remote_refs = self.source._git.get_refs()
 
595
        wants = determine_wants(remote_refs)
596
596
        create_pb = None
597
597
        if pb is None:
598
598
            create_pb = pb = ui.ui_factory.nested_progress_bar()
600
600
        try:
601
601
            self.target.lock_write()
602
602
            try:
603
 
                return import_git_objects(self.target, mapping,
 
603
                (pack_hint, last_rev) = import_git_objects(self.target, mapping,
604
604
                    self.source._git.object_store,
605
605
                    target_git_object_retriever, wants, pb, limit)
 
606
                return (pack_hint, last_rev, remote_refs)
606
607
            finally:
607
608
                self.target.unlock()
608
609
        finally:
627
628
        graphwalker = self.target._git.get_graph_walker()
628
629
        if (isinstance(self.source, LocalGitRepository) and
629
630
            isinstance(self.target, LocalGitRepository)):
630
 
            return self.source._git.fetch(self.target._git, determine_wants,
 
631
            refs = self.source._git.fetch(self.target._git, determine_wants,
631
632
                progress)
 
633
            return (None, None, refs)
632
634
        elif (isinstance(self.source, LocalGitRepository) and
633
635
              isinstance(self.target, RemoteGitRepository)):
634
636
            raise NotImplementedError
639
641
                refs = self.source._git.fetch_pack(determine_wants,
640
642
                    graphwalker, f.write, progress)
641
643
                commit()
642
 
                return refs
 
644
                return (None, None, refs)
643
645
            except:
644
646
                f.close()
645
647
                raise