/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/blackbox/test_info.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-08 23:30:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170608233031-3qavls2o7a1pqllj
Update imports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
from breezy import (
24
24
    branch,
 
25
    bzrdir,
25
26
    controldir,
26
27
    errors,
27
28
    info,
30
31
    upgrade,
31
32
    urlutils,
32
33
    )
33
 
from breezy.bzr import (
34
 
    bzrdir,
35
 
    )
 
34
from breezy.tests.matchers import ContainsNoVfsCalls
36
35
from breezy.transport import memory
37
36
 
38
37
 
45
44
    def test_info_non_existing(self):
46
45
        self.vfs_transport_factory = memory.MemoryServer
47
46
        location = self.get_url()
48
 
        out, err = self.run_bzr('info ' + location, retcode=3)
 
47
        out, err = self.run_bzr('info '+location, retcode=3)
49
48
        self.assertEqual(out, '')
50
49
        self.assertEqual(err, 'brz: ERROR: Not a branch: "%s".\n' % location)
51
50
 
52
51
    def test_info_empty_controldir(self):
53
 
        self.make_controldir('ctrl')
 
52
        self.make_bzrdir('ctrl')
54
53
        out, err = self.run_bzr('info ctrl')
55
54
        self.assertEqual(out,
56
 
                         'Empty control directory (format: 2a)\n'
57
 
                         'Location:\n'
58
 
                         '  control directory: ctrl\n')
 
55
            'Empty control directory (format: 2a or pack-0.92)\n'
 
56
            'Location:\n'
 
57
            '  control directory: ctrl\n')
59
58
        self.assertEqual(err, '')
60
59
 
61
60
    def test_info_empty_controldir_verbose(self):
62
 
        self.make_controldir('ctrl')
 
61
        self.make_bzrdir('ctrl')
63
62
        out, err = self.run_bzr('info -v ctrl')
64
63
        self.assertEqualDiff(out,
65
 
                             'Empty control directory (format: 2a)\n'
66
 
                             'Location:\n'
67
 
                             '  control directory: ctrl\n\n'
68
 
                             'Format:\n'
69
 
                             '       control: Meta directory format 1\n\n'
70
 
                             'Control directory:\n'
71
 
                             '         0 branches\n')
 
64
            'Empty control directory (format: 2a or pack-0.92)\n'
 
65
            'Location:\n'
 
66
            '  control directory: ctrl\n\n'
 
67
            'Format:\n'
 
68
            '       control: Meta directory format 1\n\n'
 
69
            'Control directory:\n'
 
70
            '         0 branches\n')
72
71
        self.assertEqual(err, '')
73
72
 
74
73
    def test_info_dangling_branch_reference(self):
77
76
        shutil.rmtree('target')
78
77
        out, err = self.run_bzr('info from')
79
78
        self.assertEqual(out,
80
 
                         'Dangling branch reference (format: 2a)\n'
81
 
                         'Location:\n'
82
 
                         '   control directory: from\n'
83
 
                         '  checkout of branch: target\n')
84
 
        self.assertEqual(err, '')
85
 
 
86
 
    def test_info_colocated(self):
87
 
        br = self.make_branch_and_tree('target', format='development-colo')
88
 
        target = br.controldir.create_branch(name='dichtbij')
89
 
        br.controldir.set_branch_reference(target)
90
 
        out, err = self.run_bzr('info target')
91
 
        self.assertEqual(out,
92
 
                         'Standalone tree (format: development-colo)\n'
93
 
                         'Location:\n'
94
 
                         '            light checkout root: target\n'
95
 
                         '  checkout of co-located branch: dichtbij\n')
 
79
            'Dangling branch reference (format: 2a or pack-0.92)\n'
 
80
            'Location:\n'
 
81
            '   control directory: from\n'
 
82
            '  checkout of branch: target\n')
96
83
        self.assertEqual(err, '')
97
84
 
98
85
    def test_info_standalone(self):
106
93
 
107
94
        out, err = self.run_bzr('info standalone')
108
95
        self.assertEqualDiff(
109
 
            """Standalone tree (format: knit)
 
96
"""Standalone tree (format: knit)
110
97
Location:
111
98
  branch root: standalone
112
99
""", out)
115
102
        # Standalone branch - verbose mode
116
103
        out, err = self.run_bzr('info standalone -v')
117
104
        self.assertEqualDiff(
118
 
            """Standalone tree (format: knit)
 
105
"""Standalone tree (format: knit)
119
106
Location:
120
107
  branch root: standalone
121
108
 
134
121
         1 added
135
122
         0 removed
136
123
         0 renamed
137
 
         0 copied
138
124
         0 unknown
139
125
         0 ignored
140
126
         0 versioned subdirectories
150
136
        # Standalone branch - really verbose mode
151
137
        out, err = self.run_bzr('info standalone -vv')
152
138
        self.assertEqualDiff(
153
 
            """Standalone tree (format: knit)
 
139
"""Standalone tree (format: knit)
154
140
Location:
155
141
  branch root: standalone
156
142
 
169
155
         1 added
170
156
         0 removed
171
157
         0 renamed
172
 
         0 copied
173
158
         0 unknown
174
159
         0 ignored
175
160
         0 versioned subdirectories
187
172
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
188
173
 
189
174
        # Branch standalone with push location
190
 
        branch2 = branch1.controldir.sprout('branch').open_branch()
191
 
        branch2.set_push_location(branch1.controldir.root_transport.base)
 
175
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
 
176
        branch2.set_push_location(branch1.bzrdir.root_transport.base)
192
177
 
193
178
        out, err = self.run_bzr('info branch')
194
179
        self.assertEqualDiff(
195
 
            """Standalone tree (format: knit)
 
180
"""Standalone tree (format: knit)
196
181
Location:
197
182
  branch root: branch
198
183
 
204
189
 
205
190
        out, err = self.run_bzr('info branch --verbose')
206
191
        self.assertEqualDiff(
207
 
            """Standalone tree (format: knit)
 
192
"""Standalone tree (format: knit)
208
193
Location:
209
194
  branch root: branch
210
195
 
227
212
         0 added
228
213
         0 removed
229
214
         0 renamed
230
 
         0 copied
231
215
         0 unknown
232
216
         0 ignored
233
217
         0 versioned subdirectories
246
230
 
247
231
        # Branch and bind to standalone, needs upgrade to metadir
248
232
        # (creates backup as unknown)
249
 
        branch1.controldir.sprout('bound')
250
 
        knit1_format = controldir.format_registry.make_controldir('knit')
 
233
        branch1.bzrdir.sprout('bound')
 
234
        knit1_format = controldir.format_registry.make_bzrdir('knit')
251
235
        upgrade.upgrade('bound', knit1_format)
252
236
        branch3 = controldir.ControlDir.open('bound').open_branch()
253
237
        branch3.bind(branch1)
254
 
        bound_tree = branch3.controldir.open_workingtree()
 
238
        bound_tree = branch3.bzrdir.open_workingtree()
255
239
        out, err = self.run_bzr('info -v bound')
256
240
        self.assertEqualDiff(
257
 
            """Checkout (format: knit)
 
241
"""Checkout (format: knit)
258
242
Location:
259
243
       checkout root: bound
260
244
  checkout of branch: standalone
277
261
         0 added
278
262
         0 removed
279
263
         0 renamed
280
 
         0 copied
281
264
         0 unknown
282
265
         0 ignored
283
266
         0 versioned subdirectories
291
274
Repository:
292
275
         1 revision
293
276
""" % (bound_tree._format.get_format_description(),
294
 
                branch3._format.get_format_description(),
295
 
                branch3.repository._format.get_format_description(),
296
 
                datestring_first, datestring_first,
 
277
       branch3._format.get_format_description(),
 
278
       branch3.repository._format.get_format_description(),
 
279
       datestring_first, datestring_first,
297
280
       ), out)
298
281
        self.assertEqual('', err)
299
282
 
300
283
        # Checkout standalone (same as above, but does not have parent set)
301
284
        branch4 = controldir.ControlDir.create_branch_convenience('checkout',
302
 
                                                                  format=knit1_format)
 
285
            format=knit1_format)
303
286
        branch4.bind(branch1)
304
 
        branch4.controldir.open_workingtree().update()
 
287
        branch4.bzrdir.open_workingtree().update()
305
288
        out, err = self.run_bzr('info checkout --verbose')
306
289
        self.assertEqualDiff(
307
 
            """Checkout (format: knit)
 
290
"""Checkout (format: knit)
308
291
Location:
309
292
       checkout root: checkout
310
293
  checkout of branch: standalone
324
307
         0 added
325
308
         0 removed
326
309
         0 renamed
327
 
         0 copied
328
310
         0 unknown
329
311
         0 ignored
330
312
         0 versioned subdirectories
338
320
Repository:
339
321
         1 revision
340
322
""" % (branch4.repository._format.get_format_description(),
341
 
                datestring_first, datestring_first,
 
323
       datestring_first, datestring_first,
342
324
       ), out)
343
325
        self.assertEqual('', err)
344
326
 
351
333
        else:
352
334
            format_description = "knit"
353
335
        self.assertEqualDiff(
354
 
            """Lightweight checkout (format: %s)
 
336
"""Lightweight checkout (format: %s)
355
337
Location:
356
338
  light checkout root: lightcheckout
357
339
   checkout of branch: standalone
371
353
         0 added
372
354
         0 removed
373
355
         0 renamed
374
 
         0 copied
375
356
         0 unknown
376
357
         0 ignored
377
358
         0 versioned subdirectories
397
378
        # Out of date branched standalone branch will not be detected
398
379
        out, err = self.run_bzr('info -v branch')
399
380
        self.assertEqualDiff(
400
 
            """Standalone tree (format: knit)
 
381
"""Standalone tree (format: knit)
401
382
Location:
402
383
  branch root: branch
403
384
 
420
401
         0 added
421
402
         0 removed
422
403
         0 renamed
423
 
         0 copied
424
404
         0 unknown
425
405
         0 ignored
426
406
         0 versioned subdirectories
440
420
        # Out of date bound branch
441
421
        out, err = self.run_bzr('info -v bound')
442
422
        self.assertEqualDiff(
443
 
            """Checkout (format: knit)
 
423
"""Checkout (format: knit)
444
424
Location:
445
425
       checkout root: bound
446
426
  checkout of branch: standalone
465
445
         0 added
466
446
         0 removed
467
447
         0 renamed
468
 
         0 copied
469
448
         0 unknown
470
449
         0 ignored
471
450
         0 versioned subdirectories
479
458
Repository:
480
459
         1 revision
481
460
""" % (branch3.repository._format.get_format_description(),
482
 
                datestring_first, datestring_first,
 
461
       datestring_first, datestring_first,
483
462
       ), out)
484
463
        self.assertEqual('', err)
485
464
 
486
465
        # Out of date checkout
487
466
        out, err = self.run_bzr('info -v checkout')
488
467
        self.assertEqualDiff(
489
 
            """Checkout (format: knit)
 
468
"""Checkout (format: knit)
490
469
Location:
491
470
       checkout root: checkout
492
471
  checkout of branch: standalone
508
487
         0 added
509
488
         0 removed
510
489
         0 renamed
511
 
         0 copied
512
490
         0 unknown
513
491
         0 ignored
514
492
         0 versioned subdirectories
522
500
Repository:
523
501
         1 revision
524
502
""" % (branch4.repository._format.get_format_description(),
525
 
                datestring_first, datestring_first,
 
503
       datestring_first, datestring_first,
526
504
       ), out)
527
505
        self.assertEqual('', err)
528
506
 
529
507
        # Out of date lightweight checkout
530
508
        out, err = self.run_bzr('info lightcheckout --verbose')
531
509
        self.assertEqualDiff(
532
 
            """Lightweight checkout (format: %s)
 
510
"""Lightweight checkout (format: %s)
533
511
Location:
534
512
  light checkout root: lightcheckout
535
513
   checkout of branch: standalone
551
529
         0 added
552
530
         0 removed
553
531
         0 renamed
554
 
         0 copied
555
532
         0 unknown
556
533
         0 ignored
557
534
         0 versioned subdirectories
569
546
 
570
547
    def test_info_standalone_no_tree(self):
571
548
        # create standalone branch without a working tree
572
 
        format = controldir.format_registry.make_controldir('default')
 
549
        format = controldir.format_registry.make_bzrdir('default')
573
550
        branch = self.make_branch('branch')
574
551
        repo = branch.repository
575
552
        out, err = self.run_bzr('info branch -v')
576
553
        self.assertEqualDiff(
577
 
            """Standalone branch (format: %s)
 
554
"""Standalone branch (format: %s)
578
555
Location:
579
556
  branch root: branch
580
557
 
591
568
 
592
569
Repository:
593
570
         0 revisions
594
 
""" % (info.describe_format(repo.controldir, repo, branch, None),
595
 
                format.get_branch_format().get_format_description(),
596
 
                format.repository_format.get_format_description(),
 
571
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
 
572
       format.get_branch_format().get_format_description(),
 
573
       format.repository_format.get_format_description(),
597
574
       ), out)
598
575
        self.assertEqual('', err)
599
576
 
600
577
    def test_info_shared_repository(self):
601
 
        format = controldir.format_registry.make_controldir('knit')
 
578
        format = controldir.format_registry.make_bzrdir('knit')
602
579
        transport = self.get_transport()
603
580
 
604
581
        # Create shared repository
606
583
        repo.set_make_working_trees(False)
607
584
        out, err = self.run_bzr('info -v repo')
608
585
        self.assertEqualDiff(
609
 
            """Shared repository (format: dirstate or dirstate-tags or knit)
 
586
"""Shared repository (format: dirstate or dirstate-tags or knit)
610
587
Location:
611
588
  shared repository: %s
612
589
 
624
601
        self.assertEqual('', err)
625
602
 
626
603
        # Create branch inside shared repository
627
 
        repo.controldir.root_transport.mkdir('branch')
 
604
        repo.bzrdir.root_transport.mkdir('branch')
628
605
        branch1 = controldir.ControlDir.create_branch_convenience(
629
606
            'repo/branch', format=format)
630
607
        out, err = self.run_bzr('info -v repo/branch')
631
608
        self.assertEqualDiff(
632
 
            """Repository branch (format: dirstate or knit)
 
609
"""Repository branch (format: dirstate or knit)
633
610
Location:
634
611
  shared repository: repo
635
612
  repository branch: repo/branch
648
625
Repository:
649
626
         0 revisions
650
627
""" % (format.get_branch_format().get_format_description(),
651
 
                format.repository_format.get_format_description(),
 
628
       format.repository_format.get_format_description(),
652
629
       ), out)
653
630
        self.assertEqual('', err)
654
631
 
656
633
        transport.mkdir('tree')
657
634
        transport.mkdir('tree/lightcheckout')
658
635
        tree2 = branch1.create_checkout('tree/lightcheckout',
659
 
                                        lightweight=True)
 
636
            lightweight=True)
660
637
        branch2 = tree2.branch
661
638
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
662
 
                                        shared_repo=repo, repo_branch=branch1, verbose=True)
 
639
                   shared_repo=repo, repo_branch=branch1, verbose=True)
663
640
 
664
641
        # Create normal checkout
665
642
        tree3 = branch1.create_checkout('tree/checkout')
666
643
        self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
667
 
                                        verbose=True,
668
 
                                        light_checkout=False, repo_branch=branch1)
 
644
            verbose=True,
 
645
            light_checkout=False, repo_branch=branch1)
669
646
        # Update lightweight checkout
670
647
        self.build_tree(['tree/lightcheckout/a'])
671
648
        tree2.add('a')
674
651
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
675
652
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
676
653
        self.assertEqualDiff(
677
 
            """Lightweight checkout (format: %s)
 
654
"""Lightweight checkout (format: %s)
678
655
Location:
679
656
  light checkout root: tree/lightcheckout
680
657
   checkout of branch: repo/branch
695
672
         0 added
696
673
         0 removed
697
674
         0 renamed
698
 
         0 copied
699
675
         0 unknown
700
676
         0 ignored
701
677
         0 versioned subdirectories
709
685
Repository:
710
686
         1 revision
711
687
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
712
 
                format.repository_format.get_format_description(),
713
 
                datestring_first, datestring_first,
 
688
       format.repository_format.get_format_description(),
 
689
       datestring_first, datestring_first,
714
690
       ), out)
715
691
        self.assertEqual('', err)
716
692
 
717
693
        # Out of date checkout
718
694
        out, err = self.run_bzr('info -v tree/checkout')
719
695
        self.assertEqualDiff(
720
 
            """Checkout (format: unnamed)
 
696
"""Checkout (format: unnamed)
721
697
Location:
722
698
       checkout root: tree/checkout
723
699
  checkout of branch: repo/branch
739
715
         0 added
740
716
         0 removed
741
717
         0 renamed
742
 
         0 copied
743
718
         0 unknown
744
719
         0 ignored
745
720
         0 versioned subdirectories
750
725
Repository:
751
726
         0 revisions
752
727
""" % (format.get_branch_format().get_format_description(),
753
 
                format.repository_format.get_format_description(),
 
728
       format.repository_format.get_format_description(),
754
729
       ), out)
755
730
        self.assertEqual('', err)
756
731
 
760
735
        tree3.add('b')
761
736
        out, err = self.run_bzr('info tree/checkout --verbose')
762
737
        self.assertEqualDiff(
763
 
            """Checkout (format: unnamed)
 
738
"""Checkout (format: unnamed)
764
739
Location:
765
740
       checkout root: tree/checkout
766
741
  checkout of branch: repo/branch
780
755
         1 added
781
756
         0 removed
782
757
         0 renamed
783
 
         0 copied
784
758
         0 unknown
785
759
         0 ignored
786
760
         0 versioned subdirectories
794
768
Repository:
795
769
         1 revision
796
770
""" % (format.get_branch_format().get_format_description(),
797
 
                format.repository_format.get_format_description(),
798
 
                datestring_first, datestring_first,
 
771
       format.repository_format.get_format_description(),
 
772
       datestring_first, datestring_first,
799
773
       ), out)
800
774
        self.assertEqual('', err)
801
775
        tree3.commit('commit two')
805
779
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
806
780
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
807
781
        self.assertEqualDiff(
808
 
            """Lightweight checkout (format: %s)
 
782
"""Lightweight checkout (format: %s)
809
783
Location:
810
784
  light checkout root: tree/lightcheckout
811
785
   checkout of branch: repo/branch
828
802
         0 added
829
803
         0 removed
830
804
         0 renamed
831
 
         0 copied
832
805
         0 unknown
833
806
         0 ignored
834
807
         0 versioned subdirectories
842
815
Repository:
843
816
         2 revisions
844
817
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
845
 
                format.repository_format.get_format_description(),
846
 
                datestring_first, datestring_last,
 
818
       format.repository_format.get_format_description(),
 
819
       datestring_first, datestring_last,
847
820
       ), out)
848
821
        self.assertEqual('', err)
849
822
 
850
823
        # Show info about shared branch
851
824
        out, err = self.run_bzr('info repo/branch --verbose')
852
825
        self.assertEqualDiff(
853
 
            """Repository branch (format: dirstate or knit)
 
826
"""Repository branch (format: dirstate or knit)
854
827
Location:
855
828
  shared repository: repo
856
829
  repository branch: repo/branch
872
845
Repository:
873
846
         2 revisions
874
847
""" % (format.get_branch_format().get_format_description(),
875
 
                format.repository_format.get_format_description(),
876
 
                datestring_first, datestring_last,
 
848
       format.repository_format.get_format_description(),
 
849
       datestring_first, datestring_last,
877
850
       ), out)
878
851
        self.assertEqual('', err)
879
852
 
880
853
        # Show info about repository with revisions
881
854
        out, err = self.run_bzr('info -v repo')
882
855
        self.assertEqualDiff(
883
 
            """Shared repository (format: dirstate or dirstate-tags or knit)
 
856
"""Shared repository (format: dirstate or dirstate-tags or knit)
884
857
Location:
885
858
  shared repository: repo
886
859
 
898
871
        self.assertEqual('', err)
899
872
 
900
873
    def test_info_shared_repository_with_trees(self):
901
 
        format = controldir.format_registry.make_controldir('knit')
 
874
        format = controldir.format_registry.make_bzrdir('knit')
902
875
        transport = self.get_transport()
903
876
 
904
877
        # Create shared repository with working trees
906
879
        repo.set_make_working_trees(True)
907
880
        out, err = self.run_bzr('info -v repo')
908
881
        self.assertEqualDiff(
909
 
            """Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
882
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
910
883
Location:
911
884
  shared repository: repo
912
885
 
926
899
        self.assertEqual('', err)
927
900
 
928
901
        # Create two branches
929
 
        repo.controldir.root_transport.mkdir('branch1')
 
902
        repo.bzrdir.root_transport.mkdir('branch1')
930
903
        branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
931
 
                                                                  format=format)
932
 
        branch2 = branch1.controldir.sprout('repo/branch2').open_branch()
 
904
            format=format)
 
905
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
933
906
 
934
907
        # Empty first branch
935
908
        out, err = self.run_bzr('info repo/branch1 --verbose')
936
909
        self.assertEqualDiff(
937
 
            """Repository tree (format: knit)
 
910
"""Repository tree (format: knit)
938
911
Location:
939
912
  shared repository: repo
940
913
  repository branch: repo/branch1
954
927
         0 added
955
928
         0 removed
956
929
         0 renamed
957
 
         0 copied
958
930
         0 unknown
959
931
         0 ignored
960
932
         0 versioned subdirectories
965
937
Repository:
966
938
         0 revisions
967
939
""" % (format.get_branch_format().get_format_description(),
968
 
                format.repository_format.get_format_description(),
 
940
       format.repository_format.get_format_description(),
969
941
       ), out)
970
942
        self.assertEqual('', err)
971
943
 
972
944
        # Update first branch
973
945
        self.build_tree(['repo/branch1/a'])
974
 
        tree1 = branch1.controldir.open_workingtree()
 
946
        tree1 = branch1.bzrdir.open_workingtree()
975
947
        tree1.add('a')
976
948
        tree1.commit('commit one')
977
949
        rev = repo.get_revision(branch1.last_revision())
978
950
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
979
951
        out, err = self.run_bzr('info -v repo/branch1')
980
952
        self.assertEqualDiff(
981
 
            """Repository tree (format: knit)
 
953
"""Repository tree (format: knit)
982
954
Location:
983
955
  shared repository: repo
984
956
  repository branch: repo/branch1
998
970
         0 added
999
971
         0 removed
1000
972
         0 renamed
1001
 
         0 copied
1002
973
         0 unknown
1003
974
         0 ignored
1004
975
         0 versioned subdirectories
1012
983
Repository:
1013
984
         1 revision
1014
985
""" % (format.get_branch_format().get_format_description(),
1015
 
                format.repository_format.get_format_description(),
1016
 
                datestring_first, datestring_first,
 
986
       format.repository_format.get_format_description(),
 
987
       datestring_first, datestring_first,
1017
988
       ), out)
1018
989
        self.assertEqual('', err)
1019
990
 
1020
991
        # Out of date second branch
1021
992
        out, err = self.run_bzr('info repo/branch2 --verbose')
1022
993
        self.assertEqualDiff(
1023
 
            """Repository tree (format: knit)
 
994
"""Repository tree (format: knit)
1024
995
Location:
1025
996
  shared repository: repo
1026
997
  repository branch: repo/branch2
1043
1014
         0 added
1044
1015
         0 removed
1045
1016
         0 renamed
1046
 
         0 copied
1047
1017
         0 unknown
1048
1018
         0 ignored
1049
1019
         0 versioned subdirectories
1054
1024
Repository:
1055
1025
         1 revision
1056
1026
""" % (format.get_branch_format().get_format_description(),
1057
 
                format.repository_format.get_format_description(),
 
1027
       format.repository_format.get_format_description(),
1058
1028
       ), out)
1059
1029
        self.assertEqual('', err)
1060
1030
 
1061
1031
        # Update second branch
1062
 
        tree2 = branch2.controldir.open_workingtree()
 
1032
        tree2 = branch2.bzrdir.open_workingtree()
1063
1033
        tree2.pull(branch1)
1064
1034
        out, err = self.run_bzr('info -v repo/branch2')
1065
1035
        self.assertEqualDiff(
1066
 
            """Repository tree (format: knit)
 
1036
"""Repository tree (format: knit)
1067
1037
Location:
1068
1038
  shared repository: repo
1069
1039
  repository branch: repo/branch2
1086
1056
         0 added
1087
1057
         0 removed
1088
1058
         0 renamed
1089
 
         0 copied
1090
1059
         0 unknown
1091
1060
         0 ignored
1092
1061
         0 versioned subdirectories
1100
1069
Repository:
1101
1070
         1 revision
1102
1071
""" % (format.get_branch_format().get_format_description(),
1103
 
                format.repository_format.get_format_description(),
1104
 
                datestring_first, datestring_first,
 
1072
       format.repository_format.get_format_description(),
 
1073
       datestring_first, datestring_first,
1105
1074
       ), out)
1106
1075
        self.assertEqual('', err)
1107
1076
 
1108
1077
        # Show info about repository with revisions
1109
1078
        out, err = self.run_bzr('info -v repo')
1110
1079
        self.assertEqualDiff(
1111
 
            """Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
1080
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1112
1081
Location:
1113
1082
  shared repository: repo
1114
1083
 
1125
1094
         1 revision
1126
1095
""" % (format.repository_format.get_format_description(),
1127
1096
       ),
1128
 
            out)
 
1097
       out)
1129
1098
        self.assertEqual('', err)
1130
1099
 
1131
1100
    def test_info_shared_repository_with_tree_in_root(self):
1132
 
        format = controldir.format_registry.make_controldir('knit')
 
1101
        format = controldir.format_registry.make_bzrdir('knit')
1133
1102
        transport = self.get_transport()
1134
1103
 
1135
1104
        # Create shared repository with working trees
1137
1106
        repo.set_make_working_trees(True)
1138
1107
        out, err = self.run_bzr('info -v repo')
1139
1108
        self.assertEqualDiff(
1140
 
            """Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
1109
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1141
1110
Location:
1142
1111
  shared repository: repo
1143
1112
 
1157
1126
        self.assertEqual('', err)
1158
1127
 
1159
1128
        # Create branch in root of repository
1160
 
        control = repo.controldir
 
1129
        control = repo.bzrdir
1161
1130
        branch = control.create_branch()
1162
1131
        control.create_workingtree()
1163
1132
        out, err = self.run_bzr('info -v repo')
1164
1133
        self.assertEqualDiff(
1165
 
            """Repository tree (format: knit)
 
1134
"""Repository tree (format: knit)
1166
1135
Location:
1167
1136
  shared repository: repo
1168
1137
  repository branch: repo
1182
1151
         0 added
1183
1152
         0 removed
1184
1153
         0 renamed
1185
 
         0 copied
1186
1154
         0 unknown
1187
1155
         0 ignored
1188
1156
         0 versioned subdirectories
1193
1161
Repository:
1194
1162
         0 revisions
1195
1163
""" % (format.get_branch_format().get_format_description(),
1196
 
                format.repository_format.get_format_description(),
 
1164
       format.repository_format.get_format_description(),
1197
1165
       ), out)
1198
1166
        self.assertEqual('', err)
1199
1167
 
1200
1168
    def test_info_repository_hook(self):
1201
 
        format = controldir.format_registry.make_controldir('knit')
1202
 
 
 
1169
        format = controldir.format_registry.make_bzrdir('knit')
1203
1170
        def repo_info(repo, stats, outf):
1204
 
            outf.write(u"more info\n")
 
1171
            outf.write("more info\n")
1205
1172
        info.hooks.install_named_hook('repository', repo_info, None)
1206
1173
        # Create shared repository with working trees
1207
1174
        repo = self.make_repository('repo', shared=True, format=format)
1208
1175
        out, err = self.run_bzr('info -v repo')
1209
1176
        self.assertEqualDiff(
1210
 
            """Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
1177
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1211
1178
Location:
1212
1179
  shared repository: repo
1213
1180
 
1228
1195
        self.assertEqual('', err)
1229
1196
 
1230
1197
    def test_info_unshared_repository_with_colocated_branches(self):
1231
 
        format = controldir.format_registry.make_controldir('development-colo')
 
1198
        format = controldir.format_registry.make_bzrdir('development-colo')
1232
1199
        transport = self.get_transport()
1233
1200
 
1234
1201
        # Create unshared repository
1235
1202
        repo = self.make_repository('repo', shared=False, format=format)
1236
1203
        repo.set_make_working_trees(True)
1237
 
        repo.controldir.create_branch(name='foo')
 
1204
        repo.bzrdir.create_branch(name='foo')
1238
1205
        out, err = self.run_bzr('info repo')
1239
1206
        self.assertEqualDiff(
1240
 
            """Unshared repository with trees and colocated branches (format: development-colo)
 
1207
"""Unshared repository with trees and colocated branches (format: development-colo)
1241
1208
Location:
1242
1209
  repository: repo
1243
1210
""", out)
1244
1211
        self.assertEqual('', err)
1245
1212
 
1246
1213
    def assertCheckoutStatusOutput(self,
1247
 
                                   command_string, lco_tree, shared_repo=None,
1248
 
                                   repo_branch=None,
1249
 
                                   tree_locked=False,
1250
 
                                   branch_locked=False, repo_locked=False,
1251
 
                                   verbose=False,
1252
 
                                   light_checkout=True,
1253
 
                                   checkout_root=None):
 
1214
        command_string, lco_tree, shared_repo=None,
 
1215
        repo_branch=None,
 
1216
        tree_locked=False,
 
1217
        branch_locked=False, repo_locked=False,
 
1218
        verbose=False,
 
1219
        light_checkout=True,
 
1220
        checkout_root=None):
1254
1221
        """Check the output of info in a checkout.
1255
1222
 
1256
1223
        This is not quite a mirror of the info code: rather than using the
1287
1254
            # in the different process -- either on win32 or on linux).
1288
1255
            # This should be removed when the locking errors are fixed.
1289
1256
            self.expectFailure('OS locks are exclusive '
1290
 
                               'for different processes (Bug #174055)',
1291
 
                               self.run_bzr_subprocess,
1292
 
                               'info ' + command_string)
 
1257
                'for different processes (Bug #174055)',
 
1258
                self.run_bzr_subprocess,
 
1259
                'info ' + command_string)
1293
1260
        out, err = self.run_bzr('info %s' % command_string)
1294
1261
        description = {
1295
1262
            (True, True): 'Lightweight checkout',
1322
1289
        extra_space = ''
1323
1290
        if light_checkout:
1324
1291
            tree_data = ("  light checkout root: %s\n" %
1325
 
                         friendly_location(lco_tree.controldir.root_transport.base))
 
1292
                friendly_location(lco_tree.bzrdir.root_transport.base))
1326
1293
            extra_space = ' '
1327
1294
        if lco_tree.branch.get_bound_location() is not None:
1328
1295
            tree_data += ("%s       checkout root: %s\n" % (extra_space,
1329
 
                                                            friendly_location(lco_tree.branch.controldir.root_transport.base)))
 
1296
                friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1330
1297
        if shared_repo is not None:
1331
1298
            branch_data = (
1332
1299
                "   checkout of branch: %s\n"
1333
1300
                "    shared repository: %s\n" %
1334
 
                (friendly_location(repo_branch.controldir.root_transport.base),
1335
 
                 friendly_location(shared_repo.controldir.root_transport.base)))
 
1301
                (friendly_location(repo_branch.bzrdir.root_transport.base),
 
1302
                 friendly_location(shared_repo.bzrdir.root_transport.base)))
1336
1303
        elif repo_branch is not None:
1337
1304
            branch_data = (
1338
1305
                "%s  checkout of branch: %s\n" %
1339
1306
                (extra_space,
1340
 
                 friendly_location(repo_branch.controldir.root_transport.base)))
 
1307
                 friendly_location(repo_branch.bzrdir.root_transport.base)))
1341
1308
        else:
1342
1309
            branch_data = ("   checkout of branch: %s\n" %
1343
 
                           lco_tree.branch.controldir.root_transport.base)
 
1310
                lco_tree.branch.bzrdir.root_transport.base)
1344
1311
 
1345
1312
        if verbose >= 2:
1346
1313
            verbose_info = '         0 committers\n'
1348
1315
            verbose_info = ''
1349
1316
 
1350
1317
        self.assertEqualDiff(
1351
 
            """%s (format: %s)
 
1318
"""%s (format: %s)
1352
1319
Location:
1353
1320
%s%s
1354
1321
Format:
1366
1333
         0 added
1367
1334
         0 removed
1368
1335
         0 renamed
1369
 
         0 copied
1370
1336
         0 unknown
1371
1337
         0 ignored
1372
1338
         0 versioned subdirectories
1376
1342
%s
1377
1343
Repository:
1378
1344
         0 revisions
1379
 
""" % (description,
1380
 
                format,
1381
 
                tree_data,
1382
 
                branch_data,
1383
 
                lco_tree._format.get_format_description(),
1384
 
                lco_tree.branch._format.get_format_description(),
1385
 
                lco_tree.branch.repository._format.get_format_description(),
1386
 
                expected_lock_output,
1387
 
                verbose_info,
1388
 
       ), out)
 
1345
""" %  (description,
 
1346
        format,
 
1347
        tree_data,
 
1348
        branch_data,
 
1349
        lco_tree._format.get_format_description(),
 
1350
        lco_tree.branch._format.get_format_description(),
 
1351
        lco_tree.branch.repository._format.get_format_description(),
 
1352
        expected_lock_output,
 
1353
        verbose_info,
 
1354
        ), out)
1389
1355
        self.assertEqual('', err)
1390
1356
 
1391
1357
    def test_info_locking(self):
1394
1360
        repo = self.make_repository('repo', shared=True,
1395
1361
                                    format=bzrdir.BzrDirMetaFormat1())
1396
1362
        repo.set_make_working_trees(False)
1397
 
        repo.controldir.root_transport.mkdir('branch')
 
1363
        repo.bzrdir.root_transport.mkdir('branch')
1398
1364
        repo_branch = controldir.ControlDir.create_branch_convenience(
1399
1365
            'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1400
1366
        # Do a heavy checkout
1418
1384
                                        repo_branch=repo_branch,
1419
1385
                                        verbose=True, light_checkout=True)
1420
1386
        # U U L
1421
 
        with lco_tree.branch.repository.lock_write():
 
1387
        lco_tree.branch.repository.lock_write()
 
1388
        try:
1422
1389
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1423
 
                                            lco_tree, repo_branch=repo_branch,
1424
 
                                            repo_locked=True, verbose=True, light_checkout=True)
 
1390
            lco_tree, repo_branch=repo_branch,
 
1391
            repo_locked=True, verbose=True, light_checkout=True)
 
1392
        finally:
 
1393
            lco_tree.branch.repository.unlock()
1425
1394
        # U L L
1426
 
        with lco_tree.branch.lock_write():
 
1395
        lco_tree.branch.lock_write()
 
1396
        try:
1427
1397
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1428
 
                                            lco_tree,
1429
 
                                            branch_locked=True,
1430
 
                                            repo_locked=True,
1431
 
                                            repo_branch=repo_branch,
1432
 
                                            verbose=True)
 
1398
            lco_tree,
 
1399
            branch_locked=True,
 
1400
            repo_locked=True,
 
1401
            repo_branch=repo_branch,
 
1402
            verbose=True)
 
1403
        finally:
 
1404
            lco_tree.branch.unlock()
1433
1405
        # L L L
1434
 
        with lco_tree.lock_write():
 
1406
        lco_tree.lock_write()
 
1407
        try:
1435
1408
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1436
 
                                            lco_tree, repo_branch=repo_branch,
1437
 
                                            tree_locked=True,
1438
 
                                            branch_locked=True,
1439
 
                                            repo_locked=True,
1440
 
                                            verbose=True)
 
1409
            lco_tree, repo_branch=repo_branch,
 
1410
            tree_locked=True,
 
1411
            branch_locked=True,
 
1412
            repo_locked=True,
 
1413
            verbose=True)
 
1414
        finally:
 
1415
            lco_tree.unlock()
1441
1416
        # L L U
1442
 
        with lco_tree.lock_write(), lco_tree.branch.repository.unlock():
 
1417
        lco_tree.lock_write()
 
1418
        lco_tree.branch.repository.unlock()
 
1419
        try:
1443
1420
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1444
 
                                            lco_tree, repo_branch=repo_branch,
1445
 
                                            tree_locked=True,
1446
 
                                            branch_locked=True,
1447
 
                                            verbose=True)
 
1421
            lco_tree, repo_branch=repo_branch,
 
1422
            tree_locked=True,
 
1423
            branch_locked=True,
 
1424
            verbose=True)
 
1425
        finally:
 
1426
            lco_tree.branch.repository.lock_write()
 
1427
            lco_tree.unlock()
1448
1428
        # L U U
1449
 
        with lco_tree.lock_write(), lco_tree.branch.unlock():
 
1429
        lco_tree.lock_write()
 
1430
        lco_tree.branch.unlock()
 
1431
        try:
1450
1432
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1451
 
                                            lco_tree, repo_branch=repo_branch,
1452
 
                                            tree_locked=True,
1453
 
                                            verbose=True)
 
1433
            lco_tree, repo_branch=repo_branch,
 
1434
            tree_locked=True,
 
1435
            verbose=True)
 
1436
        finally:
 
1437
            lco_tree.branch.lock_write()
 
1438
            lco_tree.unlock()
1454
1439
        # L U L
1455
 
        with lco_tree.lock_write(), lco_tree.branch.unlock(), \
1456
 
                lco_tree.branch.repository.lock_write():
 
1440
        lco_tree.lock_write()
 
1441
        lco_tree.branch.unlock()
 
1442
        lco_tree.branch.repository.lock_write()
 
1443
        try:
1457
1444
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1458
 
                                            lco_tree, repo_branch=repo_branch,
1459
 
                                            tree_locked=True,
1460
 
                                            repo_locked=True,
1461
 
                                            verbose=True)
 
1445
            lco_tree, repo_branch=repo_branch,
 
1446
            tree_locked=True,
 
1447
            repo_locked=True,
 
1448
            verbose=True)
 
1449
        finally:
 
1450
            lco_tree.branch.repository.unlock()
 
1451
            lco_tree.branch.lock_write()
 
1452
            lco_tree.unlock()
1462
1453
        # U L U
1463
 
        with lco_tree.branch.lock_write(), lco_tree.branch.repository.unlock():
 
1454
        lco_tree.branch.lock_write()
 
1455
        lco_tree.branch.repository.unlock()
 
1456
        try:
1464
1457
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1465
 
                                            lco_tree, repo_branch=repo_branch,
1466
 
                                            branch_locked=True,
1467
 
                                            verbose=True)
 
1458
            lco_tree, repo_branch=repo_branch,
 
1459
            branch_locked=True,
 
1460
            verbose=True)
 
1461
        finally:
 
1462
            lco_tree.branch.repository.lock_write()
 
1463
            lco_tree.branch.unlock()
1468
1464
 
1469
1465
        if sys.platform == 'win32':
1470
1466
            self.knownFailure('Win32 cannot run "brz info"'
1473
1469
    def test_info_stacked(self):
1474
1470
        # We have a mainline
1475
1471
        trunk_tree = self.make_branch_and_tree('mainline',
1476
 
                                               format='1.6')
 
1472
            format='1.6')
1477
1473
        trunk_tree.commit('mainline')
1478
1474
        # and a branch from it which is stacked
1479
 
        new_dir = trunk_tree.controldir.sprout('newbranch', stacked=True)
 
1475
        new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1480
1476
        out, err = self.run_bzr('info newbranch')
1481
1477
        self.assertEqual(
1482
 
            """Standalone tree (format: 1.6)
 
1478
"""Standalone tree (format: 1.6)
1483
1479
Location:
1484
1480
  branch root: newbranch
1485
1481
 
1491
1487
 
1492
1488
    def test_info_revinfo_optional(self):
1493
1489
        tree = self.make_branch_and_tree('.')
1494
 
 
1495
1490
        def last_revision_info(self):
1496
1491
            raise errors.UnsupportedOperation(last_revision_info, self)
1497
1492
        self.overrideAttr(
1498
1493
            branch.Branch, "last_revision_info", last_revision_info)
1499
1494
        out, err = self.run_bzr('info -v .')
1500
1495
        self.assertEqual(
1501
 
            """Standalone tree (format: 2a)
 
1496
"""Standalone tree (format: 2a)
1502
1497
Location:
1503
1498
  branch root: .
1504
1499
 
1517
1512
         0 added
1518
1513
         0 removed
1519
1514
         0 renamed
1520
 
         0 copied
1521
1515
         0 unknown
1522
1516
         0 ignored
1523
1517
         0 versioned subdirectories
1525
1519
        self.assertEqual("", err)
1526
1520
 
1527
1521
    def test_info_shows_colocated_branches(self):
1528
 
        bzrdir = self.make_branch('.', format='development-colo').controldir
 
1522
        bzrdir = self.make_branch('.', format='development-colo').bzrdir
1529
1523
        bzrdir.create_branch(name="colo1")
1530
1524
        bzrdir.create_branch(name="colo2")
1531
1525
        bzrdir.create_branch(name="colo3")
1532
1526
        out, err = self.run_bzr('info -v .')
1533
1527
        self.assertEqualDiff(
1534
 
            """Standalone branch (format: development-colo)
 
1528
"""Standalone branch (format: development-colo)
1535
1529
Location:
1536
1530
  branch root: .
1537
1531
 
1550
1544
         0 revisions
1551
1545
""", out)
1552
1546
        self.assertEqual("", err)
 
1547
 
 
1548
 
 
1549
class TestSmartServerInfo(tests.TestCaseWithTransport):
 
1550
 
 
1551
    def test_simple_branch_info(self):
 
1552
        self.setup_smart_server_with_call_log()
 
1553
        t = self.make_branch_and_tree('branch')
 
1554
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
1555
        t.add("foo")
 
1556
        t.commit("message")
 
1557
        self.reset_smart_call_log()
 
1558
        out, err = self.run_bzr(['info', self.get_url('branch')])
 
1559
        # This figure represent the amount of work to perform this use case. It
 
1560
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
1561
        # being too low. If rpc_count increases, more network roundtrips have
 
1562
        # become necessary for this use case. Please do not adjust this number
 
1563
        # upwards without agreement from bzr's network support maintainers.
 
1564
        self.assertLength(10, self.hpss_calls)
 
1565
        self.assertLength(1, self.hpss_connections)
 
1566
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
1567
 
 
1568
    def test_verbose_branch_info(self):
 
1569
        self.setup_smart_server_with_call_log()
 
1570
        t = self.make_branch_and_tree('branch')
 
1571
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
1572
        t.add("foo")
 
1573
        t.commit("message")
 
1574
        self.reset_smart_call_log()
 
1575
        out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
 
1576
        # This figure represent the amount of work to perform this use case. It
 
1577
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
1578
        # being too low. If rpc_count increases, more network roundtrips have
 
1579
        # become necessary for this use case. Please do not adjust this number
 
1580
        # upwards without agreement from bzr's network support maintainers.
 
1581
        self.assertLength(14, self.hpss_calls)
 
1582
        self.assertLength(1, self.hpss_connections)
 
1583
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)