~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-01-27 21:28:56 UTC
  • mto: This revision was merged to the branch mainline in revision 6460.
  • Revision ID: jelmer@samba.org-20120127212856-ewnjgn7fyblphcqw
Migrate mail_client to config stacks.

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
 
125
149
""", out)
126
150
        self.assertEqual('', err)
127
151
        tree1.commit('commit one')
128
 
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
 
152
        rev = branch1.repository.get_revision(branch1.last_revision())
129
153
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
130
154
 
131
155
        # Branch standalone with push location
187
211
        branch1.bzrdir.sprout('bound')
188
212
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
189
213
        upgrade.upgrade('bound', knit1_format)
190
 
        branch3 = bzrdir.BzrDir.open('bound').open_branch()
 
214
        branch3 = controldir.ControlDir.open('bound').open_branch()
191
215
        branch3.bind(branch1)
192
216
        bound_tree = branch3.bzrdir.open_workingtree()
193
217
        out, err = self.run_bzr('info -v bound')
232
256
        self.assertEqual('', err)
233
257
 
234
258
        # Checkout standalone (same as above, but does not have parent set)
235
 
        branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
 
259
        branch4 = controldir.ControlDir.create_branch_convenience('checkout',
236
260
            format=knit1_format)
237
261
        branch4.bind(branch1)
238
262
        branch4.bzrdir.open_workingtree().update()
317
341
        self.build_tree(['standalone/b'])
318
342
        tree1.add('b')
319
343
        tree1.commit('commit two')
320
 
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
 
344
        rev = branch1.repository.get_revision(branch1.last_revision())
321
345
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
322
346
 
323
347
        # Out of date branched standalone branch will not be detected
529
553
 
530
554
        # Create branch inside shared repository
531
555
        repo.bzrdir.root_transport.mkdir('branch')
532
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
533
 
            format=format)
 
556
        branch1 = controldir.ControlDir.create_branch_convenience(
 
557
            'repo/branch', format=format)
534
558
        out, err = self.run_bzr('info -v repo/branch')
535
559
        self.assertEqualDiff(
536
560
"""Repository branch (format: dirstate or knit)
571
595
        self.build_tree(['tree/lightcheckout/a'])
572
596
        tree2.add('a')
573
597
        tree2.commit('commit one')
574
 
        rev = repo.get_revision(branch2.revision_history()[0])
 
598
        rev = repo.get_revision(branch2.last_revision())
575
599
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
576
600
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
577
601
        self.assertEqualDiff(
690
714
        tree3.commit('commit two')
691
715
 
692
716
        # Out of date lightweight checkout
693
 
        rev = repo.get_revision(branch1.revision_history()[-1])
 
717
        rev = repo.get_revision(branch1.last_revision())
694
718
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
695
719
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
696
720
        self.assertEqualDiff(
803
827
 
804
828
        # Create two branches
805
829
        repo.bzrdir.root_transport.mkdir('branch1')
806
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
 
830
        branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
807
831
            format=format)
808
832
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
809
833
 
846
870
        tree1 = branch1.bzrdir.open_workingtree()
847
871
        tree1.add('a')
848
872
        tree1.commit('commit one')
849
 
        rev = repo.get_revision(branch1.revision_history()[0])
 
873
        rev = repo.get_revision(branch1.last_revision())
850
874
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
851
875
        out, err = self.run_bzr('info -v repo/branch1')
852
876
        self.assertEqualDiff(
1073
1097
       ), out)
1074
1098
        self.assertEqual('', err)
1075
1099
 
 
1100
    def test_info_unshared_repository_with_colocated_branches(self):
 
1101
        format = bzrdir.format_registry.make_bzrdir('development-colo')
 
1102
        transport = self.get_transport()
 
1103
 
 
1104
        # Create unshared repository
 
1105
        repo = self.make_repository('repo', shared=False, format=format)
 
1106
        repo.set_make_working_trees(True)
 
1107
        repo.bzrdir.create_branch(name='foo')
 
1108
        out, err = self.run_bzr('info repo')
 
1109
        self.assertEqualDiff(
 
1110
"""Unshared repository with trees and colocated branches (format: development-colo)
 
1111
Location:
 
1112
  repository: repo
 
1113
""", out)
 
1114
        self.assertEqual('', err)
 
1115
 
1076
1116
    def assertCheckoutStatusOutput(self,
1077
1117
        command_string, lco_tree, shared_repo=None,
1078
1118
        repo_branch=None,
1221
1261
                                    format=bzrdir.BzrDirMetaFormat1())
1222
1262
        repo.set_make_working_trees(False)
1223
1263
        repo.bzrdir.root_transport.mkdir('branch')
1224
 
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1225
 
                                    format=bzrdir.BzrDirMetaFormat1())
 
1264
        repo_branch = controldir.ControlDir.create_branch_convenience(
 
1265
            'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1226
1266
        # Do a heavy checkout
1227
1267
        transport.mkdir('tree')
1228
1268
        transport.mkdir('tree/checkout')
1229
 
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1230
 
            format=bzrdir.BzrDirMetaFormat1())
 
1269
        co_branch = controldir.ControlDir.create_branch_convenience(
 
1270
            'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1231
1271
        co_branch.bind(repo_branch)
1232
1272
        # Do a light checkout of the heavy one
1233
1273
        transport.mkdir('tree/lightcheckout')
1234
1274
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1235
 
        branch.BranchReferenceFormat().initialize(lco_dir,
1236
 
            target_branch=co_branch)
 
1275
        lco_dir.set_branch_reference(co_branch)
1237
1276
        lco_dir.create_workingtree()
1238
1277
        lco_tree = lco_dir.open_workingtree()
1239
1278
 
1345
1384
     stacked on: mainline
1346
1385
""", out)
1347
1386
        self.assertEqual("", err)
 
1387
 
 
1388
    def test_info_revinfo_optional(self):
 
1389
        tree = self.make_branch_and_tree('.')
 
1390
        def last_revision_info(self):
 
1391
            raise errors.UnsupportedOperation(last_revision_info, self)
 
1392
        self.overrideAttr(
 
1393
            branch.Branch, "last_revision_info", last_revision_info)
 
1394
        out, err = self.run_bzr('info -v .')
 
1395
        self.assertEqual(
 
1396
"""Standalone tree (format: 2a)
 
1397
Location:
 
1398
  branch root: .
 
1399
 
 
1400
Format:
 
1401
       control: Meta directory format 1
 
1402
  working tree: Working tree format 6
 
1403
        branch: Branch format 7
 
1404
    repository: Repository format 2a - rich roots, group compression and chk inventories
 
1405
 
 
1406
In the working tree:
 
1407
         0 unchanged
 
1408
         0 modified
 
1409
         0 added
 
1410
         0 removed
 
1411
         0 renamed
 
1412
         0 unknown
 
1413
         0 ignored
 
1414
         0 versioned subdirectories
 
1415
""", out)
 
1416
        self.assertEqual("", err)
 
1417
 
 
1418
    def test_info_shows_colocated_branches(self):
 
1419
        bzrdir = self.make_branch('.', format='development-colo').bzrdir
 
1420
        bzrdir.create_branch(name="colo1")
 
1421
        bzrdir.create_branch(name="colo2")
 
1422
        bzrdir.create_branch(name="colo3")
 
1423
        out, err = self.run_bzr('info -v .')
 
1424
        self.assertEqualDiff(
 
1425
"""Standalone branch (format: development-colo)
 
1426
Location:
 
1427
  branch root: .
 
1428
 
 
1429
Format:
 
1430
       control: Meta directory format 1 with support for colocated branches
 
1431
        branch: Branch format 7
 
1432
    repository: Repository format 2a - rich roots, group compression and chk inventories
 
1433
 
 
1434
Control directory:
 
1435
         4 branches
 
1436
 
 
1437
Branch history:
 
1438
         0 revisions
 
1439
 
 
1440
Repository:
 
1441
         0 revisions
 
1442
""", out)
 
1443
        self.assertEqual("", err)
 
1444
 
 
1445
 
 
1446
class TestSmartServerInfo(tests.TestCaseWithTransport):
 
1447
 
 
1448
    def test_simple_branch_info(self):
 
1449
        self.setup_smart_server_with_call_log()
 
1450
        t = self.make_branch_and_tree('branch')
 
1451
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
1452
        t.add("foo")
 
1453
        t.commit("message")
 
1454
        self.reset_smart_call_log()
 
1455
        out, err = self.run_bzr(['info', self.get_url('branch')])
 
1456
        # This figure represent the amount of work to perform this use case. It
 
1457
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
1458
        # being too low. If rpc_count increases, more network roundtrips have
 
1459
        # become necessary for this use case. Please do not adjust this number
 
1460
        # upwards without agreement from bzr's network support maintainers.
 
1461
        self.assertLength(12, self.hpss_calls)
 
1462
        self.assertLength(1, self.hpss_connections)
 
1463
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
1464
 
 
1465
    def test_verbose_branch_info(self):
 
1466
        self.setup_smart_server_with_call_log()
 
1467
        t = self.make_branch_and_tree('branch')
 
1468
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
1469
        t.add("foo")
 
1470
        t.commit("message")
 
1471
        self.reset_smart_call_log()
 
1472
        out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
 
1473
        # This figure represent the amount of work to perform this use case. It
 
1474
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
1475
        # being too low. If rpc_count increases, more network roundtrips have
 
1476
        # become necessary for this use case. Please do not adjust this number
 
1477
        # upwards without agreement from bzr's network support maintainers.
 
1478
        self.assertLength(16, self.hpss_calls)
 
1479
        self.assertLength(1, self.hpss_connections)
 
1480
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)