~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

(vila) Fix test failures blocking package builds. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2006-2012 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
20
21
import sys
21
22
 
22
23
from bzrlib import (
23
24
    branch,
24
25
    bzrdir,
 
26
    controldir,
25
27
    errors,
26
28
    info,
27
29
    osutils,
 
30
    tests,
28
31
    upgrade,
29
32
    urlutils,
30
33
    )
31
 
from bzrlib.osutils import format_date
32
 
from bzrlib.tests import TestSkipped
33
 
from bzrlib.tests.blackbox import ExternalBase
34
 
 
35
 
 
36
 
class TestInfo(ExternalBase):
 
34
from bzrlib.tests.matchers import ContainsNoVfsCalls
 
35
from bzrlib.transport import memory
 
36
 
 
37
 
 
38
class TestInfo(tests.TestCaseWithTransport):
37
39
 
38
40
    def setUp(self):
39
 
        ExternalBase.setUp(self)
40
 
        self._repo_strings = "2a or development-subtree"
 
41
        super(TestInfo, self).setUp()
 
42
        self._repo_strings = "2a"
41
43
 
42
44
    def test_info_non_existing(self):
43
 
        if sys.platform == "win32":
44
 
            location = "C:/i/do/not/exist/"
45
 
        else:
46
 
            location = "/i/do/not/exist/"
 
45
        self.vfs_transport_factory = memory.MemoryServer
 
46
        location = self.get_url()
47
47
        out, err = self.run_bzr('info '+location, retcode=3)
48
48
        self.assertEqual(out, '')
49
49
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
50
50
 
 
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
 
51
85
    def test_info_standalone(self):
52
86
        transport = self.get_transport()
53
87
 
54
88
        # Create initial standalone branch
55
 
        tree1 = self.make_branch_and_tree('standalone', 'weave')
 
89
        tree1 = self.make_branch_and_tree('standalone', 'knit')
56
90
        self.build_tree(['standalone/a'])
57
91
        tree1.add('a')
58
92
        branch1 = tree1.branch
59
93
 
60
94
        out, err = self.run_bzr('info standalone')
61
95
        self.assertEqualDiff(
62
 
"""Standalone tree (format: weave)
 
96
"""Standalone tree (format: knit)
63
97
Location:
64
98
  branch root: standalone
65
99
""", out)
68
102
        # Standalone branch - verbose mode
69
103
        out, err = self.run_bzr('info standalone -v')
70
104
        self.assertEqualDiff(
71
 
"""Standalone tree (format: weave)
 
105
"""Standalone tree (format: knit)
72
106
Location:
73
107
  branch root: standalone
74
108
 
75
109
Format:
76
 
       control: All-in-one format 6
77
 
  working tree: Working tree format 2
78
 
        branch: Branch format 4
79
 
    repository: Weave repository format 6
 
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
80
117
 
81
118
In the working tree:
82
119
         0 unchanged
99
136
        # Standalone branch - really verbose mode
100
137
        out, err = self.run_bzr('info standalone -vv')
101
138
        self.assertEqualDiff(
102
 
"""Standalone tree (format: weave)
 
139
"""Standalone tree (format: knit)
103
140
Location:
104
141
  branch root: standalone
105
142
 
106
143
Format:
107
 
       control: All-in-one format 6
108
 
  working tree: Working tree format 2
109
 
        branch: Branch format 4
110
 
    repository: Weave repository format 6
 
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
111
151
 
112
152
In the working tree:
113
153
         0 unchanged
128
168
""", out)
129
169
        self.assertEqual('', err)
130
170
        tree1.commit('commit one')
131
 
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
132
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
171
        rev = branch1.repository.get_revision(branch1.last_revision())
 
172
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
133
173
 
134
174
        # Branch standalone with push location
135
175
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
137
177
 
138
178
        out, err = self.run_bzr('info branch')
139
179
        self.assertEqualDiff(
140
 
"""Standalone tree (format: weave)
 
180
"""Standalone tree (format: knit)
141
181
Location:
142
182
  branch root: branch
143
183
 
149
189
 
150
190
        out, err = self.run_bzr('info branch --verbose')
151
191
        self.assertEqualDiff(
152
 
"""Standalone tree (format: weave)
 
192
"""Standalone tree (format: knit)
153
193
Location:
154
194
  branch root: branch
155
195
 
158
198
  parent branch: standalone
159
199
 
160
200
Format:
161
 
       control: All-in-one format 6
162
 
  working tree: Working tree format 2
163
 
        branch: Branch format 4
164
 
    repository: Weave repository format 6
 
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
165
208
 
166
209
In the working tree:
167
210
         1 unchanged
188
231
        # Branch and bind to standalone, needs upgrade to metadir
189
232
        # (creates backup as unknown)
190
233
        branch1.bzrdir.sprout('bound')
191
 
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
 
234
        knit1_format = controldir.format_registry.make_bzrdir('knit')
192
235
        upgrade.upgrade('bound', knit1_format)
193
 
        branch3 = bzrdir.BzrDir.open('bound').open_branch()
 
236
        branch3 = controldir.ControlDir.open('bound').open_branch()
194
237
        branch3.bind(branch1)
195
238
        bound_tree = branch3.bzrdir.open_workingtree()
196
239
        out, err = self.run_bzr('info -v bound')
209
252
        branch: %s
210
253
    repository: %s
211
254
 
 
255
Control directory:
 
256
         1 branches
 
257
 
212
258
In the working tree:
213
259
         1 unchanged
214
260
         0 modified
215
261
         0 added
216
262
         0 removed
217
263
         0 renamed
218
 
         1 unknown
 
264
         0 unknown
219
265
         0 ignored
220
266
         0 versioned subdirectories
221
267
 
235
281
        self.assertEqual('', err)
236
282
 
237
283
        # Checkout standalone (same as above, but does not have parent set)
238
 
        branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
 
284
        branch4 = controldir.ControlDir.create_branch_convenience('checkout',
239
285
            format=knit1_format)
240
286
        branch4.bind(branch1)
241
287
        branch4.bzrdir.open_workingtree().update()
252
298
        branch: Branch format 5
253
299
    repository: %s
254
300
 
 
301
Control directory:
 
302
         1 branches
 
303
 
255
304
In the working tree:
256
305
         1 unchanged
257
306
         0 modified
279
328
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
280
329
        branch5 = tree5.branch
281
330
        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"
282
335
        self.assertEqualDiff(
283
336
"""Lightweight checkout (format: %s)
284
337
Location:
287
340
 
288
341
Format:
289
342
       control: Meta directory format 1
290
 
  working tree: Working tree format 6
291
 
        branch: Branch format 4
292
 
    repository: Weave repository format 6
 
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
293
349
 
294
350
In the working tree:
295
351
         1 unchanged
309
365
 
310
366
Repository:
311
367
         1 revision
312
 
""" % (self._repo_strings, datestring_first, datestring_first,), out)
 
368
""" % (format_description, datestring_first, datestring_first,), out)
313
369
        self.assertEqual('', err)
314
370
 
315
371
        # Update initial standalone branch
316
372
        self.build_tree(['standalone/b'])
317
373
        tree1.add('b')
318
374
        tree1.commit('commit two')
319
 
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
320
 
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
375
        rev = branch1.repository.get_revision(branch1.last_revision())
 
376
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
321
377
 
322
378
        # Out of date branched standalone branch will not be detected
323
379
        out, err = self.run_bzr('info -v branch')
324
380
        self.assertEqualDiff(
325
 
"""Standalone tree (format: weave)
 
381
"""Standalone tree (format: knit)
326
382
Location:
327
383
  branch root: branch
328
384
 
331
387
  parent branch: standalone
332
388
 
333
389
Format:
334
 
       control: All-in-one format 6
335
 
  working tree: Working tree format 2
336
 
        branch: Branch format 4
337
 
    repository: Weave repository format 6
 
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
338
397
 
339
398
In the working tree:
340
399
         1 unchanged
375
434
        branch: Branch format 5
376
435
    repository: %s
377
436
 
 
437
Control directory:
 
438
         1 branches
 
439
 
378
440
Branch is out of date: missing 1 revision.
379
441
 
380
442
In the working tree:
383
445
         0 added
384
446
         0 removed
385
447
         0 renamed
386
 
         1 unknown
 
448
         0 unknown
387
449
         0 ignored
388
450
         0 versioned subdirectories
389
451
 
414
476
        branch: Branch format 5
415
477
    repository: %s
416
478
 
 
479
Control directory:
 
480
         1 branches
 
481
 
417
482
Branch is out of date: missing 1 revision.
418
483
 
419
484
In the working tree:
449
514
 
450
515
Format:
451
516
       control: Meta directory format 1
452
 
  working tree: Working tree format 6
453
 
        branch: Branch format 4
454
 
    repository: Weave repository format 6
 
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
455
523
 
456
524
Working tree is out of date: missing 1 revision.
457
525
 
473
541
 
474
542
Repository:
475
543
         2 revisions
476
 
""" % (self._repo_strings, datestring_first, datestring_last,), out)
 
544
""" % (format_description, datestring_first, datestring_last,), out)
477
545
        self.assertEqual('', err)
478
546
 
479
547
    def test_info_standalone_no_tree(self):
480
548
        # create standalone branch without a working tree
481
 
        format = bzrdir.format_registry.make_bzrdir('default')
 
549
        format = controldir.format_registry.make_bzrdir('default')
482
550
        branch = self.make_branch('branch')
483
551
        repo = branch.repository
484
552
        out, err = self.run_bzr('info branch -v')
492
560
        branch: %s
493
561
    repository: %s
494
562
 
 
563
Control directory:
 
564
         1 branches
 
565
 
495
566
Branch history:
496
567
         0 revisions
497
568
 
504
575
        self.assertEqual('', err)
505
576
 
506
577
    def test_info_shared_repository(self):
507
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
578
        format = controldir.format_registry.make_bzrdir('knit')
508
579
        transport = self.get_transport()
509
580
 
510
581
        # Create shared repository
520
591
       control: Meta directory format 1
521
592
    repository: %s
522
593
 
 
594
Control directory:
 
595
         0 branches
 
596
 
523
597
Repository:
524
598
         0 revisions
525
599
""" % ('repo', format.repository_format.get_format_description(),
528
602
 
529
603
        # Create branch inside shared repository
530
604
        repo.bzrdir.root_transport.mkdir('branch')
531
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
532
 
            format=format)
 
605
        branch1 = controldir.ControlDir.create_branch_convenience(
 
606
            'repo/branch', format=format)
533
607
        out, err = self.run_bzr('info -v repo/branch')
534
608
        self.assertEqualDiff(
535
609
"""Repository branch (format: dirstate or knit)
542
616
        branch: %s
543
617
    repository: %s
544
618
 
 
619
Control directory:
 
620
         1 branches
 
621
 
545
622
Branch history:
546
623
         0 revisions
547
624
 
570
647
        self.build_tree(['tree/lightcheckout/a'])
571
648
        tree2.add('a')
572
649
        tree2.commit('commit one')
573
 
        rev = repo.get_revision(branch2.revision_history()[0])
574
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
650
        rev = repo.get_revision(branch2.last_revision())
 
651
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
575
652
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
576
653
        self.assertEqualDiff(
577
654
"""Lightweight checkout (format: %s)
586
663
        branch: %s
587
664
    repository: %s
588
665
 
 
666
Control directory:
 
667
         1 branches
 
668
 
589
669
In the working tree:
590
670
         1 unchanged
591
671
         0 modified
624
704
        branch: %s
625
705
    repository: %s
626
706
 
 
707
Control directory:
 
708
         1 branches
 
709
 
627
710
Branch is out of date: missing 1 revision.
628
711
 
629
712
In the working tree:
663
746
        branch: %s
664
747
    repository: %s
665
748
 
 
749
Control directory:
 
750
         1 branches
 
751
 
666
752
In the working tree:
667
753
         1 unchanged
668
754
         0 modified
689
775
        tree3.commit('commit two')
690
776
 
691
777
        # Out of date lightweight checkout
692
 
        rev = repo.get_revision(branch1.revision_history()[-1])
693
 
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
778
        rev = repo.get_revision(branch1.last_revision())
 
779
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
694
780
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
695
781
        self.assertEqualDiff(
696
782
"""Lightweight checkout (format: %s)
705
791
        branch: %s
706
792
    repository: %s
707
793
 
 
794
Control directory:
 
795
         1 branches
 
796
 
708
797
Working tree is out of date: missing 1 revision.
709
798
 
710
799
In the working tree:
744
833
        branch: %s
745
834
    repository: %s
746
835
 
 
836
Control directory:
 
837
         1 branches
 
838
 
747
839
Branch history:
748
840
         2 revisions
749
841
         0 days old
769
861
       control: Meta directory format 1
770
862
    repository: %s
771
863
 
 
864
Control directory:
 
865
         0 branches
 
866
 
772
867
Repository:
773
868
         2 revisions
774
869
""" % (format.repository_format.get_format_description(),
776
871
        self.assertEqual('', err)
777
872
 
778
873
    def test_info_shared_repository_with_trees(self):
779
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
874
        format = controldir.format_registry.make_bzrdir('knit')
780
875
        transport = self.get_transport()
781
876
 
782
877
        # Create shared repository with working trees
792
887
       control: Meta directory format 1
793
888
    repository: %s
794
889
 
 
890
Control directory:
 
891
         0 branches
 
892
 
795
893
Create working tree for new branches inside the repository.
796
894
 
797
895
Repository:
802
900
 
803
901
        # Create two branches
804
902
        repo.bzrdir.root_transport.mkdir('branch1')
805
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
 
903
        branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
806
904
            format=format)
807
905
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
808
906
 
820
918
        branch: %s
821
919
    repository: %s
822
920
 
 
921
Control directory:
 
922
         1 branches
 
923
 
823
924
In the working tree:
824
925
         0 unchanged
825
926
         0 modified
845
946
        tree1 = branch1.bzrdir.open_workingtree()
846
947
        tree1.add('a')
847
948
        tree1.commit('commit one')
848
 
        rev = repo.get_revision(branch1.revision_history()[0])
849
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
949
        rev = repo.get_revision(branch1.last_revision())
 
950
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
850
951
        out, err = self.run_bzr('info -v repo/branch1')
851
952
        self.assertEqualDiff(
852
953
"""Repository tree (format: knit)
860
961
        branch: %s
861
962
    repository: %s
862
963
 
 
964
Control directory:
 
965
         1 branches
 
966
 
863
967
In the working tree:
864
968
         1 unchanged
865
969
         0 modified
901
1005
        branch: %s
902
1006
    repository: %s
903
1007
 
 
1008
Control directory:
 
1009
         1 branches
 
1010
 
904
1011
In the working tree:
905
1012
         0 unchanged
906
1013
         0 modified
940
1047
        branch: %s
941
1048
    repository: %s
942
1049
 
 
1050
Control directory:
 
1051
         1 branches
 
1052
 
943
1053
In the working tree:
944
1054
         1 unchanged
945
1055
         0 modified
975
1085
       control: Meta directory format 1
976
1086
    repository: %s
977
1087
 
 
1088
Control directory:
 
1089
         0 branches
 
1090
 
978
1091
Create working tree for new branches inside the repository.
979
1092
 
980
1093
Repository:
985
1098
        self.assertEqual('', err)
986
1099
 
987
1100
    def test_info_shared_repository_with_tree_in_root(self):
988
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
1101
        format = controldir.format_registry.make_bzrdir('knit')
989
1102
        transport = self.get_transport()
990
1103
 
991
1104
        # Create shared repository with working trees
1001
1114
       control: Meta directory format 1
1002
1115
    repository: %s
1003
1116
 
 
1117
Control directory:
 
1118
         0 branches
 
1119
 
1004
1120
Create working tree for new branches inside the repository.
1005
1121
 
1006
1122
Repository:
1026
1142
        branch: %s
1027
1143
    repository: %s
1028
1144
 
 
1145
Control directory:
 
1146
         1 branches
 
1147
 
1029
1148
In the working tree:
1030
1149
         0 unchanged
1031
1150
         0 modified
1047
1166
        self.assertEqual('', err)
1048
1167
 
1049
1168
    def test_info_repository_hook(self):
1050
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
1169
        format = controldir.format_registry.make_bzrdir('knit')
1051
1170
        def repo_info(repo, stats, outf):
1052
1171
            outf.write("more info\n")
1053
1172
        info.hooks.install_named_hook('repository', repo_info, None)
1063
1182
       control: Meta directory format 1
1064
1183
    repository: %s
1065
1184
 
 
1185
Control directory:
 
1186
         0 branches
 
1187
 
1066
1188
Create working tree for new branches inside the repository.
1067
1189
 
1068
1190
Repository:
1072
1194
       ), out)
1073
1195
        self.assertEqual('', err)
1074
1196
 
 
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
 
1075
1213
    def assertCheckoutStatusOutput(self,
1076
1214
        command_string, lco_tree, shared_repo=None,
1077
1215
        repo_branch=None,
1186
1324
        branch: %s
1187
1325
    repository: %s
1188
1326
%s
 
1327
Control directory:
 
1328
         1 branches
 
1329
 
1189
1330
In the working tree:
1190
1331
         0 unchanged
1191
1332
         0 modified
1220
1361
                                    format=bzrdir.BzrDirMetaFormat1())
1221
1362
        repo.set_make_working_trees(False)
1222
1363
        repo.bzrdir.root_transport.mkdir('branch')
1223
 
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1224
 
                                    format=bzrdir.BzrDirMetaFormat1())
 
1364
        repo_branch = controldir.ControlDir.create_branch_convenience(
 
1365
            'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1225
1366
        # Do a heavy checkout
1226
1367
        transport.mkdir('tree')
1227
1368
        transport.mkdir('tree/checkout')
1228
 
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1229
 
            format=bzrdir.BzrDirMetaFormat1())
 
1369
        co_branch = controldir.ControlDir.create_branch_convenience(
 
1370
            'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1230
1371
        co_branch.bind(repo_branch)
1231
1372
        # Do a light checkout of the heavy one
1232
1373
        transport.mkdir('tree/lightcheckout')
1233
1374
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1234
 
        branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
 
1375
        lco_dir.set_branch_reference(co_branch)
1235
1376
        lco_dir.create_workingtree()
1236
1377
        lco_tree = lco_dir.open_workingtree()
1237
1378
 
1325
1466
            self.knownFailure('Win32 cannot run "bzr info"'
1326
1467
                              ' when the tree is locked.')
1327
1468
 
1328
 
    def test_info_locking_oslocks(self):
1329
 
        if sys.platform == "win32":
1330
 
            raise TestSkipped("don't use oslocks on win32 in unix manner")
1331
 
        self.thisFailsStrictLockCheck()
1332
 
 
1333
 
        tree = self.make_branch_and_tree('branch',
1334
 
                                         format=bzrdir.BzrDirFormat6())
1335
 
 
1336
 
        # Test all permutations of locking the working tree, branch and repository
1337
 
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1338
 
        # implemented by raising NotImplementedError and get_physical_lock_status()
1339
 
        # always returns false. This makes bzr info hide the lock status.  (Olaf)
1340
 
        # W B R
1341
 
 
1342
 
        # U U U
1343
 
        out, err = self.run_bzr('info -v branch')
1344
 
        self.assertEqualDiff(
1345
 
"""Standalone tree (format: weave)
1346
 
Location:
1347
 
  branch root: %s
1348
 
 
1349
 
Format:
1350
 
       control: All-in-one format 6
1351
 
  working tree: Working tree format 2
1352
 
        branch: Branch format 4
1353
 
    repository: %s
1354
 
 
1355
 
In the working tree:
1356
 
         0 unchanged
1357
 
         0 modified
1358
 
         0 added
1359
 
         0 removed
1360
 
         0 renamed
1361
 
         0 unknown
1362
 
         0 ignored
1363
 
         0 versioned subdirectories
1364
 
 
1365
 
Branch history:
1366
 
         0 revisions
1367
 
 
1368
 
Repository:
1369
 
         0 revisions
1370
 
""" % ('branch', tree.branch.repository._format.get_format_description(),
1371
 
       ), out)
1372
 
        self.assertEqual('', err)
1373
 
        # L L L
1374
 
        tree.lock_write()
1375
 
        out, err = self.run_bzr('info -v branch')
1376
 
        self.assertEqualDiff(
1377
 
"""Standalone tree (format: weave)
1378
 
Location:
1379
 
  branch root: %s
1380
 
 
1381
 
Format:
1382
 
       control: All-in-one format 6
1383
 
  working tree: Working tree format 2
1384
 
        branch: Branch format 4
1385
 
    repository: %s
1386
 
 
1387
 
In the working tree:
1388
 
         0 unchanged
1389
 
         0 modified
1390
 
         0 added
1391
 
         0 removed
1392
 
         0 renamed
1393
 
         0 unknown
1394
 
         0 ignored
1395
 
         0 versioned subdirectories
1396
 
 
1397
 
Branch history:
1398
 
         0 revisions
1399
 
 
1400
 
Repository:
1401
 
         0 revisions
1402
 
""" % ('branch', tree.branch.repository._format.get_format_description(),
1403
 
       ), out)
1404
 
        self.assertEqual('', err)
1405
 
        tree.unlock()
1406
 
 
1407
1469
    def test_info_stacked(self):
1408
1470
        # We have a mainline
1409
1471
        trunk_tree = self.make_branch_and_tree('mainline',
1422
1484
     stacked on: mainline
1423
1485
""", out)
1424
1486
        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)