~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Samuel Bronson
  • Date: 2012-08-30 20:36:18 UTC
  • mto: (6015.57.3 2.4)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: naesten@gmail.com-20120830203618-y2dzw91nqpvpgxvx
Update INSTALL for switch to Python 2.6 and up.

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
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_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
 
 
72
48
    def test_info_standalone(self):
73
49
        transport = self.get_transport()
74
50
 
99
75
        branch: Branch format 5
100
76
    repository: Knit repository format 1
101
77
 
102
 
Control directory:
103
 
         1 branches
104
 
 
105
78
In the working tree:
106
79
         0 unchanged
107
80
         0 modified
133
106
        branch: Branch format 5
134
107
    repository: Knit repository format 1
135
108
 
136
 
Control directory:
137
 
         1 branches
138
 
 
139
109
In the working tree:
140
110
         0 unchanged
141
111
         0 modified
155
125
""", out)
156
126
        self.assertEqual('', err)
157
127
        tree1.commit('commit one')
158
 
        rev = branch1.repository.get_revision(branch1.last_revision())
 
128
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
159
129
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
160
130
 
161
131
        # Branch standalone with push location
190
160
        branch: Branch format 5
191
161
    repository: Knit repository format 1
192
162
 
193
 
Control directory:
194
 
         1 branches
195
 
 
196
163
In the working tree:
197
164
         1 unchanged
198
165
         0 modified
220
187
        branch1.bzrdir.sprout('bound')
221
188
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
222
189
        upgrade.upgrade('bound', knit1_format)
223
 
        branch3 = controldir.ControlDir.open('bound').open_branch()
 
190
        branch3 = bzrdir.BzrDir.open('bound').open_branch()
224
191
        branch3.bind(branch1)
225
192
        bound_tree = branch3.bzrdir.open_workingtree()
226
193
        out, err = self.run_bzr('info -v bound')
239
206
        branch: %s
240
207
    repository: %s
241
208
 
242
 
Control directory:
243
 
         1 branches
244
 
 
245
209
In the working tree:
246
210
         1 unchanged
247
211
         0 modified
268
232
        self.assertEqual('', err)
269
233
 
270
234
        # Checkout standalone (same as above, but does not have parent set)
271
 
        branch4 = controldir.ControlDir.create_branch_convenience('checkout',
 
235
        branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
272
236
            format=knit1_format)
273
237
        branch4.bind(branch1)
274
238
        branch4.bzrdir.open_workingtree().update()
285
249
        branch: Branch format 5
286
250
    repository: %s
287
251
 
288
 
Control directory:
289
 
         1 branches
290
 
 
291
252
In the working tree:
292
253
         1 unchanged
293
254
         0 modified
331
292
        branch: Branch format 5
332
293
    repository: Knit repository format 1
333
294
 
334
 
Control directory:
335
 
         1 branches
336
 
 
337
295
In the working tree:
338
296
         1 unchanged
339
297
         0 modified
359
317
        self.build_tree(['standalone/b'])
360
318
        tree1.add('b')
361
319
        tree1.commit('commit two')
362
 
        rev = branch1.repository.get_revision(branch1.last_revision())
 
320
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
363
321
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
364
322
 
365
323
        # Out of date branched standalone branch will not be detected
379
337
        branch: Branch format 5
380
338
    repository: Knit repository format 1
381
339
 
382
 
Control directory:
383
 
         1 branches
384
 
 
385
340
In the working tree:
386
341
         1 unchanged
387
342
         0 modified
421
376
        branch: Branch format 5
422
377
    repository: %s
423
378
 
424
 
Control directory:
425
 
         1 branches
426
 
 
427
379
Branch is out of date: missing 1 revision.
428
380
 
429
381
In the working tree:
463
415
        branch: Branch format 5
464
416
    repository: %s
465
417
 
466
 
Control directory:
467
 
         1 branches
468
 
 
469
418
Branch is out of date: missing 1 revision.
470
419
 
471
420
In the working tree:
505
454
        branch: Branch format 5
506
455
    repository: Knit repository format 1
507
456
 
508
 
Control directory:
509
 
         1 branches
510
 
 
511
457
Working tree is out of date: missing 1 revision.
512
458
 
513
459
In the working tree:
547
493
        branch: %s
548
494
    repository: %s
549
495
 
550
 
Control directory:
551
 
         1 branches
552
 
 
553
496
Branch history:
554
497
         0 revisions
555
498
 
578
521
       control: Meta directory format 1
579
522
    repository: %s
580
523
 
581
 
Control directory:
582
 
         0 branches
583
 
 
584
524
Repository:
585
525
         0 revisions
586
526
""" % ('repo', format.repository_format.get_format_description(),
589
529
 
590
530
        # Create branch inside shared repository
591
531
        repo.bzrdir.root_transport.mkdir('branch')
592
 
        branch1 = controldir.ControlDir.create_branch_convenience(
593
 
            'repo/branch', format=format)
 
532
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
 
533
            format=format)
594
534
        out, err = self.run_bzr('info -v repo/branch')
595
535
        self.assertEqualDiff(
596
536
"""Repository branch (format: dirstate or knit)
603
543
        branch: %s
604
544
    repository: %s
605
545
 
606
 
Control directory:
607
 
         1 branches
608
 
 
609
546
Branch history:
610
547
         0 revisions
611
548
 
634
571
        self.build_tree(['tree/lightcheckout/a'])
635
572
        tree2.add('a')
636
573
        tree2.commit('commit one')
637
 
        rev = repo.get_revision(branch2.last_revision())
 
574
        rev = repo.get_revision(branch2.revision_history()[0])
638
575
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
639
576
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
640
577
        self.assertEqualDiff(
650
587
        branch: %s
651
588
    repository: %s
652
589
 
653
 
Control directory:
654
 
         1 branches
655
 
 
656
590
In the working tree:
657
591
         1 unchanged
658
592
         0 modified
691
625
        branch: %s
692
626
    repository: %s
693
627
 
694
 
Control directory:
695
 
         1 branches
696
 
 
697
628
Branch is out of date: missing 1 revision.
698
629
 
699
630
In the working tree:
733
664
        branch: %s
734
665
    repository: %s
735
666
 
736
 
Control directory:
737
 
         1 branches
738
 
 
739
667
In the working tree:
740
668
         1 unchanged
741
669
         0 modified
762
690
        tree3.commit('commit two')
763
691
 
764
692
        # Out of date lightweight checkout
765
 
        rev = repo.get_revision(branch1.last_revision())
 
693
        rev = repo.get_revision(branch1.revision_history()[-1])
766
694
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
767
695
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
768
696
        self.assertEqualDiff(
778
706
        branch: %s
779
707
    repository: %s
780
708
 
781
 
Control directory:
782
 
         1 branches
783
 
 
784
709
Working tree is out of date: missing 1 revision.
785
710
 
786
711
In the working tree:
820
745
        branch: %s
821
746
    repository: %s
822
747
 
823
 
Control directory:
824
 
         1 branches
825
 
 
826
748
Branch history:
827
749
         2 revisions
828
750
         0 days old
848
770
       control: Meta directory format 1
849
771
    repository: %s
850
772
 
851
 
Control directory:
852
 
         0 branches
853
 
 
854
773
Repository:
855
774
         2 revisions
856
775
""" % (format.repository_format.get_format_description(),
874
793
       control: Meta directory format 1
875
794
    repository: %s
876
795
 
877
 
Control directory:
878
 
         0 branches
879
 
 
880
796
Create working tree for new branches inside the repository.
881
797
 
882
798
Repository:
887
803
 
888
804
        # Create two branches
889
805
        repo.bzrdir.root_transport.mkdir('branch1')
890
 
        branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
 
806
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
891
807
            format=format)
892
808
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
893
809
 
905
821
        branch: %s
906
822
    repository: %s
907
823
 
908
 
Control directory:
909
 
         1 branches
910
 
 
911
824
In the working tree:
912
825
         0 unchanged
913
826
         0 modified
933
846
        tree1 = branch1.bzrdir.open_workingtree()
934
847
        tree1.add('a')
935
848
        tree1.commit('commit one')
936
 
        rev = repo.get_revision(branch1.last_revision())
 
849
        rev = repo.get_revision(branch1.revision_history()[0])
937
850
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
938
851
        out, err = self.run_bzr('info -v repo/branch1')
939
852
        self.assertEqualDiff(
948
861
        branch: %s
949
862
    repository: %s
950
863
 
951
 
Control directory:
952
 
         1 branches
953
 
 
954
864
In the working tree:
955
865
         1 unchanged
956
866
         0 modified
992
902
        branch: %s
993
903
    repository: %s
994
904
 
995
 
Control directory:
996
 
         1 branches
997
 
 
998
905
In the working tree:
999
906
         0 unchanged
1000
907
         0 modified
1034
941
        branch: %s
1035
942
    repository: %s
1036
943
 
1037
 
Control directory:
1038
 
         1 branches
1039
 
 
1040
944
In the working tree:
1041
945
         1 unchanged
1042
946
         0 modified
1072
976
       control: Meta directory format 1
1073
977
    repository: %s
1074
978
 
1075
 
Control directory:
1076
 
         0 branches
1077
 
 
1078
979
Create working tree for new branches inside the repository.
1079
980
 
1080
981
Repository:
1101
1002
       control: Meta directory format 1
1102
1003
    repository: %s
1103
1004
 
1104
 
Control directory:
1105
 
         0 branches
1106
 
 
1107
1005
Create working tree for new branches inside the repository.
1108
1006
 
1109
1007
Repository:
1129
1027
        branch: %s
1130
1028
    repository: %s
1131
1029
 
1132
 
Control directory:
1133
 
         1 branches
1134
 
 
1135
1030
In the working tree:
1136
1031
         0 unchanged
1137
1032
         0 modified
1169
1064
       control: Meta directory format 1
1170
1065
    repository: %s
1171
1066
 
1172
 
Control directory:
1173
 
         0 branches
1174
 
 
1175
1067
Create working tree for new branches inside the repository.
1176
1068
 
1177
1069
Repository:
1181
1073
       ), out)
1182
1074
        self.assertEqual('', err)
1183
1075
 
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
 
 
1200
1076
    def assertCheckoutStatusOutput(self,
1201
1077
        command_string, lco_tree, shared_repo=None,
1202
1078
        repo_branch=None,
1311
1187
        branch: %s
1312
1188
    repository: %s
1313
1189
%s
1314
 
Control directory:
1315
 
         1 branches
1316
 
 
1317
1190
In the working tree:
1318
1191
         0 unchanged
1319
1192
         0 modified
1348
1221
                                    format=bzrdir.BzrDirMetaFormat1())
1349
1222
        repo.set_make_working_trees(False)
1350
1223
        repo.bzrdir.root_transport.mkdir('branch')
1351
 
        repo_branch = controldir.ControlDir.create_branch_convenience(
1352
 
            'repo/branch', format=bzrdir.BzrDirMetaFormat1())
 
1224
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
 
1225
                                    format=bzrdir.BzrDirMetaFormat1())
1353
1226
        # Do a heavy checkout
1354
1227
        transport.mkdir('tree')
1355
1228
        transport.mkdir('tree/checkout')
1356
 
        co_branch = controldir.ControlDir.create_branch_convenience(
1357
 
            'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
 
1229
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
 
1230
            format=bzrdir.BzrDirMetaFormat1())
1358
1231
        co_branch.bind(repo_branch)
1359
1232
        # Do a light checkout of the heavy one
1360
1233
        transport.mkdir('tree/lightcheckout')
1361
1234
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1362
 
        lco_dir.set_branch_reference(co_branch)
 
1235
        branch.BranchReferenceFormat().initialize(lco_dir,
 
1236
            target_branch=co_branch)
1363
1237
        lco_dir.create_workingtree()
1364
1238
        lco_tree = lco_dir.open_workingtree()
1365
1239
 
1471
1345
     stacked on: mainline
1472
1346
""", out)
1473
1347
        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)