1457
1457
t = transport.get_transport(to_location)
1458
1458
t.ensure_base()
1459
1459
format = self._get_checkout_format(lightweight=lightweight)
1461
checkout = format.initialize_on_transport(t)
1462
except errors.AlreadyControlDirError:
1463
# It's fine if the control directory already exists,
1464
# as long as there is no existing branch and working tree.
1465
checkout = controldir.ControlDir.open_from_transport(t)
1467
checkout.open_branch()
1468
except errors.NotBranchError:
1471
raise errors.AlreadyControlDirError(t.base)
1460
1473
if lightweight:
1461
checkout = format.initialize_on_transport(t)
1462
from_branch = BranchReferenceFormat().initialize(checkout,
1474
from_branch = checkout.set_branch_reference(target_branch=self)
1465
checkout_branch = controldir.ControlDir.create_branch_convenience(
1466
to_location, force_new_tree=False, format=format)
1467
checkout = checkout_branch.bzrdir
1476
policy = checkout.determine_repository_policy()
1477
repo = policy.acquire_repository()[0]
1478
checkout_branch = checkout.create_branch()
1468
1479
checkout_branch.bind(self)
1469
1480
# pull up to the specified revision_id to set the initial
1470
1481
# branch tip correctly, and seed it with history.
1471
1482
checkout_branch.pull(self, stop_revision=revision_id)
1473
1484
tree = checkout.create_workingtree(revision_id,
1474
1485
from_branch=from_branch,
1475
1486
accelerator_tree=accelerator_tree,