6070
6070
if '/' not in to_location and '\\' not in to_location:
6071
6071
# This path is meant to be relative to the existing branch
6072
6072
this_url = self._get_branch_location(control_dir)
6073
to_location = urlutils.join(this_url, '..', to_location)
6073
# Perhaps the target control dir supports colocated branches?
6075
root = controldir.ControlDir.open(this_url,
6076
possible_transports=[control_dir.user_transport])
6077
except errors.NotBranchError:
6080
colocated = root._format.colocated_branches
6082
to_location = urlutils.join_segment_parameters(this_url,
6083
{"branch": urlutils.escape(to_location)})
6085
to_location = urlutils.join(
6086
this_url, '..', urlutils.escape(to_location))
6074
6087
to_branch = branch.bzrdir.sprout(to_location,
6075
6088
possible_transports=[branch.bzrdir.root_transport],
6076
6089
source_branch=branch).open_branch()
6091
# Perhaps it's a colocated branch?
6079
to_branch = Branch.open(to_location)
6080
except errors.NotBranchError:
6081
this_url = self._get_branch_location(control_dir)
6082
to_branch = Branch.open(
6083
urlutils.join(this_url, '..', to_location))
6093
to_branch = control_dir.open_branch(to_location)
6094
except (errors.NotBranchError, errors.NoColocatedBranchSupport):
6096
to_branch = Branch.open(to_location)
6097
except errors.NotBranchError:
6098
this_url = self._get_branch_location(control_dir)
6099
to_branch = Branch.open(
6101
this_url, '..', urlutils.escape(to_location)))
6084
6102
if revision is not None:
6085
6103
revision = revision.as_revision_id(to_branch)
6086
6104
switch.switch(control_dir, to_branch, force, revision_id=revision)