44
46
# clients that don't anticipate errors from this method.
47
default_format = BzrDirFormat.get_default_format()
48
real_bzrdir = default_format.open(t, _found=True)
49
bzr_prober = BzrProber()
50
real_bzrdir._format.probe_transport(t)
51
bzr_prober.probe_transport(t)
51
52
except (errors.NotBranchError, errors.UnknownFormatError):
84
85
class SmartServerRequestBzrDir(SmartServerRequest):
86
87
def do(self, path, *args):
87
"""Open a BzrDir at path, and return self.do_bzrdir_request(*args)."""
88
"""Open a BzrDir at path, and return `self.do_bzrdir_request(*args)`."""
89
90
self._bzrdir = BzrDir.open_from_transport(
90
91
self.transport_from_client_path(path))
119
120
return '/'.join(segments)
123
class SmartServerBzrDirRequestDestroyBranch(SmartServerRequestBzrDir):
125
def do_bzrdir_request(self, name=None):
126
"""Destroy the branch with the specified name.
129
:return: On success, 'ok'.
132
self._bzrdir.destroy_branch(name)
133
except errors.NotBranchError, e:
134
return FailedSmartServerResponse(('nobranch',))
135
return SuccessfulSmartServerResponse(('ok',))
138
class SmartServerBzrDirRequestHasWorkingTree(SmartServerRequestBzrDir):
140
def do_bzrdir_request(self, name=None):
141
"""Check whether there is a working tree present.
145
:return: If there is a working tree present, 'yes'.
148
if self._bzrdir.has_workingtree():
149
return SuccessfulSmartServerResponse(('yes', ))
151
return SuccessfulSmartServerResponse(('no', ))
154
class SmartServerBzrDirRequestDestroyRepository(SmartServerRequestBzrDir):
156
def do_bzrdir_request(self, name=None):
157
"""Destroy the repository.
161
:return: On success, 'ok'.
164
self._bzrdir.destroy_repository()
165
except errors.NoRepositoryPresent, e:
166
return FailedSmartServerResponse(('norepository',))
167
return SuccessfulSmartServerResponse(('ok',))
122
170
class SmartServerBzrDirRequestCloningMetaDir(SmartServerRequestBzrDir):
124
172
def do_bzrdir_request(self, require_stacking):
148
196
control_format = self._bzrdir.cloning_metadir(
149
197
require_stacking=require_stacking)
150
198
control_name = control_format.network_name()
151
# XXX: There should be a method that tells us that the format does/does
152
# not have subformats.
153
if isinstance(control_format, BzrDirMetaFormat1):
199
if not control_format.fixed_components:
154
200
branch_name = ('branch',
155
201
control_format.get_branch_format().network_name())
156
202
repository_name = control_format.repository_format.network_name()
180
226
:param path: The path to the bzrdir.
181
227
:param network_name: The network name of the branch type to create.
182
:return: (ok, network_name)
228
:return: ('ok', branch_format, repo_path, rich_root, tree_ref,
229
external_lookup, repo_format)
184
231
bzrdir = BzrDir.open_from_transport(
185
232
self.transport_from_client_path(path))
429
476
# It is returned locked, but we need to do the lock to get the lock
432
repo_lock_token = repo.lock_write() or ''
479
repo_lock_token = repo.lock_write().repository_token or ''
433
480
if repo_lock_token:
434
481
repo.leave_lock_in_place()