325
330
return SuccessfulSmartServerResponse(('ok', ))
333
class SmartServerRequestBzrDirInitializeEx(SmartServerRequestBzrDir):
335
def parse_NoneTrueFalse(self, arg):
342
raise AssertionError("invalid arg %r" % arg)
344
def parse_NoneString(self, arg):
347
def _serialize_NoneTrueFalse(self, arg):
354
def do(self, bzrdir_network_name, path, use_existing_dir, create_prefix,
355
force_new_repo, stacked_on, stack_on_pwd, repo_format_name,
356
make_working_trees, shared_repo):
357
"""Initialize a bzrdir at path as per
358
BzrDirFormat.initialize_on_transport_ex.
360
New in 1.16. (Replaces BzrDirFormat.initialize_ex verb from 1.15).
362
:return: return SuccessfulSmartServerResponse((repo_path, rich_root,
363
tree_ref, external_lookup, repo_network_name,
364
repo_bzrdir_network_name, bzrdir_format_network_name,
365
NoneTrueFalse(stacking), final_stack, final_stack_pwd,
368
target_transport = self.transport_from_client_path(path)
369
format = network_format_registry.get(bzrdir_network_name)
370
use_existing_dir = self.parse_NoneTrueFalse(use_existing_dir)
371
create_prefix = self.parse_NoneTrueFalse(create_prefix)
372
force_new_repo = self.parse_NoneTrueFalse(force_new_repo)
373
stacked_on = self.parse_NoneString(stacked_on)
374
stack_on_pwd = self.parse_NoneString(stack_on_pwd)
375
make_working_trees = self.parse_NoneTrueFalse(make_working_trees)
376
shared_repo = self.parse_NoneTrueFalse(shared_repo)
377
if stack_on_pwd == '.':
378
stack_on_pwd = target_transport.base
379
repo_format_name = self.parse_NoneString(repo_format_name)
380
repo, bzrdir, stacking, repository_policy = \
381
format.initialize_on_transport_ex(target_transport,
382
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
383
force_new_repo=force_new_repo, stacked_on=stacked_on,
384
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
385
make_working_trees=make_working_trees, shared_repo=shared_repo)
389
rich_root = tree_ref = external_lookup = ''
390
repo_bzrdir_name = ''
392
final_stack_pwd = None
395
repo_path = self._repo_relpath(bzrdir.root_transport, repo)
398
rich_root, tree_ref, external_lookup = self._format_to_capabilities(
400
repo_name = repo._format.network_name()
401
repo_bzrdir_name = repo.bzrdir._format.network_name()
402
final_stack = repository_policy._stack_on
403
final_stack_pwd = repository_policy._stack_on_pwd
404
# It is returned locked, but we need to do the lock to get the lock
407
repo_lock_token = repo.lock_write() or ''
409
repo.leave_lock_in_place()
411
final_stack = final_stack or ''
412
final_stack_pwd = final_stack_pwd or ''
414
# We want this to be relative to the bzrdir.
416
final_stack_pwd = urlutils.relative_url(
417
target_transport.base, final_stack_pwd)
419
# Can't meaningfully return a root path.
420
if final_stack.startswith('/'):
421
client_path = self._root_client_path + final_stack[1:]
422
final_stack = urlutils.relative_url(
423
self._root_client_path, client_path)
424
final_stack_pwd = '.'
426
return SuccessfulSmartServerResponse((repo_path, rich_root, tree_ref,
427
external_lookup, repo_name, repo_bzrdir_name,
428
bzrdir._format.network_name(),
429
self._serialize_NoneTrueFalse(stacking), final_stack,
430
final_stack_pwd, repo_lock_token))
328
433
class SmartServerRequestOpenBranch(SmartServerRequestBzrDir):
330
435
def do_bzrdir_request(self):