~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_info.py

Merged bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import sys
22
22
 
23
23
import bzrlib
24
 
from bzrlib import repository
 
24
from bzrlib import (
 
25
    bzrdir,
 
26
    repository,
 
27
    )
25
28
from bzrlib.osutils import format_date
26
29
from bzrlib.tests import TestSkipped
27
30
from bzrlib.tests.blackbox import ExternalBase
42
45
        transport = self.get_transport()
43
46
 
44
47
        # Create initial standalone branch
45
 
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
46
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
47
 
        tree1 = self.make_branch_and_tree('standalone')
48
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
 
48
        tree1 = self.make_branch_and_tree('standalone', 'weave')
49
49
        self.build_tree(['standalone/a'])
50
50
        tree1.add('a')
51
51
        branch1 = tree1.branch
134
134
        # Branch and bind to standalone, needs upgrade to metadir
135
135
        # (creates backup as unknown)
136
136
        branch1.bzrdir.sprout('bound')
137
 
        knit1_format = bzrlib.bzrdir.BzrDirMetaFormat1()
138
 
        knit1_format.repository_format = repository.RepositoryFormatKnit1()
 
137
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
139
138
        bzrlib.upgrade.upgrade('bound', knit1_format)
140
139
        branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
141
140
        branch3.bind(branch1)
188
187
        self.assertEqual('', err)
189
188
 
190
189
        # Checkout standalone (same as above, but does not have parent set)
191
 
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
192
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(knit1_format)
193
 
        branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout')
194
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
 
190
        branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
 
191
            format=knit1_format)
195
192
        branch4.bind(branch1)
196
193
        branch4.bzrdir.open_workingtree().update()
197
194
        out, err = self.runbzr('info checkout --verbose')
238
235
        self.assertEqual('', err)
239
236
 
240
237
        # Lightweight checkout (same as above, different branch and repository)
241
 
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
242
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
243
 
        transport.mkdir('lightcheckout')
244
 
        dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
245
 
        bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
246
 
        dir5.create_workingtree()
247
 
        tree5 = dir5.open_workingtree()
248
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
 
238
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
249
239
        branch5 = tree5.branch
250
240
        out, err = self.runbzr('info lightcheckout')
251
241
        self.assertEqualDiff(
470
460
 
471
461
    def test_info_standalone_no_tree(self):
472
462
        # create standalone branch without a working tree
 
463
        format = bzrdir.format_registry.make_bzrdir('default')
473
464
        branch = self.make_branch('branch')
474
465
        repo = branch.repository
475
466
        out, err = self.runbzr('info branch')
489
480
         0 revisions
490
481
         0 KiB
491
482
""" % (branch.bzrdir.root_transport.base,
492
 
       repo._format.get_format_description(),
 
483
       format.repository_format.get_format_description(),
493
484
       ), out)
494
485
        self.assertEqual('', err)
495
486
 
496
487
    def test_info_shared_repository(self):
497
 
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
498
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
 
488
        format = bzrdir.format_registry.make_bzrdir('metaweave')
499
489
        transport = self.get_transport()
500
490
 
501
491
        # Create shared repository
502
 
        repo = self.make_repository('repo', shared=True)
 
492
        repo = self.make_repository('repo', shared=True, format=format)
503
493
        repo.set_make_working_trees(False)
504
494
        out, err = self.runbzr('info repo')
505
495
        self.assertEqualDiff(
514
504
         0 revisions
515
505
         0 KiB
516
506
""" % (repo.bzrdir.root_transport.base,
517
 
       repo._format.get_format_description(),
 
507
       format.repository_format.get_format_description(),
518
508
       ), out)
519
509
        self.assertEqual('', err)
520
510
 
521
511
        # Create branch inside shared repository
522
512
        repo.bzrdir.root_transport.mkdir('branch')
523
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
 
513
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
 
514
            format=format)
524
515
        out, err = self.runbzr('info repo/branch')
525
516
        self.assertEqualDiff(
526
517
"""Location:
539
530
         0 revisions
540
531
         0 KiB
541
532
""" % (repo.bzrdir.root_transport.base,
542
 
       repo._format.get_format_description(),
 
533
       format.repository_format.get_format_description(),
543
534
       ), out)
544
535
        self.assertEqual('', err)
545
536
 
546
537
        # Create lightweight checkout
547
538
        transport.mkdir('tree')
548
539
        transport.mkdir('tree/lightcheckout')
549
 
        dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
550
 
        bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
551
 
        dir2.create_workingtree()
552
 
        tree2 = dir2.open_workingtree()
 
540
        tree2 = branch1.create_checkout('tree/lightcheckout', 
 
541
            lightweight=True)
553
542
        branch2 = tree2.branch
554
 
        self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
 
543
        self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, 
 
544
                   shared_repo=repo)
555
545
 
556
546
        # Create normal checkout
557
547
        tree3 = branch1.create_checkout('tree/checkout')
599
589
         %d KiB
600
590
""" % (tree2.bzrdir.root_transport.base,
601
591
       repo.bzrdir.root_transport.base,
602
 
       repo._format.get_format_description(),
 
592
       format.repository_format.get_format_description(),
603
593
       datestring_first, datestring_first,
604
594
       # poking at _revision_store isn't all that clean, but neither is
605
595
       # having the ui test dependent on the exact overhead of a given store.
640
630
         0 KiB
641
631
""" % (tree3.bzrdir.root_transport.base,
642
632
       branch1.bzrdir.root_transport.base,
643
 
       repo._format.get_format_description(),
 
633
       format.repository_format.get_format_description(),
644
634
       ), out)
645
635
        self.assertEqual('', err)
646
636
 
681
671
         1 revision
682
672
         %d KiB
683
673
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
684
 
       repo._format.get_format_description(),
 
674
       format.repository_format.get_format_description(),
685
675
       datestring_first, datestring_first,
686
676
       # poking at _revision_store isn't all that clean, but neither is
687
677
       # having the ui test dependent on the exact overhead of a given store.
730
720
         %d KiB
731
721
""" % (tree2.bzrdir.root_transport.base,
732
722
       repo.bzrdir.root_transport.base,
733
 
       repo._format.get_format_description(),
 
723
       format.repository_format.get_format_description(),
734
724
       datestring_first, datestring_last,
735
725
       # poking at _revision_store isn't all that clean, but neither is
736
726
       # having the ui test dependent on the exact overhead of a given store.
761
751
         2 revisions
762
752
         %d KiB
763
753
""" % (repo.bzrdir.root_transport.base,
764
 
       repo._format.get_format_description(),
 
754
       format.repository_format.get_format_description(),
765
755
       datestring_first, datestring_last,
766
756
       # poking at _revision_store isn't all that clean, but neither is
767
757
       # having the ui test dependent on the exact overhead of a given store.
783
773
         2 revisions
784
774
         %d KiB
785
775
""" % (repo.bzrdir.root_transport.base,
786
 
       repo._format.get_format_description(),
 
776
       format.repository_format.get_format_description(),
787
777
       # poking at _revision_store isn't all that clean, but neither is
788
778
       # having the ui test dependent on the exact overhead of a given store.
789
779
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
790
780
       ), out)
791
781
        self.assertEqual('', err)
792
782
 
793
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
794
 
 
795
783
    def test_info_shared_repository_with_trees(self):
796
 
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
797
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
 
784
        format = bzrdir.format_registry.make_bzrdir('metaweave')
798
785
        transport = self.get_transport()
799
786
 
800
787
        # Create shared repository with working trees
801
 
        repo = self.make_repository('repo', shared=True)
 
788
        repo = self.make_repository('repo', shared=True, format=format)
802
789
        repo.set_make_working_trees(True)
803
790
        out, err = self.runbzr('info repo')
804
791
        self.assertEqualDiff(
815
802
         0 revisions
816
803
         0 KiB
817
804
""" % (repo.bzrdir.root_transport.base,
818
 
       repo._format.get_format_description(),
 
805
       format.repository_format.get_format_description(),
819
806
       ), out)
820
807
        self.assertEqual('', err)
821
808
 
822
809
        # Create two branches
823
810
        repo.bzrdir.root_transport.mkdir('branch1')
824
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
 
811
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
 
812
            format=format)
825
813
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
826
814
 
827
815
        # Empty first branch
855
843
         0 revisions
856
844
         0 KiB
857
845
""" % (repo.bzrdir.root_transport.base,
858
 
       repo._format.get_format_description(),
 
846
       format.repository_format.get_format_description(),
859
847
       ), out)
860
848
        self.assertEqual('', err)
861
849
 
898
886
         1 revision
899
887
         %d KiB
900
888
""" % (repo.bzrdir.root_transport.base,
901
 
       repo._format.get_format_description(),
 
889
       format.repository_format.get_format_description(),
902
890
       datestring_first, datestring_first,
903
891
       # poking at _revision_store isn't all that clean, but neither is
904
892
       # having the ui test dependent on the exact overhead of a given store.
941
929
         %d KiB
942
930
""" % (repo.bzrdir.root_transport.base,
943
931
       branch1.bzrdir.root_transport.base,
944
 
       repo._format.get_format_description(),
 
932
       format.repository_format.get_format_description(),
945
933
       # poking at _revision_store isn't all that clean, but neither is
946
934
       # having the ui test dependent on the exact overhead of a given store.
947
935
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
987
975
         %d KiB
988
976
""" % (repo.bzrdir.root_transport.base,
989
977
       branch1.bzrdir.root_transport.base,
990
 
       repo._format.get_format_description(),
 
978
       format.repository_format.get_format_description(),
991
979
       datestring_first, datestring_first,
992
980
       # poking at _revision_store isn't all that clean, but neither is
993
981
       # having the ui test dependent on the exact overhead of a given store.
1011
999
         1 revision
1012
1000
         %d KiB
1013
1001
""" % (repo.bzrdir.root_transport.base,
1014
 
       repo._format.get_format_description(),
 
1002
       format.repository_format.get_format_description(),
1015
1003
       # poking at _revision_store isn't all that clean, but neither is
1016
1004
       # having the ui test dependent on the exact overhead of a given store.
1017
1005
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1018
1006
       ),
1019
1007
       out)
1020
1008
        self.assertEqual('', err)
1021
 
 
1022
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1023
1009
    
1024
1010
    def test_info_shared_repository_with_tree_in_root(self):
1025
 
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1026
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
 
1011
        format = bzrdir.format_registry.make_bzrdir('metaweave')
1027
1012
        transport = self.get_transport()
1028
1013
 
1029
1014
        # Create shared repository with working trees
1030
 
        repo = self.make_repository('repo', shared=True)
 
1015
        repo = self.make_repository('repo', shared=True, format=format)
1031
1016
        repo.set_make_working_trees(True)
1032
1017
        out, err = self.runbzr('info repo')
1033
1018
        self.assertEqualDiff(
1044
1029
         0 revisions
1045
1030
         0 KiB
1046
1031
""" % (repo.bzrdir.root_transport.base,
1047
 
       repo._format.get_format_description(),
 
1032
       format.repository_format.get_format_description(),
1048
1033
       ), out)
1049
1034
        self.assertEqual('', err)
1050
1035
 
1081
1066
         0 revisions
1082
1067
         0 KiB
1083
1068
""" % (repo.bzrdir.root_transport.base,
1084
 
       repo._format.get_format_description(),
 
1069
       format.repository_format.get_format_description(),
1085
1070
       ), out)
1086
1071
        self.assertEqual('', err)
1087
1072
 
1088
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1089
 
 
1090
1073
    def assertCheckoutStatusOutput(self, 
1091
1074
        command_string, lco_tree, shared_repo=None,
1092
1075
        repo_branch=None,