~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

 * Two new commands 'bzr checkout' and 'bzr update' allow for CVS/SVN-alike
   behaviour. They use the existing serverless-mode and store no data
   locally. As such they are not suitable for use except in high bandwidth
   low latency environments like LAN's or local disk. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
from StringIO import StringIO
26
26
 
27
 
import bzrlib.branch as branch
 
27
import bzrlib.branch
28
28
import bzrlib.bzrdir as bzrdir
29
29
from bzrlib.errors import (NotBranchError,
30
30
                           UnknownFormatError,
37
37
class TestDefaultFormat(TestCase):
38
38
 
39
39
    def test_get_set_default_format(self):
40
 
        old_format = branch.BranchFormat.get_default_format()
 
40
        old_format = bzrlib.branch.BranchFormat.get_default_format()
41
41
        # default is 5
42
 
        self.assertTrue(isinstance(old_format, branch.BzrBranchFormat5))
43
 
        branch.BranchFormat.set_default_format(SampleBranchFormat())
 
42
        self.assertTrue(isinstance(old_format, bzrlib.branch.BzrBranchFormat5))
 
43
        bzrlib.branch.BranchFormat.set_default_format(SampleBranchFormat())
44
44
        try:
45
45
            # the default branch format is used by the meta dir format
46
46
            # which is not the default bzrdir format at this point
48
48
            result = dir.create_branch()
49
49
            self.assertEqual(result, 'A branch')
50
50
        finally:
51
 
            branch.BranchFormat.set_default_format(old_format)
52
 
        self.assertEqual(old_format, branch.BranchFormat.get_default_format())
53
 
 
54
 
 
55
 
class SampleBranchFormat(branch.BranchFormat):
 
51
            bzrlib.branch.BranchFormat.set_default_format(old_format)
 
52
        self.assertEqual(old_format, bzrlib.branch.BranchFormat.get_default_format())
 
53
 
 
54
 
 
55
class SampleBranchFormat(bzrlib.branch.BranchFormat):
56
56
    """A sample format
57
57
 
58
58
    this format is initializable, unsupported to aid in testing the 
88
88
            dir = format._matchingbzrdir.initialize(url)
89
89
            dir.create_repository()
90
90
            format.initialize(dir)
91
 
            found_format = branch.BranchFormat.find_format(dir)
 
91
            found_format = bzrlib.branch.BranchFormat.find_format(dir)
92
92
            self.failUnless(isinstance(found_format, format.__class__))
93
 
        check_format(branch.BzrBranchFormat5(), "bar")
 
93
        check_format(bzrlib.branch.BzrBranchFormat5(), "bar")
94
94
        
95
95
    def test_find_format_not_branch(self):
96
96
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
97
97
        self.assertRaises(NotBranchError,
98
 
                          branch.BranchFormat.find_format,
 
98
                          bzrlib.branch.BranchFormat.find_format,
99
99
                          dir)
100
100
 
101
101
    def test_find_format_unknown_format(self):
102
102
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
103
103
        SampleBranchFormat().initialize(dir)
104
104
        self.assertRaises(UnknownFormatError,
105
 
                          branch.BranchFormat.find_format,
 
105
                          bzrlib.branch.BranchFormat.find_format,
106
106
                          dir)
107
107
 
108
108
    def test_register_unregister_format(self):
112
112
        # make a branch
113
113
        format.initialize(dir)
114
114
        # register a format for it.
115
 
        branch.BranchFormat.register_format(format)
 
115
        bzrlib.branch.BranchFormat.register_format(format)
116
116
        # which branch.Open will refuse (not supported)
117
 
        self.assertRaises(UnsupportedFormatError, branch.Branch.open, self.get_url())
 
117
        self.assertRaises(UnsupportedFormatError, bzrlib.branch.Branch.open, self.get_url())
118
118
        # but open_downlevel will work
119
119
        self.assertEqual(format.open(dir), bzrdir.BzrDir.open(self.get_url()).open_branch(unsupported=True))
120
120
        # unregister the format
121
 
        branch.BranchFormat.unregister_format(format)
 
121
        bzrlib.branch.BranchFormat.unregister_format(format)
122
122
 
123
123
 
124
124
class TestBranchReference(TestCaseWithTransport):
133
133
        target_branch = dir.create_branch()
134
134
        t.mkdir('branch')
135
135
        branch_dir = bzrdirformat.initialize(self.get_url('branch'))
136
 
        made_branch = branch.BranchReferenceFormat().initialize(branch_dir, target_branch)
 
136
        made_branch = bzrlib.branch.BranchReferenceFormat().initialize(branch_dir, target_branch)
137
137
        self.assertEqual(made_branch.base, target_branch.base)
138
138
        opened_branch = branch_dir.open_branch()
139
139
        self.assertEqual(opened_branch.base, target_branch.base)