/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/per_branch/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:
143
143
        # wt_a might be a lightweight checkout, so get a hold of the actual
144
144
        # branch (because you can't do a partial clone of a lightweight
145
145
        # checkout).
146
 
        branch = wt_a.branch.bzrdir.open_branch()
 
146
        branch = wt_a.branch.controldir.open_branch()
147
147
        # Then make a branch where the new repository is, but specify a revision
148
148
        # ID.  The new branch's history will stop at the specified revision.
149
 
        br_b = branch.clone(repo_b.bzrdir, revision_id='1')
 
149
        br_b = branch.clone(repo_b.controldir, revision_id='1')
150
150
        self.assertEqual('1', br_b.last_revision())
151
151
 
152
152
    def get_parented_branch(self):
155
155
        wt_a.add(['one'])
156
156
        wt_a.commit('commit one', rev_id='1')
157
157
 
158
 
        branch_b = wt_a.branch.bzrdir.sprout('b', revision_id='1').open_branch()
 
158
        branch_b = wt_a.branch.controldir.sprout('b', revision_id='1').open_branch()
159
159
        self.assertEqual(wt_a.branch.base, branch_b.get_parent())
160
160
        return branch_b
161
161
 
168
168
        branch_b = self.get_parented_branch()
169
169
        repo_c = self.make_repository('c')
170
170
        branch_b.repository.copy_content_into(repo_c)
171
 
        branch_c = branch_b.clone(repo_c.bzrdir)
 
171
        branch_c = branch_b.clone(repo_c.controldir)
172
172
        self.assertNotEqual(None, branch_c.get_parent())
173
173
        self.assertEqual(branch_b.get_parent(), branch_c.get_parent())
174
174
 
177
177
        branch_b.set_parent(random_parent)
178
178
        repo_d = self.make_repository('d')
179
179
        branch_b.repository.copy_content_into(repo_d)
180
 
        branch_d = branch_b.clone(repo_d.bzrdir)
 
180
        branch_d = branch_b.clone(repo_d.controldir)
181
181
        self.assertEqual(random_parent, branch_d.get_parent())
182
182
 
183
183
    def test_submit_branch(self):
305
305
            repo = self.make_repository('.', shared=True)
306
306
        except errors.IncompatibleFormat:
307
307
            return
308
 
        if repo.bzrdir._format.colocated_branches:
 
308
        if repo.controldir._format.colocated_branches:
309
309
            raise tests.TestNotApplicable(
310
310
                "control dir does not support colocated branches")
311
 
        self.assertEqual(0, len(repo.bzrdir.list_branches()))
 
311
        self.assertEqual(0, len(repo.controldir.list_branches()))
312
312
        if not self.bzrdir_format.colocated_branches:
313
313
            raise tests.TestNotApplicable("control dir format does not support "
314
314
                "colocated branches")
315
315
        try:
316
 
            child_branch1 = self.branch_format.initialize(repo.bzrdir, 
 
316
            child_branch1 = self.branch_format.initialize(repo.controldir, 
317
317
                name='branch1')
318
318
        except errors.UninitializableFormat:
319
319
            # branch references are not default init'able and
320
320
            # not all bzrdirs support colocated branches.
321
321
            return
322
 
        self.assertEqual(1, len(repo.bzrdir.list_branches()))
323
 
        self.branch_format.initialize(repo.bzrdir, name='branch2')
324
 
        self.assertEqual(2, len(repo.bzrdir.list_branches()))
 
322
        self.assertEqual(1, len(repo.controldir.list_branches()))
 
323
        self.branch_format.initialize(repo.controldir, name='branch2')
 
324
        self.assertEqual(2, len(repo.controldir.list_branches()))
325
325
 
326
326
    def test_create_append_revisions_only(self):
327
327
        try:
330
330
            return
331
331
        for val in (True, False):
332
332
            try:
333
 
                branch = self.branch_format.initialize(repo.bzrdir,
 
333
                branch = self.branch_format.initialize(repo.controldir,
334
334
                    append_revisions_only=True)
335
335
            except (errors.UninitializableFormat, errors.UpgradeRequired):
336
336
                # branch references are not default init'able and
337
337
                # not all branches support append_revisions_only
338
338
                return
339
339
            self.assertEqual(True, branch.get_append_revisions_only())
340
 
            repo.bzrdir.destroy_branch()
 
340
            repo.controldir.destroy_branch()
341
341
 
342
342
    def test_get_set_append_revisions_only(self):
343
343
        branch = self.make_branch('.')
356
356
            repo = self.make_repository('.', shared=True)
357
357
        except errors.IncompatibleFormat:
358
358
            raise tests.TestNotApplicable("requires shared repository support")
359
 
        child_transport = repo.bzrdir.root_transport.clone('child')
 
359
        child_transport = repo.controldir.root_transport.clone('child')
360
360
        child_transport.mkdir('.')
361
361
        try:
362
362
            child_dir = self.bzrdir_format.initialize_on_transport(child_transport)
367
367
        except errors.UninitializableFormat:
368
368
            # branch references are not default init'able.
369
369
            return
370
 
        self.assertEqual(repo.bzrdir.root_transport.base,
371
 
                         child_branch.repository.bzrdir.root_transport.base)
 
370
        self.assertEqual(repo.controldir.root_transport.base,
 
371
                         child_branch.repository.controldir.root_transport.base)
372
372
        child_branch = _mod_branch.Branch.open(self.get_url('child'))
373
 
        self.assertEqual(repo.bzrdir.root_transport.base,
374
 
                         child_branch.repository.bzrdir.root_transport.base)
 
373
        self.assertEqual(repo.controldir.root_transport.base,
 
374
                         child_branch.repository.controldir.root_transport.base)
375
375
 
376
376
    def test_format_description(self):
377
377
        tree = self.make_branch_and_tree('tree')
437
437
        # open the branch via a readonly transport
438
438
        url = self.get_readonly_url(urlutils.basename(tree_a.branch.base))
439
439
        t = transport.get_transport_from_url(url)
440
 
        if not tree_a.branch.bzrdir._format.supports_transport(t):
 
440
        if not tree_a.branch.controldir._format.supports_transport(t):
441
441
            raise tests.TestNotApplicable("format does not support transport")
442
442
        source_branch = _mod_branch.Branch.open(url)
443
443
        # sanity check that the test will be valid
454
454
        url = self.get_readonly_url(
455
455
            osutils.basename(tree_a.branch.base.rstrip('/')))
456
456
        t = transport.get_transport_from_url(url)
457
 
        if not tree_a.branch.bzrdir._format.supports_transport(t):
 
457
        if not tree_a.branch.controldir._format.supports_transport(t):
458
458
            raise tests.TestNotApplicable("format does not support transport")
459
459
        source_branch = _mod_branch.Branch.open(url)
460
460
        # sanity check that the test will be valid
533
533
                          _mod_branch.Branch.open_containing,
534
534
                          self.get_readonly_url('g/p/q'))
535
535
        branch = self.make_branch('.')
536
 
        if not branch.bzrdir._format.supports_transport(
 
536
        if not branch.controldir._format.supports_transport(
537
537
            transport.get_transport_from_url(self.get_readonly_url('.'))):
538
538
            raise tests.TestNotApplicable("format does not support transport")
539
539
        branch, relpath = _mod_branch.Branch.open_containing(
650
650
            return
651
651
        made_branch = self.make_branch('.')
652
652
        self.assertEqual(None,
653
 
            made_branch._format.get_reference(made_branch.bzrdir))
 
653
            made_branch._format.get_reference(made_branch.controldir))
654
654
 
655
655
    def test_set_reference(self):
656
656
        """set_reference on all regular branches should be callable."""
662
662
        this_branch = self.make_branch('this')
663
663
        other_branch = self.make_branch('other')
664
664
        try:
665
 
            this_branch._format.set_reference(this_branch.bzrdir, None,
 
665
            this_branch._format.set_reference(this_branch.controldir, None,
666
666
                other_branch)
667
667
        except NotImplementedError:
668
668
            # that's ok
669
669
            pass
670
670
        else:
671
 
            ref = this_branch._format.get_reference(this_branch.bzrdir)
 
671
            ref = this_branch._format.get_reference(this_branch.controldir)
672
672
            self.assertEqual(ref, other_branch.base)
673
673
 
674
674
    def test_format_initialize_find_open(self):
688
688
        opened_control = controldir.ControlDir.open(readonly_t.base)
689
689
        direct_opened_branch = opened_control.open_branch()
690
690
        self.assertEqual(direct_opened_branch.__class__, made_branch.__class__)
691
 
        self.assertEqual(opened_control, direct_opened_branch.bzrdir)
 
691
        self.assertEqual(opened_control, direct_opened_branch.controldir)
692
692
        self.assertIsInstance(direct_opened_branch._format,
693
693
            self.branch_format.__class__)
694
694
 
735
735
    def test_bind_diverged(self):
736
736
        tree_a = self.make_branch_and_tree('tree_a')
737
737
        tree_a.commit('rev1a')
738
 
        tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
 
738
        tree_b = tree_a.controldir.sprout('tree_b').open_workingtree()
739
739
        tree_a.commit('rev2a')
740
740
        tree_b.commit('rev2b')
741
741
        try:
797
797
        except errors.UpgradeRequired:
798
798
            raise tests.TestSkipped('Format does not support strict history')
799
799
        tree1.commit('empty commit')
800
 
        tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
 
800
        tree2 = tree1.controldir.sprout('tree2').open_workingtree()
801
801
        tree2.commit('empty commit 2')
802
802
        tree1.pull(tree2.branch)
803
803
        tree1.commit('empty commit 3')
807
807
        tree2.commit('empty commit 5')
808
808
        self.assertRaises(errors.AppendRevisionsOnlyViolation, tree1.pull,
809
809
                          tree2.branch)
810
 
        tree3 = tree1.bzrdir.sprout('tree3').open_workingtree()
 
810
        tree3 = tree1.controldir.sprout('tree3').open_workingtree()
811
811
        tree3.merge_from_branch(tree2.branch)
812
812
        tree3.commit('empty commit 6')
813
813
        tree2.pull(tree3.branch)
863
863
        reference_parent = tree.branch.reference_parent('subtree-id',
864
864
            urlutils.relative_url(
865
865
                tree.branch.user_url, subtree.branch.user_url),
866
 
            possible_transports=[subtree.bzrdir.root_transport])
 
866
            possible_transports=[subtree.controldir.root_transport])
867
867
 
868
868
    def test_get_reference_info(self):
869
869
        branch = self.make_branch('branch')
960
960
 
961
961
    def test_sprout_copies_reference_location(self):
962
962
        branch = self.make_branch_with_reference('branch', '../reference')
963
 
        new_branch = branch.bzrdir.sprout('new-branch').open_branch()
 
963
        new_branch = branch.controldir.sprout('new-branch').open_branch()
964
964
        self.assertEqual('../reference',
965
965
                         new_branch.get_reference_info('file-id')[1])
966
966
 
967
967
    def test_clone_copies_reference_location(self):
968
968
        branch = self.make_branch_with_reference('branch', '../reference')
969
 
        new_branch = branch.bzrdir.clone('new-branch').open_branch()
 
969
        new_branch = branch.controldir.clone('new-branch').open_branch()
970
970
        self.assertEqual('../reference',
971
971
                         new_branch.get_reference_info('file-id')[1])
972
972
 
973
973
    def test_copied_locations_are_rebased(self):
974
974
        branch = self.make_branch_with_reference('branch', 'reference')
975
 
        new_branch = branch.bzrdir.sprout('branch/new-branch').open_branch()
 
975
        new_branch = branch.controldir.sprout('branch/new-branch').open_branch()
976
976
        self.assertEqual('../reference',
977
977
                         new_branch.get_reference_info('file-id')[1])
978
978
 
994
994
 
995
995
    def test_update_references_skips_known_references(self):
996
996
        branch = self.make_branch_with_reference('branch', 'reference')
997
 
        new_branch = branch.bzrdir.sprout('branch/new-branch').open_branch()
 
997
        new_branch = branch.controldir.sprout('branch/new-branch').open_branch()
998
998
        new_branch.set_reference_info('file-id', '../foo', '../foo')
999
999
        new_branch.update_references(branch)
1000
1000
        self.assertEqual('reference',
1002
1002
 
1003
1003
    def test_pull_updates_references(self):
1004
1004
        branch = self.make_branch_with_reference('branch', 'reference')
1005
 
        new_branch = branch.bzrdir.sprout('branch/new-branch').open_branch()
 
1005
        new_branch = branch.controldir.sprout('branch/new-branch').open_branch()
1006
1006
        new_branch.set_reference_info('file-id2', '../foo', '../foo')
1007
1007
        branch.pull(new_branch)
1008
1008
        self.assertEqual('foo',
1010
1010
 
1011
1011
    def test_push_updates_references(self):
1012
1012
        branch = self.make_branch_with_reference('branch', 'reference')
1013
 
        new_branch = branch.bzrdir.sprout('branch/new-branch').open_branch()
 
1013
        new_branch = branch.controldir.sprout('branch/new-branch').open_branch()
1014
1014
        new_branch.set_reference_info('file-id2', '../foo', '../foo')
1015
1015
        new_branch.push(branch)
1016
1016
        self.assertEqual('foo',