188
189
transport.ensure_base()
189
190
require_stacking = (stacked_on is not None)
190
metadir = self.cloning_metadir(require_stacking)
191
result = metadir.initialize_on_transport(transport)
191
format = self.cloning_metadir(require_stacking)
192
result = format.initialize_on_transport(transport)
192
193
repository_policy = None
194
195
local_repo = self.find_repository()
1707
1708
def initialize_on_transport(self, transport):
1708
1709
"""Initialize a new bzrdir in the base directory of a Transport."""
1709
# Since we don't have a .bzr directory, inherit the
1711
# can we hand off the request to the smart server rather than using
1713
client_medium = transport.get_smart_medium()
1714
except errors.NoSmartMedium:
1715
return self._initialize_on_transport_vfs(transport)
1717
# Current RPC's only know how to create bzr metadir1 instances, so
1718
# we still delegate to vfs methods if the requested format is not a
1720
if type(self) != BzrDirMetaFormat1:
1721
return self._initialize_on_transport_vfs(transport)
1722
remote_format = RemoteBzrDirFormat()
1723
self._supply_sub_formats_to(remote_format)
1724
return remote_format.initialize_on_transport(transport)
1726
def _initialize_on_transport_vfs(self, transport):
1727
"""Initialize a new bzrdir using VFS calls.
1729
:param transport: The transport to create the .bzr directory in.
1732
# Since we are creating a .bzr directory, inherit the
1710
1733
# mode from the root directory
1711
1734
temp_control = lockable_files.LockableFiles(transport,
1712
1735
'', lockable_files.TransportLock)
1781
1804
raise AssertionError("%s was asked to open %s, but it seems to need "
1783
1806
% (self, transport, found_format))
1807
# Allow subclasses - use the found format.
1808
self._supply_sub_formats_to(found_format)
1809
return found_format._open(transport)
1784
1810
return self._open(transport)
1786
1812
def _open(self, transport):
1826
1852
# Trim the newline
1827
1853
return self.get_format_string().rstrip()
1855
def _supply_sub_formats_to(self, other_format):
1856
"""Give other_format the same values for sub formats as this has.
1858
This method is expected to be used when parameterising a
1859
RemoteBzrDirFormat instance with the parameters from a
1860
BzrDirMetaFormat1 instance.
1862
:param other_format: other_format is a format which should be
1863
compatible with whatever sub formats are supported by self.
1830
1868
def unregister_format(klass, format):
1831
1869
del klass._formats[format.get_format_string()]
2088
2126
from bzrlib.repository import RepositoryFormat
2089
2127
return RepositoryFormat.get_default_format()
2091
def __set_repository_format(self, value):
2129
def _set_repository_format(self, value):
2092
2130
"""Allow changing the repository format for metadir formats."""
2093
2131
self._repository_format = value
2095
repository_format = property(__return_repository_format, __set_repository_format)
2133
repository_format = property(__return_repository_format,
2134
_set_repository_format)
2136
def _supply_sub_formats_to(self, other_format):
2137
"""Give other_format the same values for sub formats as this has.
2139
This method is expected to be used when parameterising a
2140
RemoteBzrDirFormat instance with the parameters from a
2141
BzrDirMetaFormat1 instance.
2143
:param other_format: other_format is a format which should be
2144
compatible with whatever sub formats are supported by self.
2147
if getattr(self, '_repository_format', None) is not None:
2148
other_format.repository_format = self.repository_format
2149
if self._branch_format is not None:
2150
other_format._branch_format = self._branch_format
2151
if self._workingtree_format is not None:
2152
other_format.workingtree_format = self.workingtree_format
2097
2154
def __get_workingtree_format(self):
2098
2155
if self._workingtree_format is None:
2679
2736
response = client.call('BzrDirFormat.initialize', path)
2680
2737
if response[0] != 'ok':
2681
2738
raise errors.SmartProtocolError('unexpected response code %s' % (response,))
2682
return remote.RemoteBzrDir(transport)
2739
format = RemoteBzrDirFormat()
2740
self._supply_sub_formats_to(format)
2741
return remote.RemoteBzrDir(transport, format)
2684
2743
def _open(self, transport):
2685
return remote.RemoteBzrDir(transport)
2744
return remote.RemoteBzrDir(transport, self)
2687
2746
def __eq__(self, other):
2688
2747
if not isinstance(other, RemoteBzrDirFormat):
2690
2749
return self.get_format_description() == other.get_format_description()
2693
def repository_format(self):
2694
# Using a property to avoid early loading of remote
2695
return remote.RemoteRepositoryFormat()
2751
def __return_repository_format(self):
2752
# Always return a RemoteRepositoryFormat object, but if a specific bzr
2753
# repository format has been asked for, tell the RemoteRepositoryFormat
2754
# that it should use that for init() etc.
2755
result = remote.RemoteRepositoryFormat()
2756
custom_format = getattr(self, '_repository_format', None)
2758
# We will use the custom format to create repositories over the
2759
# wire; expose its details like rich_root_data for code to query
2760
if isinstance(custom_format, remote.RemoteRepositoryFormat):
2761
result._custom_format = custom_format._custom_format
2763
result._custom_format = custom_format
2764
result.rich_root_data = custom_format.rich_root_data
2767
repository_format = property(__return_repository_format,
2768
BzrDirMetaFormat1._set_repository_format) #.im_func)
2698
2771
BzrDirFormat.register_control_server_format(RemoteBzrDirFormat)
3021
3094
# appear in chronological order and format descriptions can build
3022
3095
# on previous ones.
3023
3096
format_registry = BzrDirFormatRegistry()
3097
# The pre-0.8 formats have their repository format network name registered in
3098
# repository.py. MetaDir formats have their repository format network name
3099
# inferred from their disk format string.
3024
3100
format_registry.register('weave', BzrDirFormat6,
3025
3101
'Pre-0.8 format. Slower than knit and does not'
3026
3102
' support checkouts or shared repositories.',
3136
3212
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3137
3213
help='A working-tree format that supports views and content filtering.',
3138
3214
branch_format='bzrlib.branch.BzrBranchFormat7',
3139
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3215
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3140
3216
experimental=True,
3142
3218
format_registry.register_metadir('development-wt5-rich-root',
3144
3220
help='A variant of development-wt5 that supports rich-root data '
3145
3221
'(needed for bzr-svn).',
3146
3222
branch_format='bzrlib.branch.BzrBranchFormat7',
3147
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3223
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3148
3224
experimental=True,
3150
3226
# The following two formats should always just be aliases.