/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 bzrlib/bzrdir.py

  • Committer: John Arbash Meinel
  • Date: 2008-11-07 23:17:05 UTC
  • mto: (3868.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 3870.
  • Revision ID: john@arbash-meinel.com-20081107231705-rwiztjhnf1wjtdzx
Allow the source branch to pass itself into BzrDir.sprout.

This allows us to avoid opening the source branch 2 times, which also causes
problems with the lifetime of repository and branch locks during the sprout.

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()