21
21
from warnings import warn
24
from bzrlib import bzrdir, errors, lockdir, osutils, revision, \
28
35
from bzrlib.config import TreeConfig
29
36
from bzrlib.decorators import needs_read_lock, needs_write_lock
30
37
import bzrlib.errors as errors
568
575
mainline_parent_id = revision_id
569
576
return BranchCheckResult(self)
578
def create_checkout_convenience(self, to_location, revision_id=None,
580
"""Create a checkout of a branch.
582
:param to_location: The url to produce the checkout at
583
:param revision_id: The revision to check out
584
:param lightweight: If True, produce a lightweight checkout, othewise
585
produce a bound branch (heavyweight checkout)
586
:return: The tree of the created checkout
589
t = transport.get_transport(to_location)
592
except errors.FileExists:
594
checkout = bzrdir.BzrDirMetaFormat1().initialize_on_transport(t)
595
BranchReferenceFormat().initialize(checkout, self)
597
checkout_branch = bzrdir.BzrDir.create_branch_convenience(
598
to_location, force_new_tree=False)
599
checkout = checkout_branch.bzrdir
600
checkout_branch.bind(self)
601
if revision_id is not None:
602
rh = checkout_branch.revision_history()
603
new_rh = rh[:rh.index(revision_id) + 1]
604
checkout_branch.set_revision_history(new_rh)
605
return checkout.create_workingtree(revision_id)
572
608
class BranchFormat(object):
573
609
"""An encapsulation of the initialization and open routines for a format.