~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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,
29
31
    upgrade,
30
32
    urlutils,
31
33
    )
 
34
from bzrlib.tests.matchers import ContainsNoVfsCalls
32
35
from bzrlib.transport import memory
33
36
 
34
37
 
45
48
        self.assertEqual(out, '')
46
49
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
47
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_dangling_branch_reference(self):
 
61
        br = self.make_branch('target')
 
62
        br.create_checkout('from', lightweight=True)
 
63
        shutil.rmtree('target')
 
64
        out, err = self.run_bzr('info from')
 
65
        self.assertEquals(out,
 
66
            'Dangling branch reference (format: 2a or pack-0.92)\n'
 
67
            'Location:\n'
 
68
            '   control directory: from\n'
 
69
            '  checkout of branch: target\n')
 
70
        self.assertEquals(err, '')
 
71
 
48
72
    def test_info_standalone(self):
49
73
        transport = self.get_transport()
50
74
 
75
99
        branch: Branch format 5
76
100
    repository: Knit repository format 1
77
101
 
 
102
Control directory:
 
103
         1 branches
 
104
 
78
105
In the working tree:
79
106
         0 unchanged
80
107
         0 modified
106
133
        branch: Branch format 5
107
134
    repository: Knit repository format 1
108
135
 
 
136
Control directory:
 
137
         1 branches
 
138
 
109
139
In the working tree:
110
140
         0 unchanged
111
141
         0 modified
125
155
""", out)
126
156
        self.assertEqual('', err)
127
157
        tree1.commit('commit one')
128
 
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
 
158
        rev = branch1.repository.get_revision(branch1.last_revision())
129
159
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
130
160
 
131
161
        # Branch standalone with push location
160
190
        branch: Branch format 5
161
191
    repository: Knit repository format 1
162
192
 
 
193
Control directory:
 
194
         1 branches
 
195
 
163
196
In the working tree:
164
197
         1 unchanged
165
198
         0 modified
187
220
        branch1.bzrdir.sprout('bound')
188
221
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
189
222
        upgrade.upgrade('bound', knit1_format)
190
 
        branch3 = bzrdir.BzrDir.open('bound').open_branch()
 
223
        branch3 = controldir.ControlDir.open('bound').open_branch()
191
224
        branch3.bind(branch1)
192
225
        bound_tree = branch3.bzrdir.open_workingtree()
193
226
        out, err = self.run_bzr('info -v bound')
206
239
        branch: %s
207
240
    repository: %s
208
241
 
 
242
Control directory:
 
243
         1 branches
 
244
 
209
245
In the working tree:
210
246
         1 unchanged
211
247
         0 modified
232
268
        self.assertEqual('', err)
233
269
 
234
270
        # Checkout standalone (same as above, but does not have parent set)
235
 
        branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
 
271
        branch4 = controldir.ControlDir.create_branch_convenience('checkout',
236
272
            format=knit1_format)
237
273
        branch4.bind(branch1)
238
274
        branch4.bzrdir.open_workingtree().update()
249
285
        branch: Branch format 5
250
286
    repository: %s
251
287
 
 
288
Control directory:
 
289
         1 branches
 
290
 
252
291
In the working tree:
253
292
         1 unchanged
254
293
         0 modified
292
331
        branch: Branch format 5
293
332
    repository: Knit repository format 1
294
333
 
 
334
Control directory:
 
335
         1 branches
 
336
 
295
337
In the working tree:
296
338
         1 unchanged
297
339
         0 modified
317
359
        self.build_tree(['standalone/b'])
318
360
        tree1.add('b')
319
361
        tree1.commit('commit two')
320
 
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
 
362
        rev = branch1.repository.get_revision(branch1.last_revision())
321
363
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
322
364
 
323
365
        # Out of date branched standalone branch will not be detected
337
379
        branch: Branch format 5
338
380
    repository: Knit repository format 1
339
381
 
 
382
Control directory:
 
383
         1 branches
 
384
 
340
385
In the working tree:
341
386
         1 unchanged
342
387
         0 modified
376
421
        branch: Branch format 5
377
422
    repository: %s
378
423
 
 
424
Control directory:
 
425
         1 branches
 
426
 
379
427
Branch is out of date: missing 1 revision.
380
428
 
381
429
In the working tree:
415
463
        branch: Branch format 5
416
464
    repository: %s
417
465
 
 
466
Control directory:
 
467
         1 branches
 
468
 
418
469
Branch is out of date: missing 1 revision.
419
470
 
420
471
In the working tree:
454
505
        branch: Branch format 5
455
506
    repository: Knit repository format 1
456
507
 
 
508
Control directory:
 
509
         1 branches
 
510
 
457
511
Working tree is out of date: missing 1 revision.
458
512
 
459
513
In the working tree:
493
547
        branch: %s
494
548
    repository: %s
495
549
 
 
550
Control directory:
 
551
         1 branches
 
552
 
496
553
Branch history:
497
554
         0 revisions
498
555
 
521
578
       control: Meta directory format 1
522
579
    repository: %s
523
580
 
 
581
Control directory:
 
582
         0 branches
 
583
 
524
584
Repository:
525
585
         0 revisions
526
586
""" % ('repo', format.repository_format.get_format_description(),
529
589
 
530
590
        # Create branch inside shared repository
531
591
        repo.bzrdir.root_transport.mkdir('branch')
532
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
533
 
            format=format)
 
592
        branch1 = controldir.ControlDir.create_branch_convenience(
 
593
            'repo/branch', format=format)
534
594
        out, err = self.run_bzr('info -v repo/branch')
535
595
        self.assertEqualDiff(
536
596
"""Repository branch (format: dirstate or knit)
543
603
        branch: %s
544
604
    repository: %s
545
605
 
 
606
Control directory:
 
607
         1 branches
 
608
 
546
609
Branch history:
547
610
         0 revisions
548
611
 
571
634
        self.build_tree(['tree/lightcheckout/a'])
572
635
        tree2.add('a')
573
636
        tree2.commit('commit one')
574
 
        rev = repo.get_revision(branch2.revision_history()[0])
 
637
        rev = repo.get_revision(branch2.last_revision())
575
638
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
576
639
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
577
640
        self.assertEqualDiff(
587
650
        branch: %s
588
651
    repository: %s
589
652
 
 
653
Control directory:
 
654
         1 branches
 
655
 
590
656
In the working tree:
591
657
         1 unchanged
592
658
         0 modified
625
691
        branch: %s
626
692
    repository: %s
627
693
 
 
694
Control directory:
 
695
         1 branches
 
696
 
628
697
Branch is out of date: missing 1 revision.
629
698
 
630
699
In the working tree:
664
733
        branch: %s
665
734
    repository: %s
666
735
 
 
736
Control directory:
 
737
         1 branches
 
738
 
667
739
In the working tree:
668
740
         1 unchanged
669
741
         0 modified
690
762
        tree3.commit('commit two')
691
763
 
692
764
        # Out of date lightweight checkout
693
 
        rev = repo.get_revision(branch1.revision_history()[-1])
 
765
        rev = repo.get_revision(branch1.last_revision())
694
766
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
695
767
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
696
768
        self.assertEqualDiff(
706
778
        branch: %s
707
779
    repository: %s
708
780
 
 
781
Control directory:
 
782
         1 branches
 
783
 
709
784
Working tree is out of date: missing 1 revision.
710
785
 
711
786
In the working tree:
745
820
        branch: %s
746
821
    repository: %s
747
822
 
 
823
Control directory:
 
824
         1 branches
 
825
 
748
826
Branch history:
749
827
         2 revisions
750
828
         0 days old
770
848
       control: Meta directory format 1
771
849
    repository: %s
772
850
 
 
851
Control directory:
 
852
         0 branches
 
853
 
773
854
Repository:
774
855
         2 revisions
775
856
""" % (format.repository_format.get_format_description(),
793
874
       control: Meta directory format 1
794
875
    repository: %s
795
876
 
 
877
Control directory:
 
878
         0 branches
 
879
 
796
880
Create working tree for new branches inside the repository.
797
881
 
798
882
Repository:
803
887
 
804
888
        # Create two branches
805
889
        repo.bzrdir.root_transport.mkdir('branch1')
806
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
 
890
        branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
807
891
            format=format)
808
892
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
809
893
 
821
905
        branch: %s
822
906
    repository: %s
823
907
 
 
908
Control directory:
 
909
         1 branches
 
910
 
824
911
In the working tree:
825
912
         0 unchanged
826
913
         0 modified
846
933
        tree1 = branch1.bzrdir.open_workingtree()
847
934
        tree1.add('a')
848
935
        tree1.commit('commit one')
849
 
        rev = repo.get_revision(branch1.revision_history()[0])
 
936
        rev = repo.get_revision(branch1.last_revision())
850
937
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
851
938
        out, err = self.run_bzr('info -v repo/branch1')
852
939
        self.assertEqualDiff(
861
948
        branch: %s
862
949
    repository: %s
863
950
 
 
951
Control directory:
 
952
         1 branches
 
953
 
864
954
In the working tree:
865
955
         1 unchanged
866
956
         0 modified
902
992
        branch: %s
903
993
    repository: %s
904
994
 
 
995
Control directory:
 
996
         1 branches
 
997
 
905
998
In the working tree:
906
999
         0 unchanged
907
1000
         0 modified
941
1034
        branch: %s
942
1035
    repository: %s
943
1036
 
 
1037
Control directory:
 
1038
         1 branches
 
1039
 
944
1040
In the working tree:
945
1041
         1 unchanged
946
1042
         0 modified
976
1072
       control: Meta directory format 1
977
1073
    repository: %s
978
1074
 
 
1075
Control directory:
 
1076
         0 branches
 
1077
 
979
1078
Create working tree for new branches inside the repository.
980
1079
 
981
1080
Repository:
1002
1101
       control: Meta directory format 1
1003
1102
    repository: %s
1004
1103
 
 
1104
Control directory:
 
1105
         0 branches
 
1106
 
1005
1107
Create working tree for new branches inside the repository.
1006
1108
 
1007
1109
Repository:
1027
1129
        branch: %s
1028
1130
    repository: %s
1029
1131
 
 
1132
Control directory:
 
1133
         1 branches
 
1134
 
1030
1135
In the working tree:
1031
1136
         0 unchanged
1032
1137
         0 modified
1064
1169
       control: Meta directory format 1
1065
1170
    repository: %s
1066
1171
 
 
1172
Control directory:
 
1173
         0 branches
 
1174
 
1067
1175
Create working tree for new branches inside the repository.
1068
1176
 
1069
1177
Repository:
1073
1181
       ), out)
1074
1182
        self.assertEqual('', err)
1075
1183
 
 
1184
    def test_info_unshared_repository_with_colocated_branches(self):
 
1185
        format = bzrdir.format_registry.make_bzrdir('development-colo')
 
1186
        transport = self.get_transport()
 
1187
 
 
1188
        # Create unshared repository
 
1189
        repo = self.make_repository('repo', shared=False, format=format)
 
1190
        repo.set_make_working_trees(True)
 
1191
        repo.bzrdir.create_branch(name='foo')
 
1192
        out, err = self.run_bzr('info repo')
 
1193
        self.assertEqualDiff(
 
1194
"""Unshared repository with trees and colocated branches (format: development-colo)
 
1195
Location:
 
1196
  repository: repo
 
1197
""", out)
 
1198
        self.assertEqual('', err)
 
1199
 
1076
1200
    def assertCheckoutStatusOutput(self,
1077
1201
        command_string, lco_tree, shared_repo=None,
1078
1202
        repo_branch=None,
1187
1311
        branch: %s
1188
1312
    repository: %s
1189
1313
%s
 
1314
Control directory:
 
1315
         1 branches
 
1316
 
1190
1317
In the working tree:
1191
1318
         0 unchanged
1192
1319
         0 modified
1221
1348
                                    format=bzrdir.BzrDirMetaFormat1())
1222
1349
        repo.set_make_working_trees(False)
1223
1350
        repo.bzrdir.root_transport.mkdir('branch')
1224
 
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1225
 
                                    format=bzrdir.BzrDirMetaFormat1())
 
1351
        repo_branch = controldir.ControlDir.create_branch_convenience(
 
1352
            'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1226
1353
        # Do a heavy checkout
1227
1354
        transport.mkdir('tree')
1228
1355
        transport.mkdir('tree/checkout')
1229
 
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1230
 
            format=bzrdir.BzrDirMetaFormat1())
 
1356
        co_branch = controldir.ControlDir.create_branch_convenience(
 
1357
            'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1231
1358
        co_branch.bind(repo_branch)
1232
1359
        # Do a light checkout of the heavy one
1233
1360
        transport.mkdir('tree/lightcheckout')
1234
1361
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1235
 
        branch.BranchReferenceFormat().initialize(lco_dir,
1236
 
            target_branch=co_branch)
 
1362
        lco_dir.set_branch_reference(co_branch)
1237
1363
        lco_dir.create_workingtree()
1238
1364
        lco_tree = lco_dir.open_workingtree()
1239
1365
 
1345
1471
     stacked on: mainline
1346
1472
""", out)
1347
1473
        self.assertEqual("", err)
 
1474
 
 
1475
    def test_info_revinfo_optional(self):
 
1476
        tree = self.make_branch_and_tree('.')
 
1477
        def last_revision_info(self):
 
1478
            raise errors.UnsupportedOperation(last_revision_info, self)
 
1479
        self.overrideAttr(
 
1480
            branch.Branch, "last_revision_info", last_revision_info)
 
1481
        out, err = self.run_bzr('info -v .')
 
1482
        self.assertEqual(
 
1483
"""Standalone tree (format: 2a)
 
1484
Location:
 
1485
  branch root: .
 
1486
 
 
1487
Format:
 
1488
       control: Meta directory format 1
 
1489
  working tree: Working tree format 6
 
1490
        branch: Branch format 7
 
1491
    repository: Repository format 2a - rich roots, group compression and chk inventories
 
1492
 
 
1493
Control directory:
 
1494
         1 branches
 
1495
 
 
1496
In the working tree:
 
1497
         0 unchanged
 
1498
         0 modified
 
1499
         0 added
 
1500
         0 removed
 
1501
         0 renamed
 
1502
         0 unknown
 
1503
         0 ignored
 
1504
         0 versioned subdirectories
 
1505
""", out)
 
1506
        self.assertEqual("", err)
 
1507
 
 
1508
    def test_info_shows_colocated_branches(self):
 
1509
        bzrdir = self.make_branch('.', format='development-colo').bzrdir
 
1510
        bzrdir.create_branch(name="colo1")
 
1511
        bzrdir.create_branch(name="colo2")
 
1512
        bzrdir.create_branch(name="colo3")
 
1513
        out, err = self.run_bzr('info -v .')
 
1514
        self.assertEqualDiff(
 
1515
"""Standalone branch (format: development-colo)
 
1516
Location:
 
1517
  branch root: .
 
1518
 
 
1519
Format:
 
1520
       control: Meta directory format 1 with support for colocated branches
 
1521
        branch: Branch format 7
 
1522
    repository: Repository format 2a - rich roots, group compression and chk inventories
 
1523
 
 
1524
Control directory:
 
1525
         4 branches
 
1526
 
 
1527
Branch history:
 
1528
         0 revisions
 
1529
 
 
1530
Repository:
 
1531
         0 revisions
 
1532
""", out)
 
1533
        self.assertEqual("", err)
 
1534
 
 
1535
 
 
1536
class TestSmartServerInfo(tests.TestCaseWithTransport):
 
1537
 
 
1538
    def test_simple_branch_info(self):
 
1539
        self.setup_smart_server_with_call_log()
 
1540
        t = self.make_branch_and_tree('branch')
 
1541
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
1542
        t.add("foo")
 
1543
        t.commit("message")
 
1544
        self.reset_smart_call_log()
 
1545
        out, err = self.run_bzr(['info', self.get_url('branch')])
 
1546
        # This figure represent the amount of work to perform this use case. It
 
1547
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
1548
        # being too low. If rpc_count increases, more network roundtrips have
 
1549
        # become necessary for this use case. Please do not adjust this number
 
1550
        # upwards without agreement from bzr's network support maintainers.
 
1551
        self.assertLength(12, self.hpss_calls)
 
1552
        self.assertLength(1, self.hpss_connections)
 
1553
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
1554
 
 
1555
    def test_verbose_branch_info(self):
 
1556
        self.setup_smart_server_with_call_log()
 
1557
        t = self.make_branch_and_tree('branch')
 
1558
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
1559
        t.add("foo")
 
1560
        t.commit("message")
 
1561
        self.reset_smart_call_log()
 
1562
        out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
 
1563
        # This figure represent the amount of work to perform this use case. It
 
1564
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
1565
        # being too low. If rpc_count increases, more network roundtrips have
 
1566
        # become necessary for this use case. Please do not adjust this number
 
1567
        # upwards without agreement from bzr's network support maintainers.
 
1568
        self.assertLength(16, self.hpss_calls)
 
1569
        self.assertLength(1, self.hpss_connections)
 
1570
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)