~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
17
17
 
18
18
"""Tests for the info command of bzr."""
19
19
 
20
 
import shutil
21
20
import sys
22
21
 
23
22
from bzrlib import (
24
23
    branch,
25
24
    bzrdir,
26
 
    controldir,
27
25
    errors,
28
26
    info,
29
27
    osutils,
31
29
    upgrade,
32
30
    urlutils,
33
31
    )
34
 
from bzrlib.tests.matchers import ContainsNoVfsCalls
35
32
from bzrlib.transport import memory
36
33
 
37
34
 
48
45
        self.assertEqual(out, '')
49
46
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
50
47
 
51
 
    def test_info_empty_controldir(self):
52
 
        self.make_bzrdir('ctrl')
53
 
        out, err = self.run_bzr('info ctrl')
54
 
        self.assertEquals(out,
55
 
            'Empty control directory (format: 2a or pack-0.92)\n'
56
 
            'Location:\n'
57
 
            '  control directory: ctrl\n')
58
 
        self.assertEquals(err, '')
59
 
 
60
 
    def test_info_empty_controldir_verbose(self):
61
 
        self.make_bzrdir('ctrl')
62
 
        out, err = self.run_bzr('info -v ctrl')
63
 
        self.assertEqualDiff(out,
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')
71
 
        self.assertEquals(err, '')
72
 
 
73
 
    def test_info_dangling_branch_reference(self):
74
 
        br = self.make_branch('target')
75
 
        br.create_checkout('from', lightweight=True)
76
 
        shutil.rmtree('target')
77
 
        out, err = self.run_bzr('info from')
78
 
        self.assertEquals(out,
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')
83
 
        self.assertEquals(err, '')
84
 
 
85
48
    def test_info_standalone(self):
86
49
        transport = self.get_transport()
87
50
 
88
51
        # Create initial standalone branch
89
 
        tree1 = self.make_branch_and_tree('standalone', 'knit')
 
52
        tree1 = self.make_branch_and_tree('standalone', 'weave')
90
53
        self.build_tree(['standalone/a'])
91
54
        tree1.add('a')
92
55
        branch1 = tree1.branch
93
56
 
94
57
        out, err = self.run_bzr('info standalone')
95
58
        self.assertEqualDiff(
96
 
"""Standalone tree (format: knit)
 
59
"""Standalone tree (format: weave)
97
60
Location:
98
61
  branch root: standalone
99
62
""", out)
102
65
        # Standalone branch - verbose mode
103
66
        out, err = self.run_bzr('info standalone -v')
104
67
        self.assertEqualDiff(
105
 
"""Standalone tree (format: knit)
 
68
"""Standalone tree (format: weave)
106
69
Location:
107
70
  branch root: standalone
108
71
 
109
72
Format:
110
 
       control: Meta directory format 1
111
 
  working tree: Working tree format 3
112
 
        branch: Branch format 5
113
 
    repository: Knit repository format 1
114
 
 
115
 
Control directory:
116
 
         1 branches
 
73
       control: All-in-one format 6
 
74
  working tree: Working tree format 2
 
75
        branch: Branch format 4
 
76
    repository: Weave repository format 6
117
77
 
118
78
In the working tree:
119
79
         0 unchanged
136
96
        # Standalone branch - really verbose mode
137
97
        out, err = self.run_bzr('info standalone -vv')
138
98
        self.assertEqualDiff(
139
 
"""Standalone tree (format: knit)
 
99
"""Standalone tree (format: weave)
140
100
Location:
141
101
  branch root: standalone
142
102
 
143
103
Format:
144
 
       control: Meta directory format 1
145
 
  working tree: Working tree format 3
146
 
        branch: Branch format 5
147
 
    repository: Knit repository format 1
148
 
 
149
 
Control directory:
150
 
         1 branches
 
104
       control: All-in-one format 6
 
105
  working tree: Working tree format 2
 
106
        branch: Branch format 4
 
107
    repository: Weave repository format 6
151
108
 
152
109
In the working tree:
153
110
         0 unchanged
168
125
""", out)
169
126
        self.assertEqual('', err)
170
127
        tree1.commit('commit one')
171
 
        rev = branch1.repository.get_revision(branch1.last_revision())
 
128
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
172
129
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
173
130
 
174
131
        # Branch standalone with push location
177
134
 
178
135
        out, err = self.run_bzr('info branch')
179
136
        self.assertEqualDiff(
180
 
"""Standalone tree (format: knit)
 
137
"""Standalone tree (format: weave)
181
138
Location:
182
139
  branch root: branch
183
140
 
189
146
 
190
147
        out, err = self.run_bzr('info branch --verbose')
191
148
        self.assertEqualDiff(
192
 
"""Standalone tree (format: knit)
 
149
"""Standalone tree (format: weave)
193
150
Location:
194
151
  branch root: branch
195
152
 
198
155
  parent branch: standalone
199
156
 
200
157
Format:
201
 
       control: Meta directory format 1
202
 
  working tree: Working tree format 3
203
 
        branch: Branch format 5
204
 
    repository: Knit repository format 1
205
 
 
206
 
Control directory:
207
 
         1 branches
 
158
       control: All-in-one format 6
 
159
  working tree: Working tree format 2
 
160
        branch: Branch format 4
 
161
    repository: Weave repository format 6
208
162
 
209
163
In the working tree:
210
164
         1 unchanged
231
185
        # Branch and bind to standalone, needs upgrade to metadir
232
186
        # (creates backup as unknown)
233
187
        branch1.bzrdir.sprout('bound')
234
 
        knit1_format = controldir.format_registry.make_bzrdir('knit')
 
188
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
235
189
        upgrade.upgrade('bound', knit1_format)
236
 
        branch3 = controldir.ControlDir.open('bound').open_branch()
 
190
        branch3 = bzrdir.BzrDir.open('bound').open_branch()
237
191
        branch3.bind(branch1)
238
192
        bound_tree = branch3.bzrdir.open_workingtree()
239
193
        out, err = self.run_bzr('info -v bound')
252
206
        branch: %s
253
207
    repository: %s
254
208
 
255
 
Control directory:
256
 
         1 branches
257
 
 
258
209
In the working tree:
259
210
         1 unchanged
260
211
         0 modified
262
213
         0 removed
263
214
         0 renamed
264
215
         0 unknown
265
 
         0 ignored
 
216
         1 ignored
266
217
         0 versioned subdirectories
267
218
 
268
219
Branch history:
281
232
        self.assertEqual('', err)
282
233
 
283
234
        # Checkout standalone (same as above, but does not have parent set)
284
 
        branch4 = controldir.ControlDir.create_branch_convenience('checkout',
 
235
        branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
285
236
            format=knit1_format)
286
237
        branch4.bind(branch1)
287
238
        branch4.bzrdir.open_workingtree().update()
298
249
        branch: Branch format 5
299
250
    repository: %s
300
251
 
301
 
Control directory:
302
 
         1 branches
303
 
 
304
252
In the working tree:
305
253
         1 unchanged
306
254
         0 modified
328
276
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
329
277
        branch5 = tree5.branch
330
278
        out, err = self.run_bzr('info -v lightcheckout')
331
 
        if "metaweave" in controldir.format_registry:
332
 
            format_description = "knit or metaweave"
333
 
        else:
334
 
            format_description = "knit"
335
279
        self.assertEqualDiff(
336
280
"""Lightweight checkout (format: %s)
337
281
Location:
340
284
 
341
285
Format:
342
286
       control: Meta directory format 1
343
 
  working tree: Working tree format 3
344
 
        branch: Branch format 5
345
 
    repository: Knit repository format 1
346
 
 
347
 
Control directory:
348
 
         1 branches
 
287
  working tree: Working tree format 6
 
288
        branch: Branch format 4
 
289
    repository: Weave repository format 6
349
290
 
350
291
In the working tree:
351
292
         1 unchanged
365
306
 
366
307
Repository:
367
308
         1 revision
368
 
""" % (format_description, datestring_first, datestring_first,), out)
 
309
""" % (self._repo_strings, datestring_first, datestring_first,), out)
369
310
        self.assertEqual('', err)
370
311
 
371
312
        # Update initial standalone branch
372
313
        self.build_tree(['standalone/b'])
373
314
        tree1.add('b')
374
315
        tree1.commit('commit two')
375
 
        rev = branch1.repository.get_revision(branch1.last_revision())
 
316
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
376
317
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
377
318
 
378
319
        # Out of date branched standalone branch will not be detected
379
320
        out, err = self.run_bzr('info -v branch')
380
321
        self.assertEqualDiff(
381
 
"""Standalone tree (format: knit)
 
322
"""Standalone tree (format: weave)
382
323
Location:
383
324
  branch root: branch
384
325
 
387
328
  parent branch: standalone
388
329
 
389
330
Format:
390
 
       control: Meta directory format 1
391
 
  working tree: Working tree format 3
392
 
        branch: Branch format 5
393
 
    repository: Knit repository format 1
394
 
 
395
 
Control directory:
396
 
         1 branches
 
331
       control: All-in-one format 6
 
332
  working tree: Working tree format 2
 
333
        branch: Branch format 4
 
334
    repository: Weave repository format 6
397
335
 
398
336
In the working tree:
399
337
         1 unchanged
434
372
        branch: Branch format 5
435
373
    repository: %s
436
374
 
437
 
Control directory:
438
 
         1 branches
439
 
 
440
375
Branch is out of date: missing 1 revision.
441
376
 
442
377
In the working tree:
446
381
         0 removed
447
382
         0 renamed
448
383
         0 unknown
449
 
         0 ignored
 
384
         1 ignored
450
385
         0 versioned subdirectories
451
386
 
452
387
Branch history:
476
411
        branch: Branch format 5
477
412
    repository: %s
478
413
 
479
 
Control directory:
480
 
         1 branches
481
 
 
482
414
Branch is out of date: missing 1 revision.
483
415
 
484
416
In the working tree:
514
446
 
515
447
Format:
516
448
       control: Meta directory format 1
517
 
  working tree: Working tree format 3
518
 
        branch: Branch format 5
519
 
    repository: Knit repository format 1
520
 
 
521
 
Control directory:
522
 
         1 branches
 
449
  working tree: Working tree format 6
 
450
        branch: Branch format 4
 
451
    repository: Weave repository format 6
523
452
 
524
453
Working tree is out of date: missing 1 revision.
525
454
 
541
470
 
542
471
Repository:
543
472
         2 revisions
544
 
""" % (format_description, datestring_first, datestring_last,), out)
 
473
""" % (self._repo_strings, datestring_first, datestring_last,), out)
545
474
        self.assertEqual('', err)
546
475
 
547
476
    def test_info_standalone_no_tree(self):
548
477
        # create standalone branch without a working tree
549
 
        format = controldir.format_registry.make_bzrdir('default')
 
478
        format = bzrdir.format_registry.make_bzrdir('default')
550
479
        branch = self.make_branch('branch')
551
480
        repo = branch.repository
552
481
        out, err = self.run_bzr('info branch -v')
560
489
        branch: %s
561
490
    repository: %s
562
491
 
563
 
Control directory:
564
 
         1 branches
565
 
 
566
492
Branch history:
567
493
         0 revisions
568
494
 
575
501
        self.assertEqual('', err)
576
502
 
577
503
    def test_info_shared_repository(self):
578
 
        format = controldir.format_registry.make_bzrdir('knit')
 
504
        format = bzrdir.format_registry.make_bzrdir('knit')
579
505
        transport = self.get_transport()
580
506
 
581
507
        # Create shared repository
591
517
       control: Meta directory format 1
592
518
    repository: %s
593
519
 
594
 
Control directory:
595
 
         0 branches
596
 
 
597
520
Repository:
598
521
         0 revisions
599
522
""" % ('repo', format.repository_format.get_format_description(),
602
525
 
603
526
        # Create branch inside shared repository
604
527
        repo.bzrdir.root_transport.mkdir('branch')
605
 
        branch1 = controldir.ControlDir.create_branch_convenience(
606
 
            'repo/branch', format=format)
 
528
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
 
529
            format=format)
607
530
        out, err = self.run_bzr('info -v repo/branch')
608
531
        self.assertEqualDiff(
609
532
"""Repository branch (format: dirstate or knit)
616
539
        branch: %s
617
540
    repository: %s
618
541
 
619
 
Control directory:
620
 
         1 branches
621
 
 
622
542
Branch history:
623
543
         0 revisions
624
544
 
647
567
        self.build_tree(['tree/lightcheckout/a'])
648
568
        tree2.add('a')
649
569
        tree2.commit('commit one')
650
 
        rev = repo.get_revision(branch2.last_revision())
 
570
        rev = repo.get_revision(branch2.revision_history()[0])
651
571
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
652
572
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
653
573
        self.assertEqualDiff(
663
583
        branch: %s
664
584
    repository: %s
665
585
 
666
 
Control directory:
667
 
         1 branches
668
 
 
669
586
In the working tree:
670
587
         1 unchanged
671
588
         0 modified
704
621
        branch: %s
705
622
    repository: %s
706
623
 
707
 
Control directory:
708
 
         1 branches
709
 
 
710
624
Branch is out of date: missing 1 revision.
711
625
 
712
626
In the working tree:
746
660
        branch: %s
747
661
    repository: %s
748
662
 
749
 
Control directory:
750
 
         1 branches
751
 
 
752
663
In the working tree:
753
664
         1 unchanged
754
665
         0 modified
775
686
        tree3.commit('commit two')
776
687
 
777
688
        # Out of date lightweight checkout
778
 
        rev = repo.get_revision(branch1.last_revision())
 
689
        rev = repo.get_revision(branch1.revision_history()[-1])
779
690
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
780
691
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
781
692
        self.assertEqualDiff(
791
702
        branch: %s
792
703
    repository: %s
793
704
 
794
 
Control directory:
795
 
         1 branches
796
 
 
797
705
Working tree is out of date: missing 1 revision.
798
706
 
799
707
In the working tree:
833
741
        branch: %s
834
742
    repository: %s
835
743
 
836
 
Control directory:
837
 
         1 branches
838
 
 
839
744
Branch history:
840
745
         2 revisions
841
746
         0 days old
861
766
       control: Meta directory format 1
862
767
    repository: %s
863
768
 
864
 
Control directory:
865
 
         0 branches
866
 
 
867
769
Repository:
868
770
         2 revisions
869
771
""" % (format.repository_format.get_format_description(),
871
773
        self.assertEqual('', err)
872
774
 
873
775
    def test_info_shared_repository_with_trees(self):
874
 
        format = controldir.format_registry.make_bzrdir('knit')
 
776
        format = bzrdir.format_registry.make_bzrdir('knit')
875
777
        transport = self.get_transport()
876
778
 
877
779
        # Create shared repository with working trees
887
789
       control: Meta directory format 1
888
790
    repository: %s
889
791
 
890
 
Control directory:
891
 
         0 branches
892
 
 
893
792
Create working tree for new branches inside the repository.
894
793
 
895
794
Repository:
900
799
 
901
800
        # Create two branches
902
801
        repo.bzrdir.root_transport.mkdir('branch1')
903
 
        branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
 
802
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
904
803
            format=format)
905
804
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
906
805
 
918
817
        branch: %s
919
818
    repository: %s
920
819
 
921
 
Control directory:
922
 
         1 branches
923
 
 
924
820
In the working tree:
925
821
         0 unchanged
926
822
         0 modified
946
842
        tree1 = branch1.bzrdir.open_workingtree()
947
843
        tree1.add('a')
948
844
        tree1.commit('commit one')
949
 
        rev = repo.get_revision(branch1.last_revision())
 
845
        rev = repo.get_revision(branch1.revision_history()[0])
950
846
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
951
847
        out, err = self.run_bzr('info -v repo/branch1')
952
848
        self.assertEqualDiff(
961
857
        branch: %s
962
858
    repository: %s
963
859
 
964
 
Control directory:
965
 
         1 branches
966
 
 
967
860
In the working tree:
968
861
         1 unchanged
969
862
         0 modified
1005
898
        branch: %s
1006
899
    repository: %s
1007
900
 
1008
 
Control directory:
1009
 
         1 branches
1010
 
 
1011
901
In the working tree:
1012
902
         0 unchanged
1013
903
         0 modified
1047
937
        branch: %s
1048
938
    repository: %s
1049
939
 
1050
 
Control directory:
1051
 
         1 branches
1052
 
 
1053
940
In the working tree:
1054
941
         1 unchanged
1055
942
         0 modified
1085
972
       control: Meta directory format 1
1086
973
    repository: %s
1087
974
 
1088
 
Control directory:
1089
 
         0 branches
1090
 
 
1091
975
Create working tree for new branches inside the repository.
1092
976
 
1093
977
Repository:
1098
982
        self.assertEqual('', err)
1099
983
 
1100
984
    def test_info_shared_repository_with_tree_in_root(self):
1101
 
        format = controldir.format_registry.make_bzrdir('knit')
 
985
        format = bzrdir.format_registry.make_bzrdir('knit')
1102
986
        transport = self.get_transport()
1103
987
 
1104
988
        # Create shared repository with working trees
1114
998
       control: Meta directory format 1
1115
999
    repository: %s
1116
1000
 
1117
 
Control directory:
1118
 
         0 branches
1119
 
 
1120
1001
Create working tree for new branches inside the repository.
1121
1002
 
1122
1003
Repository:
1142
1023
        branch: %s
1143
1024
    repository: %s
1144
1025
 
1145
 
Control directory:
1146
 
         1 branches
1147
 
 
1148
1026
In the working tree:
1149
1027
         0 unchanged
1150
1028
         0 modified
1166
1044
        self.assertEqual('', err)
1167
1045
 
1168
1046
    def test_info_repository_hook(self):
1169
 
        format = controldir.format_registry.make_bzrdir('knit')
 
1047
        format = bzrdir.format_registry.make_bzrdir('knit')
1170
1048
        def repo_info(repo, stats, outf):
1171
1049
            outf.write("more info\n")
1172
1050
        info.hooks.install_named_hook('repository', repo_info, None)
1182
1060
       control: Meta directory format 1
1183
1061
    repository: %s
1184
1062
 
1185
 
Control directory:
1186
 
         0 branches
1187
 
 
1188
1063
Create working tree for new branches inside the repository.
1189
1064
 
1190
1065
Repository:
1194
1069
       ), out)
1195
1070
        self.assertEqual('', err)
1196
1071
 
1197
 
    def test_info_unshared_repository_with_colocated_branches(self):
1198
 
        format = controldir.format_registry.make_bzrdir('development-colo')
1199
 
        transport = self.get_transport()
1200
 
 
1201
 
        # Create unshared repository
1202
 
        repo = self.make_repository('repo', shared=False, format=format)
1203
 
        repo.set_make_working_trees(True)
1204
 
        repo.bzrdir.create_branch(name='foo')
1205
 
        out, err = self.run_bzr('info repo')
1206
 
        self.assertEqualDiff(
1207
 
"""Unshared repository with trees and colocated branches (format: development-colo)
1208
 
Location:
1209
 
  repository: repo
1210
 
""", out)
1211
 
        self.assertEqual('', err)
1212
 
 
1213
1072
    def assertCheckoutStatusOutput(self,
1214
1073
        command_string, lco_tree, shared_repo=None,
1215
1074
        repo_branch=None,
1324
1183
        branch: %s
1325
1184
    repository: %s
1326
1185
%s
1327
 
Control directory:
1328
 
         1 branches
1329
 
 
1330
1186
In the working tree:
1331
1187
         0 unchanged
1332
1188
         0 modified
1361
1217
                                    format=bzrdir.BzrDirMetaFormat1())
1362
1218
        repo.set_make_working_trees(False)
1363
1219
        repo.bzrdir.root_transport.mkdir('branch')
1364
 
        repo_branch = controldir.ControlDir.create_branch_convenience(
1365
 
            'repo/branch', format=bzrdir.BzrDirMetaFormat1())
 
1220
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
 
1221
                                    format=bzrdir.BzrDirMetaFormat1())
1366
1222
        # Do a heavy checkout
1367
1223
        transport.mkdir('tree')
1368
1224
        transport.mkdir('tree/checkout')
1369
 
        co_branch = controldir.ControlDir.create_branch_convenience(
1370
 
            'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
 
1225
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
 
1226
            format=bzrdir.BzrDirMetaFormat1())
1371
1227
        co_branch.bind(repo_branch)
1372
1228
        # Do a light checkout of the heavy one
1373
1229
        transport.mkdir('tree/lightcheckout')
1374
1230
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1375
 
        lco_dir.set_branch_reference(co_branch)
 
1231
        branch.BranchReferenceFormat().initialize(lco_dir,
 
1232
            target_branch=co_branch)
1376
1233
        lco_dir.create_workingtree()
1377
1234
        lco_tree = lco_dir.open_workingtree()
1378
1235
 
1466
1323
            self.knownFailure('Win32 cannot run "bzr info"'
1467
1324
                              ' when the tree is locked.')
1468
1325
 
 
1326
    def test_info_locking_oslocks(self):
 
1327
        if sys.platform == "win32":
 
1328
            self.skip("don't use oslocks on win32 in unix manner")
 
1329
        # This test tests old (all-in-one, OS lock using) behaviour which
 
1330
        # simply cannot work on windows (and is indeed why we changed our
 
1331
        # design. As such, don't try to remove the thisFailsStrictLockCheck
 
1332
        # call here.
 
1333
        self.thisFailsStrictLockCheck()
 
1334
 
 
1335
        tree = self.make_branch_and_tree('branch',
 
1336
                                         format=bzrdir.BzrDirFormat6())
 
1337
 
 
1338
        # Test all permutations of locking the working tree, branch and repository
 
1339
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
 
1340
        # implemented by raising NotImplementedError and get_physical_lock_status()
 
1341
        # always returns false. This makes bzr info hide the lock status.  (Olaf)
 
1342
        # W B R
 
1343
 
 
1344
        # U U U
 
1345
        out, err = self.run_bzr('info -v branch')
 
1346
        self.assertEqualDiff(
 
1347
"""Standalone tree (format: weave)
 
1348
Location:
 
1349
  branch root: %s
 
1350
 
 
1351
Format:
 
1352
       control: All-in-one format 6
 
1353
  working tree: Working tree format 2
 
1354
        branch: Branch format 4
 
1355
    repository: %s
 
1356
 
 
1357
In the working tree:
 
1358
         0 unchanged
 
1359
         0 modified
 
1360
         0 added
 
1361
         0 removed
 
1362
         0 renamed
 
1363
         0 unknown
 
1364
         0 ignored
 
1365
         0 versioned subdirectories
 
1366
 
 
1367
Branch history:
 
1368
         0 revisions
 
1369
 
 
1370
Repository:
 
1371
         0 revisions
 
1372
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1373
       ), out)
 
1374
        self.assertEqual('', err)
 
1375
        # L L L
 
1376
        tree.lock_write()
 
1377
        out, err = self.run_bzr('info -v branch')
 
1378
        self.assertEqualDiff(
 
1379
"""Standalone tree (format: weave)
 
1380
Location:
 
1381
  branch root: %s
 
1382
 
 
1383
Format:
 
1384
       control: All-in-one format 6
 
1385
  working tree: Working tree format 2
 
1386
        branch: Branch format 4
 
1387
    repository: %s
 
1388
 
 
1389
In the working tree:
 
1390
         0 unchanged
 
1391
         0 modified
 
1392
         0 added
 
1393
         0 removed
 
1394
         0 renamed
 
1395
         0 unknown
 
1396
         0 ignored
 
1397
         0 versioned subdirectories
 
1398
 
 
1399
Branch history:
 
1400
         0 revisions
 
1401
 
 
1402
Repository:
 
1403
         0 revisions
 
1404
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1405
       ), out)
 
1406
        self.assertEqual('', err)
 
1407
        tree.unlock()
 
1408
 
1469
1409
    def test_info_stacked(self):
1470
1410
        # We have a mainline
1471
1411
        trunk_tree = self.make_branch_and_tree('mainline',
1484
1424
     stacked on: mainline
1485
1425
""", out)
1486
1426
        self.assertEqual("", err)
1487
 
 
1488
 
    def test_info_revinfo_optional(self):
1489
 
        tree = self.make_branch_and_tree('.')
1490
 
        def last_revision_info(self):
1491
 
            raise errors.UnsupportedOperation(last_revision_info, self)
1492
 
        self.overrideAttr(
1493
 
            branch.Branch, "last_revision_info", last_revision_info)
1494
 
        out, err = self.run_bzr('info -v .')
1495
 
        self.assertEqual(
1496
 
"""Standalone tree (format: 2a)
1497
 
Location:
1498
 
  branch root: .
1499
 
 
1500
 
Format:
1501
 
       control: Meta directory format 1
1502
 
  working tree: Working tree format 6
1503
 
        branch: Branch format 7
1504
 
    repository: Repository format 2a - rich roots, group compression and chk inventories
1505
 
 
1506
 
Control directory:
1507
 
         1 branches
1508
 
 
1509
 
In the working tree:
1510
 
         0 unchanged
1511
 
         0 modified
1512
 
         0 added
1513
 
         0 removed
1514
 
         0 renamed
1515
 
         0 unknown
1516
 
         0 ignored
1517
 
         0 versioned subdirectories
1518
 
""", out)
1519
 
        self.assertEqual("", err)
1520
 
 
1521
 
    def test_info_shows_colocated_branches(self):
1522
 
        bzrdir = self.make_branch('.', format='development-colo').bzrdir
1523
 
        bzrdir.create_branch(name="colo1")
1524
 
        bzrdir.create_branch(name="colo2")
1525
 
        bzrdir.create_branch(name="colo3")
1526
 
        out, err = self.run_bzr('info -v .')
1527
 
        self.assertEqualDiff(
1528
 
"""Standalone branch (format: development-colo)
1529
 
Location:
1530
 
  branch root: .
1531
 
 
1532
 
Format:
1533
 
       control: Meta directory format 1 with support for colocated branches
1534
 
        branch: Branch format 7
1535
 
    repository: Repository format 2a - rich roots, group compression and chk inventories
1536
 
 
1537
 
Control directory:
1538
 
         4 branches
1539
 
 
1540
 
Branch history:
1541
 
         0 revisions
1542
 
 
1543
 
Repository:
1544
 
         0 revisions
1545
 
""", out)
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)