~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

(jelmer) Reduce the number of connections made during "bzr branch
 --stacked". (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
655
655
        return None, self.open_branch(name=name)
656
656
 
657
657
    def open_branch(self, name=None, unsupported=False,
658
 
                    ignore_fallbacks=False):
 
658
                    ignore_fallbacks=False, possible_transports=None):
659
659
        if unsupported:
660
660
            raise NotImplementedError('unsupported flag support not implemented yet.')
661
661
        if self._next_open_branch_result is not None:
668
668
            # a branch reference, use the existing BranchReference logic.
669
669
            format = BranchReferenceFormat()
670
670
            return format.open(self, name=name, _found=True,
671
 
                location=response[1], ignore_fallbacks=ignore_fallbacks)
 
671
                location=response[1], ignore_fallbacks=ignore_fallbacks,
 
672
                possible_transports=possible_transports)
672
673
        branch_format_name = response[1]
673
674
        if not branch_format_name:
674
675
            branch_format_name = None
675
676
        format = RemoteBranchFormat(network_name=branch_format_name)
676
677
        return RemoteBranch(self, self.find_repository(), format=format,
677
 
            setup_stacking=not ignore_fallbacks, name=name)
 
678
            setup_stacking=not ignore_fallbacks, name=name,
 
679
            possible_transports=possible_transports)
678
680
 
679
681
    def _open_repo_v1(self, path):
680
682
        verb = 'BzrDir.find_repository'
2809
2811
    """
2810
2812
 
2811
2813
    def __init__(self, remote_bzrdir, remote_repository, real_branch=None,
2812
 
        _client=None, format=None, setup_stacking=True, name=None):
 
2814
        _client=None, format=None, setup_stacking=True, name=None,
 
2815
        possible_transports=None):
2813
2816
        """Create a RemoteBranch instance.
2814
2817
 
2815
2818
        :param real_branch: An optional local implementation of the branch
2880
2883
            hook(self)
2881
2884
        self._is_stacked = False
2882
2885
        if setup_stacking:
2883
 
            self._setup_stacking()
 
2886
            self._setup_stacking(possible_transports)
2884
2887
 
2885
 
    def _setup_stacking(self):
 
2888
    def _setup_stacking(self, possible_transports):
2886
2889
        # configure stacking into the remote repository, by reading it from
2887
2890
        # the vfs branch.
2888
2891
        try:
2891
2894
            errors.UnstackableRepositoryFormat), e:
2892
2895
            return
2893
2896
        self._is_stacked = True
2894
 
        self._activate_fallback_location(fallback_url)
 
2897
        if possible_transports is None:
 
2898
            possible_transports = []
 
2899
        else:
 
2900
            possible_transports = list(possible_transports)
 
2901
        possible_transports.append(self.bzrdir.root_transport)
 
2902
        self._activate_fallback_location(fallback_url,
 
2903
            possible_transports=possible_transports)
2895
2904
 
2896
2905
    def _get_config(self):
2897
2906
        return RemoteBranchConfig(self)