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
534
541
rev = self.repository.get_revision(revision_id)
535
542
new_history = rev.get_history(self.repository)[1:]
536
543
destination.set_revision_history(new_history)
537
parent = self.get_parent()
539
destination.set_parent(parent)
545
parent = self.get_parent()
546
except errors.InaccessibleParent, e:
547
mutter('parent was not accessible to copy: %s', e)
550
destination.set_parent(parent)
568
579
mainline_parent_id = revision_id
569
580
return BranchCheckResult(self)
582
def create_checkout(self, to_location, revision_id=None,
584
"""Create a checkout of a branch.
586
:param to_location: The url to produce the checkout at
587
:param revision_id: The revision to check out
588
:param lightweight: If True, produce a lightweight checkout, otherwise,
589
produce a bound branch (heavyweight checkout)
590
:return: The tree of the created checkout
593
t = transport.get_transport(to_location)
596
except errors.FileExists:
598
checkout = bzrdir.BzrDirMetaFormat1().initialize_on_transport(t)
599
BranchReferenceFormat().initialize(checkout, self)
601
checkout_branch = bzrdir.BzrDir.create_branch_convenience(
602
to_location, force_new_tree=False)
603
checkout = checkout_branch.bzrdir
604
checkout_branch.bind(self)
605
if revision_id is not None:
606
rh = checkout_branch.revision_history()
607
new_rh = rh[:rh.index(revision_id) + 1]
608
checkout_branch.set_revision_history(new_rh)
609
return checkout.create_workingtree(revision_id)
572
612
class BranchFormat(object):
573
613
"""An encapsulation of the initialization and open routines for a format.
1170
1210
# turn it into a url
1171
1211
if parent.startswith('/'):
1172
1212
parent = urlutils.local_path_to_url(parent.decode('utf8'))
1173
return urlutils.join(self.base[:-1], parent)
1214
return urlutils.join(self.base[:-1], parent)
1215
except errors.InvalidURLJoin, e:
1216
raise errors.InaccessibleParent(parent, self.base)
1176
1219
def get_push_location(self):