51
52
return SuccessfulSmartServerResponse((answer,))
54
class SmartServerRequestFindRepository(SmartServerRequest):
55
class SmartServerRequestBzrDir(SmartServerRequest):
56
57
def _boolean_to_yes_no(self, a_boolean):
63
def _format_to_capabilities(self, repo_format):
64
rich_root = self._boolean_to_yes_no(repo_format.rich_root_data)
65
tree_ref = self._boolean_to_yes_no(
66
repo_format.supports_tree_reference)
67
external_lookup = self._boolean_to_yes_no(
68
repo_format.supports_external_lookups)
69
return rich_root, tree_ref, external_lookup
72
class SmartServerRequestCreateRepository(SmartServerRequestBzrDir):
74
def do(self, path, network_name, shared):
75
"""Create a repository in the bzr dir at path.
77
This operates precisely like 'bzrdir.create_repository'.
79
If a bzrdir is not present, an exception is propogated
80
rather than 'no branch' because these are different conditions (and
81
this method should only be called after establishing that a bzr dir
84
This is the initial version of this method introduced to the smart
87
:param path: The path to the bzrdir.
88
:param network_name: The network name of the repository type to create.
89
:param shared: The value to pass create_repository for the shared
91
:return: (ok, rich_root, tree_ref, external_lookup, network_name)
93
bzrdir = BzrDir.open_from_transport(
94
self.transport_from_client_path(path))
95
shared = shared == 'True'
96
format = network_format_registry.get(network_name)
97
bzrdir.repository_format = format
98
result = format.initialize(bzrdir, shared=shared)
99
rich_root, tree_ref, external_lookup = self._format_to_capabilities(
101
return SuccessfulSmartServerResponse(('ok', rich_root, tree_ref,
102
external_lookup, result._format.network_name()))
105
class SmartServerRequestFindRepository(SmartServerRequestBzrDir):
62
107
def _find(self, path):
63
108
"""try to find a repository from path upwards
81
126
segments = ['..'] * len(relpath.split('/'))
84
rich_root = self._boolean_to_yes_no(repository.supports_rich_root())
85
tree_ref = self._boolean_to_yes_no(
86
repository._format.supports_tree_reference)
87
external_lookup = self._boolean_to_yes_no(
88
repository._format.supports_external_lookups)
129
rich_root, tree_ref, external_lookup = self._format_to_capabilities(
89
131
return '/'.join(segments), rich_root, tree_ref, external_lookup