/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 breezy/git/interrepo.py

  • Committer: Jelmer Vernooij
  • Date: 2019-12-23 01:39:21 UTC
  • mfrom: (7424 work)
  • mto: This revision was merged to the branch mainline in revision 7425.
  • Revision ID: jelmer@jelmer.uk-20191223013921-2kzd0wlcoylgxksk
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
216
216
                stop_revids.append(revid)
217
217
        missing = set()
218
218
        graph = self.source.get_graph()
219
 
        pb = ui.ui_factory.nested_progress_bar()
220
 
        try:
 
219
        with ui.ui_factory.nested_progress_bar() as pb:
221
220
            while stop_revids:
222
221
                new_stop_revids = []
223
222
                for revid in stop_revids:
231
230
                for parent_revids in viewvalues(parent_map):
232
231
                    stop_revids.update(parent_revids)
233
232
                pb.update("determining revisions to fetch", len(missing))
234
 
        finally:
235
 
            pb.finished()
236
233
        return graph.iter_topo_order(missing)
237
234
 
238
235
    def _get_target_bzr_refs(self):
302
299
        with self.source_store.lock_read():
303
300
            todo = list(self.missing_revisions(revs))[:limit]
304
301
            revidmap = {}
305
 
            pb = ui.ui_factory.nested_progress_bar()
306
 
            try:
 
302
            with ui.ui_factory.nested_progress_bar() as pb:
307
303
                object_generator = MissingObjectsIterator(
308
304
                    self.source_store, self.source, pb)
309
305
                for (old_revid, git_sha) in object_generator.import_revisions(
321
317
                    revidmap[old_revid] = (git_sha, new_revid)
322
318
                self.target_store.add_objects(object_generator)
323
319
                return revidmap
324
 
            finally:
325
 
                pb.finished()
326
320
 
327
321
    def fetch(self, revision_id=None, pb=None, find_ghosts=False,
328
322
              fetch_spec=None, mapped_refs=None):
574
568
                lambda sha: store[sha].parents)
575
569
            wants_recorder = DetermineWantsRecorder(determine_wants)
576
570
 
577
 
            pb = ui.ui_factory.nested_progress_bar()
578
 
            try:
 
571
            with ui.ui_factory.nested_progress_bar() as pb:
579
572
                objects_iter = self.source.fetch_objects(
580
573
                    wants_recorder, graph_walker, store.get_raw)
581
574
                trace.mutter("Importing %d new revisions",
584
577
                    self.target, mapping, objects_iter, store,
585
578
                    wants_recorder.wants, pb, limit)
586
579
                return (pack_hint, last_rev, wants_recorder.remote_refs)
587
 
            finally:
588
 
                pb.finished()
589
580
 
590
581
    @staticmethod
591
582
    def is_compatible(source, target):
610
601
        self._warn_slow()
611
602
        remote_refs = self.source.controldir.get_refs_container().as_dict()
612
603
        wants = determine_wants(remote_refs)
613
 
        pb = ui.ui_factory.nested_progress_bar()
614
604
        target_git_object_retriever = get_object_store(self.target, mapping)
615
 
        try:
 
605
        with ui.ui_factory.nested_progress_bar() as pb:
616
606
            target_git_object_retriever.lock_write()
617
607
            try:
618
608
                (pack_hint, last_rev) = import_git_objects(
621
611
                return (pack_hint, last_rev, remote_refs)
622
612
            finally:
623
613
                target_git_object_retriever.unlock()
624
 
        finally:
625
 
            pb.finished()
626
614
 
627
615
    @staticmethod
628
616
    def is_compatible(source, target):
683
671
                    "Unsupported search result type %s" % recipe[0])
684
672
            args = heads
685
673
        if branches is not None:
686
 
            def determine_wants(refs):
687
 
                ret = []
688
 
                for name, value in viewitems(refs):
689
 
                    if value == ZERO_SHA:
690
 
                        continue
691
 
 
692
 
                    if name in branches or (include_tags and is_tag(name)):
693
 
                        ret.append(value)
694
 
                return ret
 
674
            determine_wants = self.get_determine_wants_branches(
 
675
                branches, include_tags=include_tags)
695
676
        elif fetch_spec is None and revision_id is None:
696
677
            determine_wants = self.determine_wants_all
697
678
        else:
710
691
            wants.add(git_sha)
711
692
        return self.get_determine_wants_heads(wants, include_tags=include_tags)
712
693
 
 
694
    def get_determine_wants_branches(self, branches, include_tags=False):
 
695
        def determine_wants(refs):
 
696
            ret = []
 
697
            for name, value in viewitems(refs):
 
698
                if value == ZERO_SHA:
 
699
                    continue
 
700
 
 
701
                if name.endswith(ANNOTATED_TAG_SUFFIX):
 
702
                    continue
 
703
 
 
704
                if name in branches or (include_tags and is_tag(name)):
 
705
                    ret.append(value)
 
706
            return ret
 
707
        return determine_wants
 
708
 
713
709
    def determine_wants_all(self, refs):
714
710
        potential = set([
715
711
            v for k, v in refs.items()
726
722
        if limit is not None:
727
723
            raise FetchLimitUnsupported(self)
728
724
        from .remote import DefaultProgressReporter
729
 
        pb = ui.ui_factory.nested_progress_bar()
730
 
        progress = DefaultProgressReporter(pb).progress
731
 
        try:
 
725
        with ui.ui_factory.nested_progress_bar() as pb:
 
726
            progress = DefaultProgressReporter(pb).progress
732
727
            refs = self.source._git.fetch(
733
728
                self.target._git, determine_wants,
734
729
                progress=progress)
735
 
        finally:
736
 
            pb.finished()
737
730
        return (None, None, refs)
738
731
 
739
732
    @staticmethod