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

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

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