~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-12-17 10:21:38 UTC
  • mfrom: (3904.3.9 broken-stacking-fix)
  • Revision ID: pqm@pqm.ubuntu.com-20081217102138-pz7pfli9o3k50zq7
Fix pushing an unstackable branch + stackable repo when there is a
        default stacking policy. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
218
218
            make_working_trees = local_repo.make_working_trees()
219
219
            result_repo = repository_policy.acquire_repository(
220
220
                make_working_trees, local_repo.is_shared())
 
221
            if not require_stacking and repository_policy._require_stacking:
 
222
                require_stacking = True
 
223
                result._format.require_stacking()
221
224
            result_repo.fetch(local_repo, revision_id=revision_id)
222
225
        else:
223
226
            result_repo = None
1035
1038
                return format
1036
1039
            tree_format = repository._format._matchingbzrdir.workingtree_format
1037
1040
            format.workingtree_format = tree_format.__class__()
1038
 
        if (require_stacking and not
1039
 
            format.get_branch_format().supports_stacking()):
1040
 
            # We need to make a stacked branch, but the default format for the
1041
 
            # target doesn't support stacking.  So force a branch that *can*
1042
 
            # support stacking.
1043
 
            from bzrlib.branch import BzrBranchFormat7
1044
 
            format._branch_format = BzrBranchFormat7()
1045
 
            mutter("using %r for stacking" % (format._branch_format,))
1046
 
            from bzrlib.repofmt import pack_repo
1047
 
            if format.repository_format.rich_root_data:
1048
 
                bzrdir_format_name = '1.6.1-rich-root'
1049
 
                repo_format = pack_repo.RepositoryFormatKnitPack5RichRoot()
1050
 
            else:
1051
 
                bzrdir_format_name = '1.6'
1052
 
                repo_format = pack_repo.RepositoryFormatKnitPack5()
1053
 
            note('Source format does not support stacking, using format:'
1054
 
                 ' \'%s\'\n  %s\n',
1055
 
                 bzrdir_format_name, repo_format.get_format_description())
1056
 
            format.repository_format = repo_format
 
1041
        if require_stacking:
 
1042
            format.require_stacking()
1057
1043
        return format
1058
1044
 
1059
1045
    def checkout_metadir(self):
2026
2012
    def set_branch_format(self, format):
2027
2013
        self._branch_format = format
2028
2014
 
 
2015
    def require_stacking(self):
 
2016
        if not self.get_branch_format().supports_stacking():
 
2017
            # We need to make a stacked branch, but the default format for the
 
2018
            # target doesn't support stacking.  So force a branch that *can*
 
2019
            # support stacking.
 
2020
            from bzrlib.branch import BzrBranchFormat7
 
2021
            self._branch_format = BzrBranchFormat7()
 
2022
            mutter("using %r for stacking" % (self._branch_format,))
 
2023
            from bzrlib.repofmt import pack_repo
 
2024
            if self.repository_format.rich_root_data:
 
2025
                bzrdir_format_name = '1.6.1-rich-root'
 
2026
                repo_format = pack_repo.RepositoryFormatKnitPack5RichRoot()
 
2027
            else:
 
2028
                bzrdir_format_name = '1.6'
 
2029
                repo_format = pack_repo.RepositoryFormatKnitPack5()
 
2030
            note('Source format does not support stacking, using format:'
 
2031
                 ' \'%s\'\n  %s\n',
 
2032
                 bzrdir_format_name, repo_format.get_format_description())
 
2033
            self.repository_format = repo_format
 
2034
 
2029
2035
    def get_converter(self, format=None):
2030
2036
        """See BzrDirFormat.get_converter()."""
2031
2037
        if format is None:
2906
2912
        except errors.UnstackableRepositoryFormat:
2907
2913
            if self._require_stacking:
2908
2914
                raise
 
2915
        else:
 
2916
            self._require_stacking = True
2909
2917
 
2910
2918
    def acquire_repository(self, make_working_trees=None, shared=False):
2911
2919
        """Acquire a repository for this bzrdir.