~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

(broken) merge aaron's workingtree format changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from StringIO import StringIO
24
24
 
25
25
from bzrlib import (
 
26
    bzrdir,
 
27
    errors,
26
28
    help_topics,
 
29
    repository,
27
30
    symbol_versioning,
28
31
    urlutils,
29
32
    workingtree,
30
33
    )
31
34
import bzrlib.branch
32
 
import bzrlib.bzrdir as bzrdir
33
 
import bzrlib.errors as errors
34
35
from bzrlib.errors import (NotBranchError,
35
36
                           UnknownFormatError,
36
37
                           UnsupportedFormatError,
37
38
                           )
38
 
import bzrlib.repository as repository
39
39
from bzrlib.tests import TestCase, TestCaseWithTransport, test_sftp_transport
40
40
from bzrlib.tests.HttpServer import HttpServer
41
41
from bzrlib.transport import get_transport
75
75
            'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
76
76
            'Format using knits',
77
77
            )
 
78
        my_format_registry.register_metadir('experimental-knit3', 
 
79
            'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
 
80
            'Format using knits', 
 
81
            tree='WorkingTreeFormatAB1')
78
82
        my_format_registry.set_default('knit')
79
83
        my_format_registry.register_metadir(
80
84
            'experimental-knit2',
100
104
        my_bzrdir = my_format_registry.make_bzrdir('knit')
101
105
        self.assertIsInstance(my_bzrdir.repository_format, 
102
106
            knitrepo.RepositoryFormatKnit1)
 
107
        my_bzrdir = my_format_registry.make_bzrdir('experimental-knit3')
 
108
        self.assertIsInstance(my_bzrdir.repository_format, 
 
109
            knitrepo.RepositoryFormatKnit3)
 
110
        self.assertIsInstance(my_bzrdir.workingtree_format, 
 
111
            workingtree.WorkingTreeFormatAB1)
103
112
        my_bzrdir = my_format_registry.make_bzrdir('branch6')
104
113
        self.assertIsInstance(my_bzrdir.get_branch_format(),
105
114
                              bzrlib.branch.BzrBranchFormat6)
476
485
        self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport,
477
486
                          transport)
478
487
 
 
488
    def test_sprout_recursive(self):
 
489
        tree = self.make_branch_and_tree('tree1', format='experimental-knit3')
 
490
        sub_tree = self.make_branch_and_tree('tree1/subtree',
 
491
                                             format='experimental-knit3')
 
492
        tree.add_reference(sub_tree)
 
493
        self.build_tree(['tree1/subtree/file'])
 
494
        sub_tree.add('file')
 
495
        tree.commit('Initial commit')
 
496
        tree.bzrdir.sprout('tree2')
 
497
        self.failUnlessExists('tree2/subtree/file')
 
498
 
 
499
    def test_cloning_metadir(self):
 
500
        """Ensure that cloning metadir is suitable"""
 
501
        bzrdir = self.make_bzrdir('bzrdir')
 
502
        bzrdir.cloning_metadir()
 
503
        branch = self.make_branch('branch', format='knit')
 
504
        format = branch.bzrdir.cloning_metadir()
 
505
        self.assertIsInstance(format.workingtree_format,
 
506
        workingtree.WorkingTreeFormat3)
 
507
        branch2 = self.make_branch('branch2', format='experimental-knit3')
 
508
        format2 = branch2.bzrdir.cloning_metadir()
 
509
        self.assertIsInstance(format2.workingtree_format,
 
510
                              workingtree.WorkingTreeFormatAB1)
 
511
 
 
512
    def test_sprout_recursive_treeless(self):
 
513
        tree = self.make_branch_and_tree('tree1', format='experimental-knit3')
 
514
        sub_tree = self.make_branch_and_tree('tree1/subtree',
 
515
                                             format='experimental-knit3')
 
516
        tree.add_reference(sub_tree)
 
517
        self.build_tree(['tree1/subtree/file'])
 
518
        sub_tree.add('file')
 
519
        tree.commit('Initial commit')
 
520
        tree.bzrdir.destroy_workingtree()
 
521
        repo = self.make_repository('repo', shared=True,
 
522
                                    format='experimental-knit3')
 
523
        repo.set_make_working_trees(False)
 
524
        tree.bzrdir.sprout('repo/tree2')
 
525
        self.failUnlessExists('repo/tree2/subtree')
 
526
        self.failIfExists('repo/tree2/subtree/file')
 
527
 
479
528
 
480
529
class TestMeta1DirFormat(TestCaseWithTransport):
481
530
    """Tests specific to the meta1 dir format."""
502
551
        t = dir.transport
503
552
        self.assertIsDirectory('branch-lock', t)
504
553
 
 
554
    def test_comparison(self):
 
555
        """Equality and inequality behave properly.
 
556
 
 
557
        Metadirs should compare equal iff they have the same repo, branch and
 
558
        tree formats.
 
559
        """
 
560
        mydir = bzrdir.format_registry.make_bzrdir('knit')
 
561
        self.assertEqual(mydir, mydir)
 
562
        self.assertFalse(mydir != mydir)
 
563
        otherdir = bzrdir.format_registry.make_bzrdir('knit')
 
564
        self.assertEqual(otherdir, mydir)
 
565
        self.assertFalse(otherdir != mydir)
 
566
        otherdir2 = bzrdir.format_registry.make_bzrdir('experimental-knit2')
 
567
        self.assertNotEqual(otherdir2, mydir)
 
568
        self.assertFalse(otherdir2 == mydir)
 
569
 
505
570
        
506
571
class TestFormat5(TestCaseWithTransport):
507
572
    """Tests specific to the version 5 bzrdir format."""
677
742
        result.open_branch()
678
743
        result.open_repository()
679
744
 
 
745
    def test_checkout_metadir(self):
 
746
        # checkout_metadir has reasonable working tree format even when no
 
747
        # working tree is present
 
748
        self.make_branch('branch-knit3', format='experimental-knit3')
 
749
        my_bzrdir = bzrdir.BzrDir.open(self.get_url('branch-knit3'))
 
750
        checkout_format = my_bzrdir.checkout_metadir()
 
751
        self.assertIsInstance(checkout_format.workingtree_format,
 
752
                              workingtree.WorkingTreeFormatAB1)
 
753
 
 
754
        self.make_branch('branch-knit2', format='experimental-knit2')
 
755
        my_bzrdir = bzrdir.BzrDir.open(self.get_url('branch-knit2'))
 
756
        checkout_format = my_bzrdir.checkout_metadir()
 
757
        self.assertIsInstance(checkout_format.workingtree_format,
 
758
                              workingtree.WorkingTreeFormat3)
 
759
 
680
760
 
681
761
class TestRemoteSFTP(test_sftp_transport.TestCaseWithSFTPServer):
682
762