1736
1737
mode=file_mode)
1738
1739
control_files.unlock()
1739
return self.open(transport, _found=True)
1740
# If we initialized using VFS methods on a RemoteTransport, return a
1741
# Remote object: No need for it to be slower than necessary.
1742
if isinstance(transport, remote_transport.RemoteTransport):
1743
return self.open(transport)
1745
return self.open(transport, _found=True)
1741
1747
def is_supported(self):
1742
1748
"""Is this format supported?
1781
1787
raise AssertionError("%s was asked to open %s, but it seems to need "
1783
1789
% (self, transport, found_format))
1790
# Allow subclasses - use the found format.
1791
self._supply_sub_formats_to(found_format)
1792
return found_format._open(transport)
1784
1793
return self._open(transport)
1786
1795
def _open(self, transport):
1826
1835
# Trim the newline
1827
1836
return self.get_format_string().rstrip()
1838
def _supply_sub_formats_to(self, other_format):
1839
"""Give other_format the same values for sub formats as this has.
1841
This method is expected to be used when parameterising a
1842
RemoteBzrDirFormat instance with the parameters from a
1843
BzrDirMetaFormat1 instance.
1845
:param other_format: other_format is a format which should be
1846
compatible with whatever sub formats are supported by self.
1830
1851
def unregister_format(klass, format):
1831
1852
del klass._formats[format.get_format_string()]
2088
2109
from bzrlib.repository import RepositoryFormat
2089
2110
return RepositoryFormat.get_default_format()
2091
def __set_repository_format(self, value):
2112
def _set_repository_format(self, value):
2092
2113
"""Allow changing the repository format for metadir formats."""
2093
2114
self._repository_format = value
2095
repository_format = property(__return_repository_format, __set_repository_format)
2116
repository_format = property(__return_repository_format,
2117
_set_repository_format)
2119
def _supply_sub_formats_to(self, other_format):
2120
"""Give other_format the same values for sub formats as this has.
2122
This method is expected to be used when parameterising a
2123
RemoteBzrDirFormat instance with the parameters from a
2124
BzrDirMetaFormat1 instance.
2126
:param other_format: other_format is a format which should be
2127
compatible with whatever sub formats are supported by self.
2130
if getattr(self, '_repository_format', None) is not None:
2131
other_format.repository_format = self.repository_format
2132
if self._branch_format is not None:
2133
other_format._branch_format = self._branch_format
2134
if self._workingtree_format is not None:
2135
other_format.workingtree_format = self.workingtree_format
2097
2137
def __get_workingtree_format(self):
2098
2138
if self._workingtree_format is None:
2679
2719
response = client.call('BzrDirFormat.initialize', path)
2680
2720
if response[0] != 'ok':
2681
2721
raise errors.SmartProtocolError('unexpected response code %s' % (response,))
2682
return remote.RemoteBzrDir(transport)
2722
return remote.RemoteBzrDir(transport, self)
2684
2724
def _open(self, transport):
2685
return remote.RemoteBzrDir(transport)
2725
return remote.RemoteBzrDir(transport, self)
2687
2727
def __eq__(self, other):
2688
2728
if not isinstance(other, RemoteBzrDirFormat):
2690
2730
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()
2732
def __return_repository_format(self):
2733
# Always return a RemoteRepositoryFormat object, but if a specific bzr
2734
# repository format has been asked for, tell the RemoteRepositoryFormat
2735
# that it should use that for init() etc.
2736
result = remote.RemoteRepositoryFormat()
2737
custom_format = getattr(self, '_repository_format', None)
2739
# We will use the custom format to create repositories over the
2740
# wire; expose its details like rich_root_data for code to query
2741
result._custom_format = custom_format
2742
result.rich_root_data = custom_format.rich_root_data
2745
repository_format = property(__return_repository_format,
2746
BzrDirMetaFormat1._set_repository_format) #.im_func)
2698
2749
BzrDirFormat.register_control_server_format(RemoteBzrDirFormat)