~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: 2011-08-03 04:57:59 UTC
  • mfrom: (6042.1.2 fix-log-2)
  • Revision ID: pqm@pqm.ubuntu.com-20110803045759-1lrr8eymve8ofldr
(mbp) Log levels are no longer reset to what the log formatter supports (bug
 747958) (Thomi Richards)

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,
47
45
        self.assertEqual(out, '')
48
46
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
49
47
 
50
 
    def test_info_empty_controldir(self):
51
 
        self.make_bzrdir('ctrl')
52
 
        out, err = self.run_bzr('info ctrl')
53
 
        self.assertEquals(out,
54
 
            'Empty control directory (format: 2a or pack-0.92)\n'
55
 
            'Location:\n'
56
 
            '  control directory: ctrl\n')
57
 
        self.assertEquals(err, '')
58
 
 
59
 
    def test_info_dangling_branch_reference(self):
60
 
        br = self.make_branch('target')
61
 
        br.create_checkout('from', lightweight=True)
62
 
        shutil.rmtree('target')
63
 
        out, err = self.run_bzr('info from')
64
 
        self.assertEquals(out,
65
 
            'Dangling branch reference (format: 2a or pack-0.92)\n'
66
 
            'Location:\n'
67
 
            '   control directory: from\n'
68
 
            '  checkout of branch: target\n')
69
 
        self.assertEquals(err, '')
70
 
 
71
48
    def test_info_standalone(self):
72
49
        transport = self.get_transport()
73
50
 
148
125
""", out)
149
126
        self.assertEqual('', err)
150
127
        tree1.commit('commit one')
151
 
        rev = branch1.repository.get_revision(branch1.last_revision())
 
128
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
152
129
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
153
130
 
154
131
        # Branch standalone with push location
210
187
        branch1.bzrdir.sprout('bound')
211
188
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
212
189
        upgrade.upgrade('bound', knit1_format)
213
 
        branch3 = controldir.ControlDir.open('bound').open_branch()
 
190
        branch3 = bzrdir.BzrDir.open('bound').open_branch()
214
191
        branch3.bind(branch1)
215
192
        bound_tree = branch3.bzrdir.open_workingtree()
216
193
        out, err = self.run_bzr('info -v bound')
255
232
        self.assertEqual('', err)
256
233
 
257
234
        # Checkout standalone (same as above, but does not have parent set)
258
 
        branch4 = controldir.ControlDir.create_branch_convenience('checkout',
 
235
        branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
259
236
            format=knit1_format)
260
237
        branch4.bind(branch1)
261
238
        branch4.bzrdir.open_workingtree().update()
340
317
        self.build_tree(['standalone/b'])
341
318
        tree1.add('b')
342
319
        tree1.commit('commit two')
343
 
        rev = branch1.repository.get_revision(branch1.last_revision())
 
320
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
344
321
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
345
322
 
346
323
        # Out of date branched standalone branch will not be detected
552
529
 
553
530
        # Create branch inside shared repository
554
531
        repo.bzrdir.root_transport.mkdir('branch')
555
 
        branch1 = controldir.ControlDir.create_branch_convenience(
556
 
            'repo/branch', format=format)
 
532
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
 
533
            format=format)
557
534
        out, err = self.run_bzr('info -v repo/branch')
558
535
        self.assertEqualDiff(
559
536
"""Repository branch (format: dirstate or knit)
594
571
        self.build_tree(['tree/lightcheckout/a'])
595
572
        tree2.add('a')
596
573
        tree2.commit('commit one')
597
 
        rev = repo.get_revision(branch2.last_revision())
 
574
        rev = repo.get_revision(branch2.revision_history()[0])
598
575
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
599
576
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
600
577
        self.assertEqualDiff(
713
690
        tree3.commit('commit two')
714
691
 
715
692
        # Out of date lightweight checkout
716
 
        rev = repo.get_revision(branch1.last_revision())
 
693
        rev = repo.get_revision(branch1.revision_history()[-1])
717
694
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
718
695
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
719
696
        self.assertEqualDiff(
826
803
 
827
804
        # Create two branches
828
805
        repo.bzrdir.root_transport.mkdir('branch1')
829
 
        branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
 
806
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
830
807
            format=format)
831
808
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
832
809
 
869
846
        tree1 = branch1.bzrdir.open_workingtree()
870
847
        tree1.add('a')
871
848
        tree1.commit('commit one')
872
 
        rev = repo.get_revision(branch1.last_revision())
 
849
        rev = repo.get_revision(branch1.revision_history()[0])
873
850
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
874
851
        out, err = self.run_bzr('info -v repo/branch1')
875
852
        self.assertEqualDiff(
1244
1221
                                    format=bzrdir.BzrDirMetaFormat1())
1245
1222
        repo.set_make_working_trees(False)
1246
1223
        repo.bzrdir.root_transport.mkdir('branch')
1247
 
        repo_branch = controldir.ControlDir.create_branch_convenience(
1248
 
            'repo/branch', format=bzrdir.BzrDirMetaFormat1())
 
1224
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
 
1225
                                    format=bzrdir.BzrDirMetaFormat1())
1249
1226
        # Do a heavy checkout
1250
1227
        transport.mkdir('tree')
1251
1228
        transport.mkdir('tree/checkout')
1252
 
        co_branch = controldir.ControlDir.create_branch_convenience(
1253
 
            'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
 
1229
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
 
1230
            format=bzrdir.BzrDirMetaFormat1())
1254
1231
        co_branch.bind(repo_branch)
1255
1232
        # Do a light checkout of the heavy one
1256
1233
        transport.mkdir('tree/lightcheckout')
1368
1345
     stacked on: mainline
1369
1346
""", out)
1370
1347
        self.assertEqual("", err)
1371
 
 
1372
 
    def test_info_revinfo_optional(self):
1373
 
        tree = self.make_branch_and_tree('.')
1374
 
        def last_revision_info(self):
1375
 
            raise errors.UnsupportedOperation(last_revision_info, self)
1376
 
        self.overrideAttr(
1377
 
            branch.Branch, "last_revision_info", last_revision_info)
1378
 
        out, err = self.run_bzr('info -v .')
1379
 
        self.assertEqual(
1380
 
"""Standalone tree (format: 2a)
1381
 
Location:
1382
 
  branch root: .
1383
 
 
1384
 
Format:
1385
 
       control: Meta directory format 1
1386
 
  working tree: Working tree format 6
1387
 
        branch: Branch format 7
1388
 
    repository: Repository format 2a - rich roots, group compression and chk inventories
1389
 
 
1390
 
In the working tree:
1391
 
         0 unchanged
1392
 
         0 modified
1393
 
         0 added
1394
 
         0 removed
1395
 
         0 renamed
1396
 
         0 unknown
1397
 
         0 ignored
1398
 
         0 versioned subdirectories
1399
 
""", out)
1400
 
        self.assertEqual("", err)
1401
 
 
1402
 
    def test_info_shows_colocated_branches(self):
1403
 
        bzrdir = self.make_branch('.', format='development-colo').bzrdir
1404
 
        bzrdir.create_branch(name="colo1")
1405
 
        bzrdir.create_branch(name="colo2")
1406
 
        bzrdir.create_branch(name="colo3")
1407
 
        out, err = self.run_bzr('info -v .')
1408
 
        self.assertEqualDiff(
1409
 
"""Standalone branch (format: development-colo)
1410
 
Location:
1411
 
  branch root: .
1412
 
 
1413
 
Format:
1414
 
       control: Meta directory format 1 with support for colocated branches
1415
 
        branch: Branch format 7
1416
 
    repository: Repository format 2a - rich roots, group compression and chk inventories
1417
 
 
1418
 
Control directory:
1419
 
         4 branches
1420
 
 
1421
 
Branch history:
1422
 
         0 revisions
1423
 
 
1424
 
Repository:
1425
 
         0 revisions
1426
 
""", out)
1427
 
        self.assertEqual("", err)
1428
 
 
1429
 
 
1430
 
class TestSmartServerInfo(tests.TestCaseWithTransport):
1431
 
 
1432
 
    def test_simple_branch_info(self):
1433
 
        self.setup_smart_server_with_call_log()
1434
 
        t = self.make_branch_and_tree('branch')
1435
 
        self.build_tree_contents([('branch/foo', 'thecontents')])
1436
 
        t.add("foo")
1437
 
        t.commit("message")
1438
 
        self.reset_smart_call_log()
1439
 
        out, err = self.run_bzr(['info', self.get_url('branch')])
1440
 
        # This figure represent the amount of work to perform this use case. It
1441
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
1442
 
        # being too low. If rpc_count increases, more network roundtrips have
1443
 
        # become necessary for this use case. Please do not adjust this number
1444
 
        # upwards without agreement from bzr's network support maintainers.
1445
 
        self.assertLength(12, self.hpss_calls)
1446
 
 
1447
 
    def test_verbose_branch_info(self):
1448
 
        self.setup_smart_server_with_call_log()
1449
 
        t = self.make_branch_and_tree('branch')
1450
 
        self.build_tree_contents([('branch/foo', 'thecontents')])
1451
 
        t.add("foo")
1452
 
        t.commit("message")
1453
 
        self.reset_smart_call_log()
1454
 
        out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
1455
 
        # This figure represent the amount of work to perform this use case. It
1456
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
1457
 
        # being too low. If rpc_count increases, more network roundtrips have
1458
 
        # become necessary for this use case. Please do not adjust this number
1459
 
        # upwards without agreement from bzr's network support maintainers.
1460
 
        self.assertLength(16, self.hpss_calls)