773
785
:param transport: Transport containing the bzrdir.
774
786
:param _unsupported: private.
788
# Keep initial base since 'transport' may be modified while following
776
790
base = transport.base
778
791
def find_format(transport):
779
792
return transport, BzrDirFormat.find_format(
780
793
transport, _server_formats=_server_formats)
782
795
def redirected(transport, e, redirection_notice):
783
qualified_source = e.get_source_url()
784
relpath = transport.relpath(qualified_source)
785
if not e.target.endswith(relpath):
786
# Not redirected to a branch-format, not a branch
787
raise errors.NotBranchError(path=e.target)
788
target = e.target[:-len(relpath)]
796
redirected_transport = transport._redirected_to(e.source, e.target)
797
if redirected_transport is None:
798
raise errors.NotBranchError(base)
789
799
note('%s is%s redirected to %s',
790
transport.base, e.permanently, target)
791
# Let's try with a new transport
792
# FIXME: If 'transport' has a qualifier, this should
793
# be applied again to the new transport *iff* the
794
# schemes used are the same. Uncomment this code
795
# once the function (and tests) exist.
797
#target = urlutils.copy_url_qualifiers(original, target)
798
return get_transport(target)
800
transport.base, e.permanently, redirected_transport.base)
801
return redirected_transport
801
804
transport, format = do_catching_redirections(find_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*
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()
1051
bzrdir_format_name = '1.6'
1052
repo_format = pack_repo.RepositoryFormatKnitPack5()
1053
note('Source format does not support stacking, using format:'
1055
bzrdir_format_name, repo_format.get_format_description())
1056
format.repository_format = repo_format
1041
if require_stacking:
1042
format.require_stacking()
1059
1045
def checkout_metadir(self):
2026
2012
def set_branch_format(self, format):
2027
2013
self._branch_format = format
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*
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()
2028
bzrdir_format_name = '1.6'
2029
repo_format = pack_repo.RepositoryFormatKnitPack5()
2030
note('Source format does not support stacking, using format:'
2032
bzrdir_format_name, repo_format.get_format_description())
2033
self.repository_format = repo_format
2029
2035
def get_converter(self, format=None):
2030
2036
"""See BzrDirFormat.get_converter()."""
2031
2037
if format is None:
2586
2592
# TODO: conversions of Branch and Tree should be done by
2587
2593
# InterXFormat lookups
2588
2594
if (isinstance(tree, workingtree.WorkingTree3) and
2589
not isinstance(tree, workingtree_4.WorkingTree4) and
2595
not isinstance(tree, workingtree_4.DirStateWorkingTree) and
2590
2596
isinstance(self.target_format.workingtree_format,
2591
workingtree_4.WorkingTreeFormat4)):
2597
workingtree_4.DirStateWorkingTreeFormat)):
2592
2598
workingtree_4.Converter3to4().convert(tree)
2599
if (isinstance(tree, workingtree_4.DirStateWorkingTree) and
2600
not isinstance(tree, workingtree_4.WorkingTree5) and
2601
isinstance(self.target_format.workingtree_format,
2602
workingtree_4.WorkingTreeFormat5)):
2603
workingtree_4.Converter4to5().convert(tree)
2593
2604
return to_convert
2810
2825
experimental_pairs.append((key, help))
2812
2827
output += wrapped(key, help, info)
2828
output += "\nSee ``bzr help formats`` for more about storage formats."
2813
2830
if len(experimental_pairs) > 0:
2814
output += "Experimental formats are shown below.\n\n"
2831
other_output += "Experimental formats are shown below.\n\n"
2815
2832
for key, help in experimental_pairs:
2816
2833
info = self.get_info(key)
2817
output += wrapped(key, help, info)
2834
other_output += wrapped(key, help, info)
2837
"No experimental formats are available.\n\n"
2818
2838
if len(deprecated_pairs) > 0:
2819
output += "Deprecated formats are shown below.\n\n"
2839
other_output += "\nDeprecated formats are shown below.\n\n"
2820
2840
for key, help in deprecated_pairs:
2821
2841
info = self.get_info(key)
2822
output += wrapped(key, help, info)
2842
other_output += wrapped(key, help, info)
2845
"\nNo deprecated formats are available.\n\n"
2847
"\nSee ``bzr help formats`` for more about storage formats."
2849
if topic == 'other-formats':
2827
2855
class RepositoryAcquisitionPolicy(object):
2956
2986
return self._repository
2989
# Please register new formats after old formats so that formats
2990
# appear in chronological order and format descriptions can build
2959
2992
format_registry = BzrDirFormatRegistry()
2960
2993
format_registry.register('weave', BzrDirFormat6,
2961
2994
'Pre-0.8 format. Slower than knit and does not'
2962
2995
' support checkouts or shared repositories.',
2963
2996
deprecated=True)
2964
format_registry.register_metadir('knit',
2965
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
2966
'Format using knits. Recommended for interoperation with bzr <= 0.14.',
2967
branch_format='bzrlib.branch.BzrBranchFormat5',
2968
tree_format='bzrlib.workingtree.WorkingTreeFormat3')
2969
2997
format_registry.register_metadir('metaweave',
2970
2998
'bzrlib.repofmt.weaverepo.RepositoryFormat7',
2971
2999
'Transitional format in 0.8. Slower than knit.',
2972
3000
branch_format='bzrlib.branch.BzrBranchFormat5',
2973
3001
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
2974
3002
deprecated=True)
3003
format_registry.register_metadir('knit',
3004
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3005
'Format using knits. Recommended for interoperation with bzr <= 0.14.',
3006
branch_format='bzrlib.branch.BzrBranchFormat5',
3007
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
2975
3009
format_registry.register_metadir('dirstate',
2976
3010
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
2977
3011
help='New in 0.15: Fast local operations. Compatible with bzr 0.8 and '
2988
3022
' Incompatible with bzr < 0.15.',
2989
3023
branch_format='bzrlib.branch.BzrBranchFormat6',
2990
3024
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2992
3026
format_registry.register_metadir('rich-root',
2993
3027
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit4',
2994
3028
help='New in 1.0. Better handling of tree roots. Incompatible with'
2996
3030
branch_format='bzrlib.branch.BzrBranchFormat6',
2997
3031
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2999
3033
format_registry.register_metadir('dirstate-with-subtree',
3000
3034
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
3001
3035
help='New in 0.15: Fast local operations and improved scaling for '
3033
3067
format_registry.register_metadir('rich-root-pack',
3034
3068
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
3035
help='New in 1.0: Pack-based format with data compatible with '
3036
'rich-root format repositories. Incompatible with'
3069
help='New in 1.0: A variant of pack-0.92 that supports rich-root data '
3070
'(needed for bzr-svn).',
3038
3071
branch_format='bzrlib.branch.BzrBranchFormat6',
3039
3072
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3041
3074
format_registry.register_metadir('1.6',
3042
3075
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5',
3043
help='A branch and pack based repository that supports stacking. ',
3076
help='A format that allows a branch to indicate that there is another '
3077
'(stacked) repository that should be used to access data that is '
3078
'not present locally.',
3044
3079
branch_format='bzrlib.branch.BzrBranchFormat7',
3045
3080
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3047
3082
format_registry.register_metadir('1.6.1-rich-root',
3048
3083
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot',
3049
help='A branch and pack based repository that supports stacking '
3050
'and rich root data (needed for bzr-svn). ',
3084
help='A variant of 1.6 that supports rich-root data '
3085
'(needed for bzr-svn).',
3051
3086
branch_format='bzrlib.branch.BzrBranchFormat7',
3052
3087
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3054
3089
format_registry.register_metadir('1.9',
3055
3090
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3056
help='A branch and pack based repository that uses btree indexes. ',
3091
help='A repository format using B+tree indexes. These indexes '
3092
'are smaller in size, have smarter caching and provide faster '
3093
'performance for most operations.',
3057
3094
branch_format='bzrlib.branch.BzrBranchFormat7',
3058
3095
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3060
3097
format_registry.register_metadir('1.9-rich-root',
3061
3098
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3062
help='A branch and pack based repository that uses btree indexes '
3063
'and rich root data (needed for bzr-svn). ',
3099
help='A variant of 1.9 that supports rich-root data '
3100
'(needed for bzr-svn).',
3064
3101
branch_format='bzrlib.branch.BzrBranchFormat7',
3065
3102
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3104
format_registry.register_metadir('1.12-preview',
3105
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3106
help='A working-tree format that supports views and content filtering.',
3107
branch_format='bzrlib.branch.BzrBranchFormat7',
3108
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3111
format_registry.register_metadir('1.12-preview-rich-root',
3112
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3113
help='A variant of 1.12-preview that supports rich-root data '
3114
'(needed for bzr-svn).',
3115
branch_format='bzrlib.branch.BzrBranchFormat7',
3116
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3067
3119
# The following two formats should always just be aliases.
3068
3120
format_registry.register_metadir('development',
3069
3121
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2',