21
21
from warnings import warn
24
from bzrlib import bzrdir, errors, lockdir, osutils, revision, \
28
36
from bzrlib.config import TreeConfig
29
37
from bzrlib.decorators import needs_read_lock, needs_write_lock
30
38
import bzrlib.errors as errors
572
580
mainline_parent_id = revision_id
573
581
return BranchCheckResult(self)
583
def create_checkout(self, to_location, revision_id=None,
585
"""Create a checkout of a branch.
587
:param to_location: The url to produce the checkout at
588
:param revision_id: The revision to check out
589
:param lightweight: If True, produce a lightweight checkout, otherwise,
590
produce a bound branch (heavyweight checkout)
591
:return: The tree of the created checkout
594
t = transport.get_transport(to_location)
597
except errors.FileExists:
599
checkout = bzrdir.BzrDirMetaFormat1().initialize_on_transport(t)
600
BranchReferenceFormat().initialize(checkout, self)
602
checkout_branch = bzrdir.BzrDir.create_branch_convenience(
603
to_location, force_new_tree=False)
604
checkout = checkout_branch.bzrdir
605
checkout_branch.bind(self)
606
if revision_id is not None:
607
rh = checkout_branch.revision_history()
608
new_rh = rh[:rh.index(revision_id) + 1]
609
checkout_branch.set_revision_history(new_rh)
610
return checkout.create_workingtree(revision_id)
576
613
class BranchFormat(object):
577
614
"""An encapsulation of the initialization and open routines for a format.
1064
1101
transaction = self.get_transaction()
1065
1102
history = transaction.map.find_revision_history()
1066
1103
if history is not None:
1067
mutter("cache hit for revision-history in %s", self)
1104
# mutter("cache hit for revision-history in %s", self)
1068
1105
return list(history)
1069
history = [l.rstrip('\r\n') for l in
1070
self.control_files.get_utf8('revision-history').readlines()]
1106
decode_utf8 = cache_utf8.decode
1107
history = [decode_utf8(l.rstrip('\r\n')) for l in
1108
self.control_files.get('revision-history').readlines()]
1071
1109
transaction.map.add_revision_history(history)
1072
1110
# this call is disabled because revision_history is
1073
1111
# not really an object yet, and the transaction is for objects.