/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

remove all trailing whitespace from bzr source

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
        my_format_registry.register('weave', bzrdir.BzrDirFormat6,
85
85
            'Pre-0.8 format.  Slower and does not support checkouts or shared'
86
86
            ' repositories', deprecated=True)
87
 
        my_format_registry.register_lazy('lazy', 'bzrlib.bzrdir', 
 
87
        my_format_registry.register_lazy('lazy', 'bzrlib.bzrdir',
88
88
            'BzrDirFormat6', 'Format registered lazily', deprecated=True)
89
89
        my_format_registry.register_metadir('knit',
90
90
            'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
117
117
        my_bzrdir = my_format_registry.make_bzrdir('weave')
118
118
        self.assertIsInstance(my_bzrdir, bzrdir.BzrDirFormat6)
119
119
        my_bzrdir = my_format_registry.make_bzrdir('default')
120
 
        self.assertIsInstance(my_bzrdir.repository_format, 
 
120
        self.assertIsInstance(my_bzrdir.repository_format,
121
121
            knitrepo.RepositoryFormatKnit1)
122
122
        my_bzrdir = my_format_registry.make_bzrdir('knit')
123
 
        self.assertIsInstance(my_bzrdir.repository_format, 
 
123
        self.assertIsInstance(my_bzrdir.repository_format,
124
124
            knitrepo.RepositoryFormatKnit1)
125
125
        my_bzrdir = my_format_registry.make_bzrdir('branch6')
126
126
        self.assertIsInstance(my_bzrdir.get_branch_format(),
130
130
        my_format_registry = self.make_format_registry()
131
131
        self.assertEqual('Format registered lazily',
132
132
                         my_format_registry.get_help('lazy'))
133
 
        self.assertEqual('Format using knits', 
 
133
        self.assertEqual('Format using knits',
134
134
                         my_format_registry.get_help('knit'))
135
 
        self.assertEqual('Format using knits', 
 
135
        self.assertEqual('Format using knits',
136
136
                         my_format_registry.get_help('default'))
137
137
        self.assertEqual('Pre-0.8 format.  Slower and does not support'
138
 
                         ' checkouts or shared repositories', 
 
138
                         ' checkouts or shared repositories',
139
139
                         my_format_registry.get_help('weave'))
140
 
        
 
140
 
141
141
    def test_help_topic(self):
142
142
        topics = help_topics.HelpTopicRegistry()
143
143
        registry = self.make_format_registry()
144
 
        topics.register('current-formats', registry.help_topic, 
 
144
        topics.register('current-formats', registry.help_topic,
145
145
                        'Current formats')
146
 
        topics.register('other-formats', registry.help_topic, 
 
146
        topics.register('other-formats', registry.help_topic,
147
147
                        'Other formats')
148
148
        new = topics.get_detail('current-formats')
149
149
        rest = topics.get_detail('other-formats')
150
150
        experimental, deprecated = rest.split('Deprecated formats')
151
151
        self.assertContainsRe(new, 'bzr help formats')
152
 
        self.assertContainsRe(new, 
 
152
        self.assertContainsRe(new,
153
153
                ':knit:\n    \(native\) \(default\) Format using knits\n')
154
 
        self.assertContainsRe(experimental, 
 
154
        self.assertContainsRe(experimental,
155
155
                ':branch6:\n    \(native\) Experimental successor to knit')
156
 
        self.assertContainsRe(deprecated, 
 
156
        self.assertContainsRe(deprecated,
157
157
                ':lazy:\n    \(native\) Format registered lazily\n')
158
158
        self.assertNotContainsRe(new, 'hidden')
159
159
 
219
219
class SampleBzrDirFormat(bzrdir.BzrDirFormat):
220
220
    """A sample format
221
221
 
222
 
    this format is initializable, unsupported to aid in testing the 
 
222
    this format is initializable, unsupported to aid in testing the
223
223
    open and open_downlevel routines.
224
224
    """
225
225
 
246
246
    def test_find_format(self):
247
247
        # is the right format object found for a branch?
248
248
        # create a branch with a few known format objects.
249
 
        # this is not quite the same as 
 
249
        # this is not quite the same as
250
250
        t = get_transport(self.get_url())
251
251
        self.build_tree(["foo/", "bar/"], transport=t)
252
252
        def check_format(format, url):
256
256
            self.failUnless(isinstance(found_format, format.__class__))
257
257
        check_format(bzrdir.BzrDirFormat5(), "foo")
258
258
        check_format(bzrdir.BzrDirFormat6(), "bar")
259
 
        
 
259
 
260
260
    def test_find_format_nothing_there(self):
261
261
        self.assertRaises(NotBranchError,
262
262
                          bzrdir.BzrDirFormat.find_format,
306
306
                          branch.bzrdir.open_repository)
307
307
 
308
308
    def test_create_branch_and_repo_under_shared_force_new(self):
309
 
        # creating a branch and repo in a shared repo can be forced to 
 
309
        # creating a branch and repo in a shared repo can be forced to
310
310
        # make a new repo
311
311
        format = bzrdir.format_registry.make_bzrdir('knit')
312
312
        self.make_repository('.', shared=True, format=format)
317
317
 
318
318
    def test_create_standalone_working_tree(self):
319
319
        format = SampleBzrDirFormat()
320
 
        # note this is deliberately readonly, as this failure should 
 
320
        # note this is deliberately readonly, as this failure should
321
321
        # occur before any writes.
322
322
        self.assertRaises(errors.NotLocalUrl,
323
323
                          bzrdir.BzrDir.create_standalone_workingtree,
324
324
                          self.get_readonly_url(), format=format)
325
 
        tree = bzrdir.BzrDir.create_standalone_workingtree('.', 
 
325
        tree = bzrdir.BzrDir.create_standalone_workingtree('.',
326
326
                                                           format=format)
327
327
        self.assertEqual('A tree', tree)
328
328
 
330
330
        # create standalone working tree always makes a repo.
331
331
        format = bzrdir.format_registry.make_bzrdir('knit')
332
332
        self.make_repository('.', shared=True, format=format)
333
 
        # note this is deliberately readonly, as this failure should 
 
333
        # note this is deliberately readonly, as this failure should
334
334
        # occur before any writes.
335
335
        self.assertRaises(errors.NotLocalUrl,
336
336
                          bzrdir.BzrDir.create_standalone_workingtree,
337
337
                          self.get_readonly_url('child'), format=format)
338
 
        tree = bzrdir.BzrDir.create_standalone_workingtree('child', 
 
338
        tree = bzrdir.BzrDir.create_standalone_workingtree('child',
339
339
            format=format)
340
340
        tree.bzrdir.open_repository()
341
341
 
360
360
        self.vfs_transport_factory = MemoryServer
361
361
        # outside a repo the default convenience output is a repo+branch_tree
362
362
        format = bzrdir.format_registry.make_bzrdir('knit')
363
 
        branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(), 
 
363
        branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(),
364
364
                                                         format=format)
365
365
        self.assertRaises(errors.NoWorkingTree,
366
366
                          branch.bzrdir.open_workingtree)
376
376
        branch.bzrdir.open_workingtree()
377
377
        self.assertRaises(errors.NoRepositoryPresent,
378
378
                          branch.bzrdir.open_repository)
379
 
            
 
379
 
380
380
    def test_create_branch_convenience_under_shared_repo_force_no_tree(self):
381
381
        # inside a repo the default convenience output is a branch+ follow the
382
382
        # repo tree policy but we can override that
388
388
                          branch.bzrdir.open_workingtree)
389
389
        self.assertRaises(errors.NoRepositoryPresent,
390
390
                          branch.bzrdir.open_repository)
391
 
            
 
391
 
392
392
    def test_create_branch_convenience_under_shared_repo_no_tree_policy(self):
393
393
        # inside a repo the default convenience output is a branch+ follow the
394
394
        # repo tree policy
395
395
        format = bzrdir.format_registry.make_bzrdir('knit')
396
396
        repo = self.make_repository('.', shared=True, format=format)
397
397
        repo.set_make_working_trees(False)
398
 
        branch = bzrdir.BzrDir.create_branch_convenience('child', 
 
398
        branch = bzrdir.BzrDir.create_branch_convenience('child',
399
399
                                                         format=format)
400
400
        self.assertRaises(errors.NoWorkingTree,
401
401
                          branch.bzrdir.open_workingtree)
725
725
        opened_bzrdir = bzrdir.BzrDir.open_from_transport(transport)
726
726
        self.assertEqual(transport.base, opened_bzrdir.root_transport.base)
727
727
        self.assertIsInstance(opened_bzrdir, bzrdir.BzrDir)
728
 
        
 
728
 
729
729
    def test_open_from_transport_no_bzrdir(self):
730
730
        transport = get_transport(self.get_url())
731
731
        self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport,
881
881
    def test_needs_conversion_different_working_tree(self):
882
882
        # meta1dirs need an conversion if any element is not the default.
883
883
        old_format = bzrdir.BzrDirFormat.get_default_format()
884
 
        # test with 
 
884
        # test with
885
885
        new_default = bzrdir.format_registry.make_bzrdir('dirstate')
886
886
        bzrdir.BzrDirFormat._set_default_format(new_default)
887
887
        try:
895
895
    """Tests specific to the version 5 bzrdir format."""
896
896
 
897
897
    def test_same_lockfiles_between_tree_repo_branch(self):
898
 
        # this checks that only a single lockfiles instance is created 
 
898
        # this checks that only a single lockfiles instance is created
899
899
        # for format 5 objects
900
900
        dir = bzrdir.BzrDirFormat5().initialize(self.get_url())
901
901
        def check_dir_components_use_same_lock(dir):
908
908
        # and if we open it normally.
909
909
        dir = bzrdir.BzrDir.open(self.get_url())
910
910
        check_dir_components_use_same_lock(dir)
911
 
    
 
911
 
912
912
    def test_can_convert(self):
913
913
        # format 5 dirs are convertable
914
914
        dir = bzrdir.BzrDirFormat5().initialize(self.get_url())
915
915
        self.assertTrue(dir.can_convert_format())
916
 
    
 
916
 
917
917
    def test_needs_conversion(self):
918
918
        # format 5 dirs need a conversion if they are not the default.
919
919
        # and they start of not the default.
931
931
    """Tests specific to the version 6 bzrdir format."""
932
932
 
933
933
    def test_same_lockfiles_between_tree_repo_branch(self):
934
 
        # this checks that only a single lockfiles instance is created 
 
934
        # this checks that only a single lockfiles instance is created
935
935
        # for format 6 objects
936
936
        dir = bzrdir.BzrDirFormat6().initialize(self.get_url())
937
937
        def check_dir_components_use_same_lock(dir):
944
944
        # and if we open it normally.
945
945
        dir = bzrdir.BzrDir.open(self.get_url())
946
946
        check_dir_components_use_same_lock(dir)
947
 
    
 
947
 
948
948
    def test_can_convert(self):
949
949
        # format 6 dirs are convertable
950
950
        dir = bzrdir.BzrDirFormat6().initialize(self.get_url())
951
951
        self.assertTrue(dir.can_convert_format())
952
 
    
 
952
 
953
953
    def test_needs_conversion(self):
954
954
        # format 6 dirs need an conversion if they are not the default.
955
955
        old_format = bzrdir.BzrDirFormat.get_default_format()
995
995
 
996
996
class TestNotBzrDir(TestCaseWithTransport):
997
997
    """Tests for using the bzrdir api with a non .bzr based disk format.
998
 
    
 
998
 
999
999
    If/when one of these is in the core, we can let the implementation tests
1000
1000
    verify this works.
1001
1001
    """
1002
1002
 
1003
1003
    def test_create_and_find_format(self):
1004
 
        # create a .notbzr dir 
 
1004
        # create a .notbzr dir
1005
1005
        format = NotBzrDirFormat()
1006
1006
        dir = format.initialize(self.get_url())
1007
1007
        self.assertIsInstance(dir, NotBzrDir)
1032
1032
    def setUp(self):
1033
1033
        super(NonLocalTests, self).setUp()
1034
1034
        self.vfs_transport_factory = MemoryServer
1035
 
    
 
1035
 
1036
1036
    def test_create_branch_convenience(self):
1037
1037
        # outside a repo the default convenience output is a repo+branch_tree
1038
1038
        format = bzrdir.format_registry.make_bzrdir('knit')
1083
1083
 
1084
1084
    We can't inherit directly from TestCaseWithTwoWebservers or the
1085
1085
    test framework will try to create an instance which cannot
1086
 
    run, its implementation being incomplete. 
 
1086
    run, its implementation being incomplete.
1087
1087
    """
1088
1088
 
1089
1089
    def create_transport_readonly_server(self):
1205
1205
 
1206
1206
class _TestBzrDir(bzrdir.BzrDirMeta1):
1207
1207
    """Test BzrDir implementation for TestBzrDirSprout.
1208
 
    
 
1208
 
1209
1209
    When created a _TestBzrDir already has repository and a branch.  The branch
1210
1210
    is a test double as well.
1211
1211
    """
1252
1252
        Usually, BzrDir.sprout should delegate to the branch's sprout method
1253
1253
        for part of the work.  This allows the source branch to control the
1254
1254
        choice of format for the new branch.
1255
 
        
 
1255
 
1256
1256
        There are exceptions, but this tests avoids them:
1257
1257
          - if there's no branch in the source bzrdir,
1258
1258
          - or if the stacking has been requested and the format needs to be