~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-11-28 03:17:39 UTC
  • mfrom: (3868.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20081128031739-mprtvyhcn9zwtkqc
(mbp, for jam) bzr branch opens source branch only once

Show diffs side-by-side

added added

removed removed

Lines of Context:
1061
1061
 
1062
1062
    def sprout(self, url, revision_id=None, force_new_repo=False,
1063
1063
               recurse='down', possible_transports=None,
1064
 
               accelerator_tree=None, hardlink=False, stacked=False):
 
1064
               accelerator_tree=None, hardlink=False, stacked=False,
 
1065
               source_branch=None):
1065
1066
        """Create a copy of this bzrdir prepared for use as a new line of
1066
1067
        development.
1067
1068
 
1088
1089
        cloning_format = self.cloning_metadir(stacked)
1089
1090
        # Create/update the result branch
1090
1091
        result = cloning_format.initialize_on_transport(target_transport)
1091
 
        try:
1092
 
            source_branch = self.open_branch()
1093
 
            source_repository = source_branch.repository
 
1092
        # if a stacked branch wasn't requested, we don't create one
 
1093
        # even if the origin was stacked
 
1094
        stacked_branch_url = None
 
1095
        if source_branch is not None:
1094
1096
            if stacked:
1095
1097
                stacked_branch_url = self.root_transport.base
1096
 
            else:
1097
 
                # if a stacked branch wasn't requested, we don't create one
1098
 
                # even if the origin was stacked
1099
 
                stacked_branch_url = None
1100
 
        except errors.NotBranchError:
1101
 
            source_branch = None
 
1098
            source_repository = source_branch.repository
 
1099
        else:
1102
1100
            try:
1103
 
                source_repository = self.open_repository()
1104
 
            except errors.NoRepositoryPresent:
1105
 
                source_repository = None
1106
 
            stacked_branch_url = None
 
1101
                source_branch = self.open_branch()
 
1102
                source_repository = source_branch.repository
 
1103
                if stacked:
 
1104
                    stacked_branch_url = self.root_transport.base
 
1105
            except errors.NotBranchError:
 
1106
                source_branch = None
 
1107
                try:
 
1108
                    source_repository = self.open_repository()
 
1109
                except errors.NoRepositoryPresent:
 
1110
                    source_repository = None
1107
1111
        repository_policy = result.determine_repository_policy(
1108
1112
            force_new_repo, stacked_branch_url, require_stacking=stacked)
1109
1113
        result_repo = repository_policy.acquire_repository()