/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 breezy/tests/test_branch.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 16:40:42 UTC
  • mfrom: (6653.6.7 rename-controldir)
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170610164042-zrxqgy2htyduvke2
MergeĀ rename-controldirĀ branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
        """See BzrBranchFormat.get_format_string()."""
123
123
        return "Sample branch format."
124
124
 
125
 
    def initialize(self, a_bzrdir, name=None, repository=None,
 
125
    def initialize(self, a_controldir, name=None, repository=None,
126
126
                   append_revisions_only=None):
127
127
        """Format 4 branches cannot be created."""
128
 
        t = a_bzrdir.get_branch_transport(self, name=name)
 
128
        t = a_controldir.get_branch_transport(self, name=name)
129
129
        t.put_bytes('format', self.get_format_string())
130
130
        return 'A branch'
131
131
 
150
150
        """See BzrBranchFormat.get_format_string()."""
151
151
        return SampleSupportedBranchFormatString
152
152
 
153
 
    def initialize(self, a_bzrdir, name=None, append_revisions_only=None):
154
 
        t = a_bzrdir.get_branch_transport(self, name=name)
 
153
    def initialize(self, a_controldir, name=None, append_revisions_only=None):
 
154
        t = a_controldir.get_branch_transport(self, name=name)
155
155
        t.put_bytes('format', self.get_format_string())
156
156
        return 'A branch'
157
157
 
171
171
        # Network name always has to be provided.
172
172
        return "extra"
173
173
 
174
 
    def initialize(self, a_bzrdir, name=None):
 
174
    def initialize(self, a_controldir, name=None):
175
175
        raise NotImplementedError(self.initialize)
176
176
 
177
177
    def open(self, transport, name=None, _found=False, ignore_fallbacks=False,
218
218
    def test_find_format_with_features(self):
219
219
        tree = self.make_branch_and_tree('.', format='2a')
220
220
        tree.branch.update_feature_flags({"name": "optional"})
221
 
        found_format = _mod_bzrbranch.BranchFormatMetadir.find_format(tree.bzrdir)
 
221
        found_format = _mod_bzrbranch.BranchFormatMetadir.find_format(tree.controldir)
222
222
        self.assertIsInstance(found_format, _mod_bzrbranch.BranchFormatMetadir)
223
223
        self.assertEqual(found_format.features.get("name"), "optional")
224
224
        tree.branch.update_feature_flags({"name": None})
377
377
 
378
378
    def test_set_stacked_on_url_unstackable_repo(self):
379
379
        repo = self.make_repository('a', format='dirstate-tags')
380
 
        control = repo.bzrdir
 
380
        control = repo.controldir
381
381
        branch = _mod_bzrbranch.BzrBranchFormat7().initialize(control)
382
382
        target = self.make_branch('b')
383
383
        self.assertRaises(errors.UnstackableRepositoryFormat,
385
385
 
386
386
    def test_clone_stacked_on_unstackable_repo(self):
387
387
        repo = self.make_repository('a', format='dirstate-tags')
388
 
        control = repo.bzrdir
 
388
        control = repo.controldir
389
389
        branch = _mod_bzrbranch.BzrBranchFormat7().initialize(control)
390
390
        # Calling clone should not raise UnstackableRepositoryFormat.
391
391
        cloned_bzrdir = control.clone('cloned')
409
409
        branch = self.make_branch('a', format=self.get_format_name())
410
410
        target = self.make_branch_and_tree('b', format=self.get_format_name())
411
411
        branch.set_stacked_on_url(target.branch.base)
412
 
        branch = branch.bzrdir.open_branch()
 
412
        branch = branch.controldir.open_branch()
413
413
        revid = target.commit('foo')
414
414
        self.assertTrue(branch.repository.has_revision(revid))
415
415
 
418
418
 
419
419
    def make_branch(self, location, format=None):
420
420
        if format is None:
421
 
            format = controldir.format_registry.make_bzrdir('1.9')
 
421
            format = controldir.format_registry.make_controldir('1.9')
422
422
            format.set_branch_format(_mod_bzrbranch.BzrBranchFormat8())
423
423
        return tests.TestCaseWithTransport.make_branch(
424
424
            self, location, format=format)
508
508
        """For a BranchReference, get_reference should return the location."""
509
509
        branch = self.make_branch('target')
510
510
        checkout = branch.create_checkout('checkout', lightweight=True)
511
 
        reference_url = branch.bzrdir.root_transport.abspath('') + '/'
 
511
        reference_url = branch.controldir.root_transport.abspath('') + '/'
512
512
        # if the api for create_checkout changes to return different checkout types
513
513
        # then this file read will fail.
514
514
        self.assertFileEqual(reference_url, 'checkout/.bzr/branch/location')
515
515
        self.assertEqual(reference_url,
516
 
            _mod_bzrbranch.BranchReferenceFormat().get_reference(checkout.bzrdir))
 
516
            _mod_bzrbranch.BranchReferenceFormat().get_reference(checkout.controldir))
517
517
 
518
518
 
519
519
class TestHooks(tests.TestCaseWithTransport):
549
549
        self.assertLength(1, calls)
550
550
        params = calls[0]
551
551
        self.assertIsInstance(params, _mod_branch.BranchInitHookParams)
552
 
        self.assertTrue(hasattr(params, 'bzrdir'))
 
552
        self.assertTrue(hasattr(params, 'controldir'))
553
553
        self.assertTrue(hasattr(params, 'branch'))
554
554
 
555
555
    def test_post_branch_init_hook_repr(self):
570
570
        self.build_tree(['branch-1/file-1'])
571
571
        tree.add('file-1')
572
572
        tree.commit('rev1')
573
 
        to_branch = tree.bzrdir.sprout('branch-2').open_branch()
 
573
        to_branch = tree.controldir.sprout('branch-2').open_branch()
574
574
        self.build_tree(['branch-1/file-2'])
575
575
        tree.add('file-2')
576
576
        tree.remove('file-1')
577
577
        tree.commit('rev2')
578
578
        checkout = tree.branch.create_checkout('checkout')
579
579
        self.assertLength(0, calls)
580
 
        switch.switch(checkout.bzrdir, to_branch)
 
580
        switch.switch(checkout.controldir, to_branch)
581
581
        self.assertLength(1, calls)
582
582
        params = calls[0]
583
583
        self.assertIsInstance(params, _mod_branch.SwitchHookParams)