136
136
raise TestSkipped("cannot make working tree with transport %r"
137
137
% a_bzrdir.transport)
139
def sproutOrSkip(self, from_bzrdir, to_url, revision_id=None, basis=None,
139
def sproutOrSkip(self, from_bzrdir, to_url, revision_id=None,
140
140
force_new_repo=False):
141
141
"""Sprout from_bzrdir into to_url, or raise TestSkipped.
147
147
target = from_bzrdir.sprout(to_url, revision_id=revision_id,
149
148
force_new_repo=force_new_repo)
150
149
except errors.NotLocalUrl:
151
150
raise TestSkipped('Cannot sprout to remote bzrdirs.')
494
493
self.skipIfNoWorkingTree(target)
495
494
self.assertEqual(['1'], target.open_workingtree().get_parent_ids())
497
def test_clone_bzrdir_incomplete_source_with_basis(self):
498
# ensure that basis really does grab from the basis by having incomplete source
499
tree = self.make_branch_and_tree('commit_tree')
500
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
502
tree.commit('revision 1', rev_id='1')
503
source = self.make_branch_and_tree('source')
504
# this gives us an incomplete repository
505
tree.bzrdir.open_repository().copy_content_into(source.branch.repository)
506
tree.commit('revision 2', rev_id='2', allow_pointless=True)
507
tree.bzrdir.open_branch().copy_content_into(source.branch)
508
tree.copy_content_into(source)
509
self.assertFalse(source.branch.repository.has_revision('2'))
511
target = dir.clone(self.get_url('target'), basis=tree.bzrdir)
512
self.assertEqual('2', target.open_branch().last_revision())
514
self.assertEqual(['2'], target.open_workingtree().get_parent_ids())
515
except errors.NoWorkingTree:
516
# It should have a working tree if it's able to have one, so if
517
# we're here make sure it really can't have one.
518
self.assertRaises(errors.NotLocalUrl, target.create_workingtree)
519
self.assertTrue(target.open_branch().repository.has_revision('2'))
521
496
def test_sprout_bzrdir_empty(self):
522
497
dir = self.make_bzrdir('source')
523
498
target = self.sproutOrSkip(dir, self.get_url('target'))
935
910
target = self.sproutOrSkip(dir, self.get_url('target'), revision_id='1')
936
911
self.assertEqual(['1'], target.open_workingtree().get_parent_ids())
938
def test_sprout_bzrdir_incomplete_source_with_basis(self):
939
# ensure that basis really does grab from the basis by having incomplete source
940
tree = self.make_branch_and_tree('commit_tree')
941
self.build_tree(['commit_tree/foo'])
943
tree.commit('revision 1', rev_id='1')
944
source = self.make_branch_and_tree('source')
945
# this gives us an incomplete repository
946
tree.bzrdir.open_repository().copy_content_into(source.branch.repository)
947
tree.commit('revision 2', rev_id='2', allow_pointless=True)
948
tree.bzrdir.open_branch().copy_content_into(source.branch)
949
tree.copy_content_into(source)
950
self.assertFalse(source.branch.repository.has_revision('2'))
952
target = self.sproutOrSkip(dir, self.get_url('target'),
954
self.assertEqual('2', target.open_branch().last_revision())
955
self.assertEqual(['2'], target.open_workingtree().get_parent_ids())
956
self.assertTrue(target.open_branch().repository.has_revision('2'))
958
913
def test_format_initialize_find_open(self):
959
914
# loopback test to check the current format initializes to itself.
960
915
if not self.bzrdir_format.is_supported():