/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_controldir/test_controldir.py

Add a 'brz clone' command.

Merged from https://code.launchpad.net/~jelmer/brz/clone/+merge/379369

Show diffs side-by-side

added added

removed removed

Lines of Context:
199
199
                                    "control directories without working tree")
200
200
        self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
201
201
 
202
 
    def test_clone_bzrdir_repository_under_shared(self):
 
202
    def test_clone_controldir_repository_under_shared(self):
203
203
        tree = self.make_branch_and_tree('commit_tree')
204
204
        self.build_tree(
205
205
            ['foo'], transport=tree.controldir.transport.clone('..'))
221
221
        self.assertNotEqual(dir.transport.base, target.transport.base)
222
222
        self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
223
223
 
224
 
    def test_clone_bzrdir_repository_branch_both_under_shared(self):
 
224
    def test_clone_controldir_repository_branch_both_under_shared(self):
225
225
        # Create a shared repository
226
226
        try:
227
227
            shared_repo = self.make_repository('shared', shared=True)
249
249
        dir.create_branch()
250
250
        # Clone 'source' to 'target', also inside the shared repository.
251
251
        target = dir.clone(self.get_url('shared/target'))
252
 
        # 'source', 'target', and the shared repo all have distinct bzrdirs.
 
252
        # 'source', 'target', and the shared repo all have distinct controldirs.
253
253
        self.assertNotEqual(dir.transport.base, target.transport.base)
254
254
        self.assertNotEqual(
255
255
            dir.transport.base, shared_repo.controldir.transport.base)
258
258
        # 'commit_tree' branch.
259
259
        self.assertTrue(shared_repo.has_revision(rev1))
260
260
 
261
 
    def test_clone_bzrdir_repository_branch_only_source_under_shared(self):
 
261
    def test_clone_controldir_repository_branch_only_source_under_shared(self):
262
262
        try:
263
263
            shared_repo = self.make_repository('shared', shared=True)
264
264
        except errors.IncompatibleFormat:
291
291
        self.assertFalse(branch.repository.make_working_trees())
292
292
        self.assertTrue(branch.repository.is_shared())
293
293
 
294
 
    def test_clone_bzrdir_repository_revision(self):
 
294
    def test_clone_controldir_repository_revision(self):
295
295
        # test for revision limiting, [smoke test, not corner case checks].
296
296
        # make a repository with some revisions,
297
297
        # and clone it with a revision limit.
310
310
        dir.clone(self.get_url('target'), revision_id=rev2)
311
311
        raise TestSkipped('revision limiting not strict yet')
312
312
 
313
 
    def test_clone_bzrdir_branch_and_repo_fixed_user_id(self):
 
313
    def test_clone_controldir_branch_and_repo_fixed_user_id(self):
314
314
        # Bug #430868 is about an email containing '.sig'
315
315
        self.overrideEnv('BRZ_EMAIL', 'murphy@host.sighup.org')
316
316
        tree = self.make_branch_and_tree('commit_tree')
330
330
            tree_repo.get_signature_text(rev1),
331
331
            target.repository.get_signature_text(rev1))
332
332
 
333
 
    def test_clone_bzrdir_branch_and_repo_into_shared_repo(self):
 
333
    def test_clone_controldir_branch_and_repo_into_shared_repo(self):
334
334
        # by default cloning into a shared repo uses the shared repo.
335
335
        tree = self.make_branch_and_tree('commit_tree')
336
336
        self.build_tree(['commit_tree/foo'])
354
354
        self.assertEqual(source.last_revision(),
355
355
                         target.open_branch().last_revision())
356
356
 
357
 
    def test_clone_bzrdir_branch_revision(self):
 
357
    def test_clone_controldir_branch_revision(self):
358
358
        # test for revision limiting, [smoke test, not corner case checks].
359
359
        # make a branch with some revisions,
360
360
        # and clone it with a revision limit.
371
371
        target = dir.clone(self.get_url('target'), revision_id=rev1)
372
372
        self.assertEqual(rev1, target.open_branch().last_revision())
373
373
 
 
374
    def test_clone_controldir_with_colocated(self):
 
375
        if not self.bzrdir_format.colocated_branches:
 
376
            raise TestNotApplicable(
 
377
                'format does not supported colocated branches')
 
378
        tree = self.make_branch_and_tree('commit_tree')
 
379
        self.build_tree(['commit_tree/foo'])
 
380
        tree.add('foo')
 
381
        rev1 = tree.commit('revision 1')
 
382
        rev2 = tree.commit('revision 2', allow_pointless=True)
 
383
        rev3 = tree.commit('revision 2', allow_pointless=True)
 
384
        dir = tree.branch.controldir
 
385
        colo = dir.create_branch(name='colo')
 
386
        colo.pull(tree.branch, stop_revision=rev1)
 
387
        target = dir.clone(self.get_url('target'), revision_id=rev2)
 
388
        self.assertEqual(rev2, target.open_branch().last_revision())
 
389
        self.assertEqual(rev1, target.open_branch(name='colo').last_revision())
 
390
 
374
391
    def test_clone_on_transport_preserves_repo_format(self):
375
392
        if self.bzrdir_format == controldir.format_registry.make_controldir('default'):
376
393
            format = 'knit'
381
398
        a_dir = breezy.branch.Branch.open_from_transport(
382
399
            self.get_transport('source')).controldir
383
400
        target_transport = self.get_transport('target')
384
 
        target_bzrdir = a_dir.clone_on_transport(target_transport)
385
 
        target_repo = target_bzrdir.open_repository()
 
401
        target_controldir = a_dir.clone_on_transport(target_transport)
 
402
        target_repo = target_controldir.open_repository()
386
403
        source_branch = breezy.branch.Branch.open(
387
404
            self.get_vfs_only_url('source'))
388
405
        if isinstance(target_repo, RemoteRepository):
390
407
            target_repo = target_repo._real_repository
391
408
        self.assertEqual(target_repo._format, source_branch.repository._format)
392
409
 
393
 
    def test_clone_bzrdir_tree_revision(self):
 
410
    def test_clone_controldir_tree_revision(self):
394
411
        # test for revision limiting, [smoke test, not corner case checks].
395
412
        # make a tree with a revision with a last-revision
396
413
        # and clone it with a revision limit.
406
423
        self.skipIfNoWorkingTree(target)
407
424
        self.assertEqual([rev1], target.open_workingtree().get_parent_ids())
408
425
 
409
 
    def test_clone_bzrdir_into_notrees_repo(self):
 
426
    def test_clone_controldir_into_notrees_repo(self):
410
427
        """Cloning into a no-trees repo should not create a working tree"""
411
428
        tree = self.make_branch_and_tree('source')
412
429
        self.build_tree(['source/foo'])
514
531
        """get_branch_reference should not mask NotBranchErrors."""
515
532
        dir = self.make_controldir('source')
516
533
        if dir.has_branch():
517
 
            # this format does not support branchless bzrdirs.
 
534
            # this format does not support branchless controldirs.
518
535
            raise TestNotApplicable("format does not support "
519
536
                                    "branchless control directories")
520
537
        self.assertRaises(errors.NotBranchError, dir.get_branch_reference)
521
538
 
522
 
    def test_sprout_bzrdir_empty(self):
 
539
    def test_sprout_controldir_empty(self):
523
540
        dir = self.make_controldir('source')
524
541
        target = dir.sprout(self.get_url('target'))
525
542
        self.assertNotEqual(dir.control_transport.base,
529
546
        target.open_branch()
530
547
        self.openWorkingTreeIfLocal(target)
531
548
 
532
 
    def test_sprout_bzrdir_empty_under_shared_repo(self):
 
549
    def test_sprout_controldir_empty_under_shared_repo(self):
533
550
        # sprouting an empty dir into a repo uses the repo
534
551
        dir = self.make_controldir('source')
535
552
        try:
543
560
        try:
544
561
            target.open_workingtree()
545
562
        except errors.NoWorkingTree:
546
 
            # Some bzrdirs can never have working trees.
 
563
            # Some controldirs can never have working trees.
547
564
            repo = target.find_repository()
548
565
            self.assertFalse(repo.controldir._format.supports_workingtrees)
549
566
 
550
 
    def test_sprout_bzrdir_empty_under_shared_repo_force_new(self):
 
567
    def test_sprout_controldir_empty_under_shared_repo_force_new(self):
551
568
        # the force_new_repo parameter should force use of a new repo in an empty
552
 
        # bzrdir's sprout logic
 
569
        # controldir's sprout logic
553
570
        dir = self.make_controldir('source')
554
571
        try:
555
572
            self.make_repository('target', shared=True)
561
578
        target.open_branch()
562
579
        self.openWorkingTreeIfLocal(target)
563
580
 
564
 
    def test_sprout_bzrdir_with_repository_to_shared(self):
 
581
    def test_sprout_controldir_with_repository_to_shared(self):
565
582
        tree = self.make_branch_and_tree('commit_tree')
566
583
        self.build_tree(['commit_tree/foo'])
567
584
        tree.add('foo')
583
600
                            target.user_transport.base)
584
601
        self.assertTrue(shared_repo.has_revision(rev1))
585
602
 
586
 
    def test_sprout_bzrdir_repository_branch_both_under_shared(self):
 
603
    def test_sprout_controldir_repository_branch_both_under_shared(self):
587
604
        try:
588
605
            shared_repo = self.make_repository('shared', shared=True)
589
606
        except errors.IncompatibleFormat:
609
626
                            shared_repo.controldir.transport.base)
610
627
        self.assertTrue(shared_repo.has_revision(rev1))
611
628
 
612
 
    def test_sprout_bzrdir_repository_branch_only_source_under_shared(self):
 
629
    def test_sprout_controldir_repository_branch_only_source_under_shared(self):
613
630
        try:
614
631
            shared_repo = self.make_repository('shared', shared=True)
615
632
        except errors.IncompatibleFormat:
639
656
            dir.transport.base,
640
657
            shared_repo.controldir.transport.base)
641
658
        branch = target.open_branch()
642
 
        # The sprouted bzrdir has a branch, so only revisions referenced by
 
659
        # The sprouted controldir has a branch, so only revisions referenced by
643
660
        # that branch are copied, rather than the whole repository.  It's an
644
661
        # empty branch, so none are copied.
645
662
        self.assertEqual([], branch.repository.all_revision_ids())
647
664
            self.assertTrue(branch.repository.make_working_trees())
648
665
        self.assertFalse(branch.repository.is_shared())
649
666
 
650
 
    def test_sprout_bzrdir_repository_under_shared_force_new_repo(self):
 
667
    def test_sprout_controldir_repository_under_shared_force_new_repo(self):
651
668
        tree = self.make_branch_and_tree('commit_tree')
652
669
        self.build_tree(['commit_tree/foo'])
653
670
        tree.add('foo')
670
687
            target.control_transport.base)
671
688
        self.assertFalse(shared_repo.has_revision(rev1))
672
689
 
673
 
    def test_sprout_bzrdir_repository_revision(self):
 
690
    def test_sprout_controldir_repository_revision(self):
674
691
        # test for revision limiting, [smoke test, not corner case checks].
675
692
        # make a repository with some revisions,
676
693
        # and sprout it with a revision limit.
689
706
        self.sproutOrSkip(dir, self.get_url('target'), revision_id=rev2)
690
707
        raise TestSkipped('revision limiting not strict yet')
691
708
 
692
 
    def test_sprout_bzrdir_branch_and_repo_shared(self):
 
709
    def test_sprout_controldir_branch_and_repo_shared(self):
693
710
        # sprouting a branch with a repo into a shared repo uses the shared
694
711
        # repo
695
712
        tree = self.make_branch_and_tree('commit_tree')
708
725
        dir.sprout(self.get_url('target/child'))
709
726
        self.assertTrue(shared_repo.has_revision(rev1))
710
727
 
711
 
    def test_sprout_bzrdir_branch_and_repo_shared_force_new_repo(self):
 
728
    def test_sprout_controldir_branch_and_repo_shared_force_new_repo(self):
712
729
        # sprouting a branch with a repo into a shared repo uses the shared
713
730
        # repo
714
731
        tree = self.make_branch_and_tree('commit_tree')
729
746
            dir.control_transport.base, target.control_transport.base)
730
747
        self.assertFalse(shared_repo.has_revision(rev1))
731
748
 
732
 
    def test_sprout_bzrdir_branch_reference(self):
 
749
    def test_sprout_controldir_branch_reference(self):
733
750
        # sprouting should create a repository if needed and a sprouted branch.
734
751
        referenced_branch = self.make_branch('referenced')
735
752
        dir = self.make_controldir('source')
747
764
        # place
748
765
        target.open_repository()
749
766
 
750
 
    def test_sprout_bzrdir_branch_reference_shared(self):
 
767
    def test_sprout_controldir_branch_reference_shared(self):
751
768
        # sprouting should create a repository if needed and a sprouted branch.
752
769
        referenced_tree = self.make_branch_and_tree('referenced')
753
770
        rev1 = referenced_tree.commit('1', allow_pointless=True)
773
790
        # and we want revision '1' in the shared repo
774
791
        self.assertTrue(shared_repo.has_revision(rev1))
775
792
 
776
 
    def test_sprout_bzrdir_branch_reference_shared_force_new_repo(self):
 
793
    def test_sprout_controldir_branch_reference_shared_force_new_repo(self):
777
794
        # sprouting should create a repository if needed and a sprouted branch.
778
795
        referenced_tree = self.make_branch_and_tree('referenced')
779
796
        rev1 = referenced_tree.commit('1', allow_pointless=True)
799
816
        # but not the shared one
800
817
        self.assertFalse(shared_repo.has_revision(rev1))
801
818
 
802
 
    def test_sprout_bzrdir_branch_revision(self):
 
819
    def test_sprout_controldir_branch_revision(self):
803
820
        # test for revision limiting, [smoke test, not corner case checks].
804
821
        # make a repository with some revisions,
805
822
        # and sprout it with a revision limit.
816
833
        target = dir.sprout(self.get_url('target'), revision_id=rev1)
817
834
        self.assertEqual(rev1, target.open_branch().last_revision())
818
835
 
819
 
    def test_sprout_bzrdir_branch_with_tags(self):
 
836
    def test_sprout_controldir_branch_with_tags(self):
820
837
        # when sprouting a branch all revisions named in the tags are copied
821
838
        # too.
822
839
        builder = self.make_branch_builder('source')
835
852
        self.assertEqual(rev2, new_branch.tags.lookup_tag('tag-a'))
836
853
        new_branch.repository.get_revision(rev2)
837
854
 
838
 
    def test_sprout_bzrdir_branch_with_absent_tag(self):
 
855
    def test_sprout_controldir_branch_with_absent_tag(self):
839
856
        # tags referencing absent revisions are copied (and those absent
840
857
        # revisions do not prevent the sprout.)
841
858
        builder = self.make_branch_builder('source')
855
872
        new_branch = target.open_branch()
856
873
        self.assertEqual(b'missing-rev', new_branch.tags.lookup_tag('tag-a'))
857
874
 
858
 
    def test_sprout_bzrdir_passing_source_branch_with_absent_tag(self):
 
875
    def test_sprout_controldir_passing_source_branch_with_absent_tag(self):
859
876
        # tags referencing absent revisions are copied (and those absent
860
877
        # revisions do not prevent the sprout.)
861
878
        builder = self.make_branch_builder('source')
875
892
        new_branch = target.open_branch()
876
893
        self.assertEqual(b'missing-rev', new_branch.tags.lookup_tag('tag-a'))
877
894
 
878
 
    def test_sprout_bzrdir_passing_rev_not_source_branch_copies_tags(self):
 
895
    def test_sprout_controldir_passing_rev_not_source_branch_copies_tags(self):
879
896
        # dir.sprout(..., revision_id=b'rev1') copies rev1, and all the tags of
880
 
        # the branch at that bzrdir, the ancestry of all of those, but no other
 
897
        # the branch at that controldir, the ancestry of all of those, but no other
881
898
        # revs (not even the tip of the source branch).
882
899
        builder = self.make_branch_builder('source')
883
900
        base_rev = builder.build_commit(message="Base")
927
944
            sorted([base_rev, rev_b1, rev_b2, rev_c1, rev_c2]),
928
945
            sorted(new_branch.repository.all_revision_ids()))
929
946
 
930
 
    def test_sprout_bzrdir_tree_branch_reference(self):
 
947
    def test_sprout_controldir_tree_branch_reference(self):
931
948
        # sprouting should create a repository if needed and a sprouted branch.
932
949
        # the tree state should not be copied.
933
950
        referenced_branch = self.make_branch('referencced')
952
969
        result_tree = target.open_workingtree()
953
970
        self.assertFalse(result_tree.has_filename('subdir'))
954
971
 
955
 
    def test_sprout_bzrdir_tree_branch_reference_revision(self):
 
972
    def test_sprout_controldir_tree_branch_reference_revision(self):
956
973
        # sprouting should create a repository if needed and a sprouted branch.
957
974
        # the tree state should not be copied but the revision changed,
958
975
        # and the likewise the new branch should be truncated too
982
999
        self.assertEqual([rev1], target.open_workingtree().get_parent_ids())
983
1000
        self.assertEqual(rev1, target.open_branch().last_revision())
984
1001
 
985
 
    def test_sprout_bzrdir_tree_revision(self):
 
1002
    def test_sprout_controldir_tree_revision(self):
986
1003
        # test for revision limiting, [smoke test, not corner case checks].
987
1004
        # make a tree with a revision with a last-revision
988
1005
        # and sprout it with a revision limit.
1034
1051
        rev3 = builder.build_commit(message='Rev 3.')
1035
1052
        builder.finish_series()
1036
1053
        stack_on = builder.get_branch()
1037
 
        # Make a bzrdir with a default stacking policy to stack on that branch.
 
1054
        # Make a controldir with a default stacking policy to stack on that branch.
1038
1055
        config = self.make_controldir('policy-dir').get_config()
1039
1056
        try:
1040
1057
            config.set_default_stack_on(self.get_url('stack-on'))
1041
1058
        except errors.BzrError:
1042
1059
            raise TestNotApplicable('Only relevant for stackable formats.')
1043
 
        # Sprout the stacked-on branch into the bzrdir.
 
1060
        # Sprout the stacked-on branch into the controldir.
1044
1061
        sprouted = stack_on.controldir.sprout(
1045
1062
            self.get_url('policy-dir/sprouted'), revision_id=rev3)
1046
1063
        # Not all revisions are copied into the sprouted repository.
1288
1305
        repo.controldir.create_branch()
1289
1306
        self.assertEqual([""], list(repo.controldir.get_branches()))
1290
1307
 
 
1308
    def test_branch_names(self):
 
1309
        repo = self.make_repository('branch-1')
 
1310
        repo.controldir.create_branch()
 
1311
        self.assertEqual([""], repo.controldir.branch_names())
 
1312
 
1291
1313
    def test_create_repository(self):
1292
1314
        # a bzrdir can construct a repository for itself.
1293
1315
        if not self.bzrdir_format.is_initializable():