~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

  • Committer: Jelmer Vernooij
  • Date: 2012-04-02 01:44:26 UTC
  • mfrom: (6518 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6519.
  • Revision ID: jelmer@samba.org-20120402014426-0o5qtysohyl006b2
merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
170
170
        self.assertNotContainsRe(new, 'hidden')
171
171
 
172
172
    def test_set_default_repository(self):
173
 
        default_factory = bzrdir.format_registry.get('default')
174
 
        old_default = [k for k, v in bzrdir.format_registry.iteritems()
 
173
        default_factory = controldir.format_registry.get('default')
 
174
        old_default = [k for k, v in controldir.format_registry.iteritems()
175
175
                       if v == default_factory and k != 'default'][0]
176
 
        bzrdir.format_registry.set_default_repository('dirstate-with-subtree')
 
176
        controldir.format_registry.set_default_repository('dirstate-with-subtree')
177
177
        try:
178
 
            self.assertIs(bzrdir.format_registry.get('dirstate-with-subtree'),
179
 
                          bzrdir.format_registry.get('default'))
 
178
            self.assertIs(controldir.format_registry.get('dirstate-with-subtree'),
 
179
                          controldir.format_registry.get('default'))
180
180
            self.assertIs(
181
181
                repository.format_registry.get_default().__class__,
182
182
                knitrepo.RepositoryFormatKnit3)
183
183
        finally:
184
 
            bzrdir.format_registry.set_default_repository(old_default)
 
184
            controldir.format_registry.set_default_repository(old_default)
185
185
 
186
186
    def test_aliases(self):
187
187
        a_registry = controldir.ControlDirFormatRegistry()
212
212
    """A sample BzrDir implementation to allow testing static methods."""
213
213
 
214
214
    def create_repository(self, shared=False):
215
 
        """See BzrDir.create_repository."""
 
215
        """See ControlDir.create_repository."""
216
216
        return "A repository"
217
217
 
218
218
    def open_repository(self):
219
 
        """See BzrDir.open_repository."""
 
219
        """See ControlDir.open_repository."""
220
220
        return SampleRepository(self)
221
221
 
222
222
    def create_branch(self, name=None):
223
 
        """See BzrDir.create_branch."""
 
223
        """See ControlDir.create_branch."""
224
224
        if name is not None:
225
225
            raise NoColocatedBranchSupport(self)
226
226
        return SampleBranch(self)
227
227
 
228
228
    def create_workingtree(self):
229
 
        """See BzrDir.create_workingtree."""
 
229
        """See ControlDir.create_workingtree."""
230
230
        return "A tree"
231
231
 
232
232
 
337
337
    def test_create_branch_and_repo_under_shared(self):
338
338
        # creating a branch and repo in a shared repo uses the
339
339
        # shared repository
340
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
340
        format = controldir.format_registry.make_bzrdir('knit')
341
341
        self.make_repository('.', shared=True, format=format)
342
342
        branch = bzrdir.BzrDir.create_branch_and_repo(
343
343
            self.get_url('child'), format=format)
347
347
    def test_create_branch_and_repo_under_shared_force_new(self):
348
348
        # creating a branch and repo in a shared repo can be forced to
349
349
        # make a new repo
350
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
350
        format = controldir.format_registry.make_bzrdir('knit')
351
351
        self.make_repository('.', shared=True, format=format)
352
352
        branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url('child'),
353
353
                                                      force_new_repo=True,
367
367
 
368
368
    def test_create_standalone_working_tree_under_shared_repo(self):
369
369
        # create standalone working tree always makes a repo.
370
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
370
        format = controldir.format_registry.make_bzrdir('knit')
371
371
        self.make_repository('.', shared=True, format=format)
372
372
        # note this is deliberately readonly, as this failure should
373
373
        # occur before any writes.
380
380
 
381
381
    def test_create_branch_convenience(self):
382
382
        # outside a repo the default convenience output is a repo+branch_tree
383
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
383
        format = controldir.format_registry.make_bzrdir('knit')
384
384
        branch = bzrdir.BzrDir.create_branch_convenience('.', format=format)
385
385
        branch.bzrdir.open_workingtree()
386
386
        branch.bzrdir.open_repository()
387
387
 
388
388
    def test_create_branch_convenience_possible_transports(self):
389
389
        """Check that the optional 'possible_transports' is recognized"""
390
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
390
        format = controldir.format_registry.make_bzrdir('knit')
391
391
        t = self.get_transport()
392
392
        branch = bzrdir.BzrDir.create_branch_convenience(
393
393
            '.', format=format, possible_transports=[t])
398
398
        """Creating a branch at the root of a fs should work."""
399
399
        self.vfs_transport_factory = memory.MemoryServer
400
400
        # outside a repo the default convenience output is a repo+branch_tree
401
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
401
        format = controldir.format_registry.make_bzrdir('knit')
402
402
        branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(),
403
403
                                                         format=format)
404
404
        self.assertRaises(errors.NoWorkingTree,
408
408
    def test_create_branch_convenience_under_shared_repo(self):
409
409
        # inside a repo the default convenience output is a branch+ follow the
410
410
        # repo tree policy
411
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
411
        format = controldir.format_registry.make_bzrdir('knit')
412
412
        self.make_repository('.', shared=True, format=format)
413
413
        branch = bzrdir.BzrDir.create_branch_convenience('child',
414
414
            format=format)
419
419
    def test_create_branch_convenience_under_shared_repo_force_no_tree(self):
420
420
        # inside a repo the default convenience output is a branch+ follow the
421
421
        # repo tree policy but we can override that
422
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
422
        format = controldir.format_registry.make_bzrdir('knit')
423
423
        self.make_repository('.', shared=True, format=format)
424
424
        branch = bzrdir.BzrDir.create_branch_convenience('child',
425
425
            force_new_tree=False, format=format)
431
431
    def test_create_branch_convenience_under_shared_repo_no_tree_policy(self):
432
432
        # inside a repo the default convenience output is a branch+ follow the
433
433
        # repo tree policy
434
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
434
        format = controldir.format_registry.make_bzrdir('knit')
435
435
        repo = self.make_repository('.', shared=True, format=format)
436
436
        repo.set_make_working_trees(False)
437
437
        branch = bzrdir.BzrDir.create_branch_convenience('child',
444
444
    def test_create_branch_convenience_under_shared_repo_no_tree_policy_force_tree(self):
445
445
        # inside a repo the default convenience output is a branch+ follow the
446
446
        # repo tree policy but we can override that
447
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
447
        format = controldir.format_registry.make_bzrdir('knit')
448
448
        repo = self.make_repository('.', shared=True, format=format)
449
449
        repo.set_make_working_trees(False)
450
450
        branch = bzrdir.BzrDir.create_branch_convenience('child',
456
456
    def test_create_branch_convenience_under_shared_repo_force_new_repo(self):
457
457
        # inside a repo the default convenience output is overridable to give
458
458
        # repo+branch+tree
459
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
459
        format = controldir.format_registry.make_bzrdir('knit')
460
460
        self.make_repository('.', shared=True, format=format)
461
461
        branch = bzrdir.BzrDir.create_branch_convenience('child',
462
462
            force_new_repo=True, format=format)
523
523
        # general case.
524
524
        trunk = self.make_branch('trunk', format='1.9')
525
525
        t = self.get_transport('stacked')
526
 
        old_fmt = bzrdir.format_registry.make_bzrdir('pack-0.92')
 
526
        old_fmt = controldir.format_registry.make_bzrdir('pack-0.92')
527
527
        repo_name = old_fmt.repository_format.network_name()
528
528
        # Should end up with a 1.9 format (stackable)
529
529
        repo, control, require_stacking, repo_policy = \
1015
1015
        Metadirs should compare equal iff they have the same repo, branch and
1016
1016
        tree formats.
1017
1017
        """
1018
 
        mydir = bzrdir.format_registry.make_bzrdir('knit')
 
1018
        mydir = controldir.format_registry.make_bzrdir('knit')
1019
1019
        self.assertEqual(mydir, mydir)
1020
1020
        self.assertFalse(mydir != mydir)
1021
 
        otherdir = bzrdir.format_registry.make_bzrdir('knit')
 
1021
        otherdir = controldir.format_registry.make_bzrdir('knit')
1022
1022
        self.assertEqual(otherdir, mydir)
1023
1023
        self.assertFalse(otherdir != mydir)
1024
 
        otherdir2 = bzrdir.format_registry.make_bzrdir('development-subtree')
 
1024
        otherdir2 = controldir.format_registry.make_bzrdir('development-subtree')
1025
1025
        self.assertNotEqual(otherdir2, mydir)
1026
1026
        self.assertFalse(otherdir2 == mydir)
1027
1027
 
1039
1039
 
1040
1040
    def test_needs_conversion_different_working_tree(self):
1041
1041
        # meta1dirs need an conversion if any element is not the default.
1042
 
        new_format = bzrdir.format_registry.make_bzrdir('dirstate')
 
1042
        new_format = controldir.format_registry.make_bzrdir('dirstate')
1043
1043
        tree = self.make_branch_and_tree('tree', format='knit')
1044
1044
        self.assertTrue(tree.bzrdir.needs_format_conversion(
1045
1045
            new_format))
1046
1046
 
1047
1047
    def test_initialize_on_format_uses_smart_transport(self):
1048
1048
        self.setup_smart_server_with_call_log()
1049
 
        new_format = bzrdir.format_registry.make_bzrdir('dirstate')
 
1049
        new_format = controldir.format_registry.make_bzrdir('dirstate')
1050
1050
        transport = self.get_transport('target')
1051
1051
        transport.ensure_base()
1052
1052
        self.reset_smart_call_log()
1070
1070
 
1071
1071
    def test_create_branch_convenience(self):
1072
1072
        # outside a repo the default convenience output is a repo+branch_tree
1073
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
1073
        format = controldir.format_registry.make_bzrdir('knit')
1074
1074
        branch = bzrdir.BzrDir.create_branch_convenience(
1075
1075
            self.get_url('foo'), format=format)
1076
1076
        self.assertRaises(errors.NoWorkingTree,
1079
1079
 
1080
1080
    def test_create_branch_convenience_force_tree_not_local_fails(self):
1081
1081
        # outside a repo the default convenience output is a repo+branch_tree
1082
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
1082
        format = controldir.format_registry.make_bzrdir('knit')
1083
1083
        self.assertRaises(errors.NotLocalUrl,
1084
1084
            bzrdir.BzrDir.create_branch_convenience,
1085
1085
            self.get_url('foo'),
1090
1090
 
1091
1091
    def test_clone(self):
1092
1092
        # clone into a nonlocal path works
1093
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
1093
        format = controldir.format_registry.make_bzrdir('knit')
1094
1094
        branch = bzrdir.BzrDir.create_branch_convenience('local',
1095
1095
                                                         format=format)
1096
1096
        branch.bzrdir.open_workingtree()
1404
1404
            possible_transports=[self._transport])
1405
1405
        self._bzrdir = bzrdir.BzrDir.open_from_transport(self._transport)
1406
1406
 
1407
 
    def test_deprecated_generate_backup_name(self):
1408
 
        res = self.applyDeprecated(
1409
 
                symbol_versioning.deprecated_in((2, 3, 0)),
1410
 
                self._bzrdir.generate_backup_name, 'whatever')
1411
 
 
1412
1407
    def test_new(self):
1413
1408
        self.assertEqual("a.~1~", self._bzrdir._available_backup_name("a"))
1414
1409