/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

merge bzr.dev r4154

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
from bzrlib.transport.memory import MemoryServer
60
60
from bzrlib.transport.nosmart import NoSmartTransportDecorator
61
61
from bzrlib.transport.readonly import ReadonlyTransportDecorator
62
 
from bzrlib.repofmt import knitrepo, weaverepo
 
62
from bzrlib.repofmt import knitrepo, weaverepo, pack_repo
63
63
 
64
64
 
65
65
class TestDefaultFormat(TestCase):
432
432
        """The default acquisition policy should create a standalone branch."""
433
433
        my_bzrdir = self.make_bzrdir('.')
434
434
        repo_policy = my_bzrdir.determine_repository_policy()
435
 
        repo = repo_policy.acquire_repository()
 
435
        repo, is_new = repo_policy.acquire_repository()
436
436
        self.assertEqual(repo.bzrdir.root_transport.base,
437
437
                         my_bzrdir.root_transport.base)
438
438
        self.assertFalse(repo.is_shared())
439
439
 
440
 
 
441
440
    def test_determine_stacking_policy(self):
442
441
        parent_bzrdir = self.make_bzrdir('.')
443
442
        child_bzrdir = self.make_bzrdir('child')
467
466
        self.assertEqual(child_branch.base,
468
467
                         new_child.open_branch().get_stacked_on_url())
469
468
 
 
469
    def test_default_stacking_with_stackable_branch_unstackable_repo(self):
 
470
        # Make stackable source branch with an unstackable repo format.
 
471
        source_bzrdir = self.make_bzrdir('source')
 
472
        pack_repo.RepositoryFormatKnitPack1().initialize(source_bzrdir)
 
473
        source_branch = bzrlib.branch.BzrBranchFormat7().initialize(source_bzrdir)
 
474
        # Make a directory with a default stacking policy
 
475
        parent_bzrdir = self.make_bzrdir('parent')
 
476
        stacked_on = self.make_branch('parent/stacked-on', format='pack-0.92')
 
477
        parent_bzrdir.get_config().set_default_stack_on(stacked_on.base)
 
478
        # Clone source into directory
 
479
        target = source_bzrdir.clone(self.get_url('parent/target'))
 
480
 
470
481
    def test_sprout_obeys_stacking_policy(self):
471
482
        child_branch, new_child_transport = self.prepare_default_stacking()
472
483
        new_child = child_branch.bzrdir.sprout(new_child_transport.base)
741
752
                          transport)
742
753
 
743
754
    def test_sprout_recursive(self):
744
 
        tree = self.make_branch_and_tree('tree1', format='dirstate-with-subtree')
 
755
        tree = self.make_branch_and_tree('tree1',
 
756
                                         format='dirstate-with-subtree')
745
757
        sub_tree = self.make_branch_and_tree('tree1/subtree',
746
758
            format='dirstate-with-subtree')
 
759
        sub_tree.set_root_id('subtree-root')
747
760
        tree.add_reference(sub_tree)
748
761
        self.build_tree(['tree1/subtree/file'])
749
762
        sub_tree.add('file')
750
763
        tree.commit('Initial commit')
751
 
        tree.bzrdir.sprout('tree2')
 
764
        tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
 
765
        tree2.lock_read()
 
766
        self.addCleanup(tree2.unlock)
752
767
        self.failUnlessExists('tree2/subtree/file')
 
768
        self.assertEqual('tree-reference', tree2.kind('subtree-root'))
753
769
 
754
770
    def test_cloning_metadir(self):
755
771
        """Ensure that cloning metadir is suitable"""
1228
1244
        return _TestBzrDirFormat()
1229
1245
 
1230
1246
 
 
1247
class _TestBranchFormat(bzrlib.branch.BranchFormat):
 
1248
    """Test Branch format for TestBzrDirSprout."""
 
1249
 
 
1250
 
1231
1251
class _TestBranch(bzrlib.branch.Branch):
1232
1252
    """Test Branch implementation for TestBzrDirSprout."""
1233
1253
 
1234
1254
    def __init__(self, *args, **kwargs):
 
1255
        self._format = _TestBranchFormat()
1235
1256
        super(_TestBranch, self).__init__(*args, **kwargs)
1236
1257
        self.calls = []
1237
1258
        self._parent = None