41
46
def test_info_non_existing(self):
42
47
self.vfs_transport_factory = memory.MemoryServer
43
48
location = self.get_url()
44
out, err = self.run_bzr('info '+location, retcode=3)
49
out, err = self.run_bzr('info ' + location, retcode=3)
45
50
self.assertEqual(out, '')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
51
self.assertEqual(err, 'brz: ERROR: Not a branch: "%s".\n' % location)
53
def test_info_empty_controldir(self):
54
self.make_controldir('ctrl')
55
out, err = self.run_bzr('info ctrl')
57
'Empty control directory (format: 2a)\n'
59
' control directory: ctrl\n')
60
self.assertEqual(err, '')
62
def test_info_empty_controldir_verbose(self):
63
self.make_controldir('ctrl')
64
out, err = self.run_bzr('info -v ctrl')
65
self.assertEqualDiff(out,
66
'Empty control directory (format: 2a)\n'
68
' control directory: ctrl\n\n'
70
' control: Meta directory format 1\n\n'
71
'Control directory:\n'
73
self.assertEqual(err, '')
75
def test_info_dangling_branch_reference(self):
76
br = self.make_branch('target')
77
br.create_checkout('from', lightweight=True)
78
shutil.rmtree('target')
79
out, err = self.run_bzr('info from')
81
'Dangling branch reference (format: 2a)\n'
83
' control directory: from\n'
84
' checkout of branch: target\n')
85
self.assertEqual(err, '')
87
def test_info_colocated(self):
88
br = self.make_branch_and_tree('target', format='development-colo')
89
target = br.controldir.create_branch(name='dichtbij')
90
br.controldir.set_branch_reference(target)
91
out, err = self.run_bzr('info target')
93
'Standalone tree (format: development-colo)\n'
95
' light checkout root: target\n'
96
' checkout of co-located branch: dichtbij\n')
97
self.assertEqual(err, '')
48
99
def test_info_standalone(self):
49
100
transport = self.get_transport()
51
102
# Create initial standalone branch
52
tree1 = self.make_branch_and_tree('standalone', 'weave')
103
tree1 = self.make_branch_and_tree('standalone', 'knit')
53
104
self.build_tree(['standalone/a'])
55
106
branch1 = tree1.branch
57
108
out, err = self.run_bzr('info standalone')
58
109
self.assertEqualDiff(
59
"""Standalone tree (format: weave)
110
"""Standalone tree (format: knit)
61
112
branch root: standalone
227
294
""" % (bound_tree._format.get_format_description(),
228
branch3._format.get_format_description(),
229
branch3.repository._format.get_format_description(),
230
datestring_first, datestring_first,
295
branch3._format.get_format_description(),
296
branch3.repository._format.get_format_description(),
297
datestring_first, datestring_first,
232
299
self.assertEqual('', err)
234
301
# Checkout standalone (same as above, but does not have parent set)
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
302
branch4 = controldir.ControlDir.create_branch_convenience('checkout',
237
304
branch4.bind(branch1)
238
branch4.bzrdir.open_workingtree().update()
305
branch4.controldir.open_workingtree().update()
239
306
out, err = self.run_bzr('info checkout --verbose')
240
307
self.assertEqualDiff(
241
"""Checkout (format: knit)
308
"""Checkout (format: knit)
243
310
checkout root: checkout
244
311
checkout of branch: standalone
434
525
""" % (branch4.repository._format.get_format_description(),
435
datestring_first, datestring_first,
526
datestring_first, datestring_first,
437
528
self.assertEqual('', err)
439
530
# Out of date lightweight checkout
440
531
out, err = self.run_bzr('info lightcheckout --verbose')
441
532
self.assertEqualDiff(
442
"""Lightweight checkout (format: %s)
533
"""Lightweight checkout (format: %s)
444
535
light checkout root: lightcheckout
445
536
checkout of branch: standalone
448
539
control: Meta directory format 1
449
working tree: Working tree format 6
450
branch: Branch format 4
451
repository: Weave repository format 6
540
working tree: Working tree format 3
541
branch: Branch format 5
542
repository: Knit repository format 1
453
547
Working tree is out of date: missing 1 revision.
553
657
transport.mkdir('tree')
554
658
transport.mkdir('tree/lightcheckout')
555
659
tree2 = branch1.create_checkout('tree/lightcheckout',
557
661
branch2 = tree2.branch
558
662
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
559
shared_repo=repo, repo_branch=branch1, verbose=True)
663
shared_repo=repo, repo_branch=branch1, verbose=True)
561
665
# Create normal checkout
562
666
tree3 = branch1.create_checkout('tree/checkout')
563
667
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
565
light_checkout=False, repo_branch=branch1)
669
light_checkout=False, repo_branch=branch1)
566
670
# Update lightweight checkout
567
671
self.build_tree(['tree/lightcheckout/a'])
569
673
tree2.commit('commit one')
570
rev = repo.get_revision(branch2.revision_history()[0])
674
rev = repo.get_revision(branch2.last_revision())
571
675
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
572
676
out, err = self.run_bzr('info tree/lightcheckout --verbose')
573
677
self.assertEqualDiff(
574
"""Lightweight checkout (format: %s)
678
"""Lightweight checkout (format: %s)
576
680
light checkout root: tree/lightcheckout
577
681
checkout of branch: repo/branch
681
797
""" % (format.get_branch_format().get_format_description(),
682
format.repository_format.get_format_description(),
683
datestring_first, datestring_first,
798
format.repository_format.get_format_description(),
799
datestring_first, datestring_first,
685
801
self.assertEqual('', err)
686
802
tree3.commit('commit two')
688
804
# Out of date lightweight checkout
689
rev = repo.get_revision(branch1.revision_history()[-1])
805
rev = repo.get_revision(branch1.last_revision())
690
806
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
691
807
out, err = self.run_bzr('info tree/lightcheckout --verbose')
692
808
self.assertEqualDiff(
693
"""Lightweight checkout (format: %s)
809
"""Lightweight checkout (format: %s)
695
811
light checkout root: tree/lightcheckout
696
812
checkout of branch: repo/branch
1041
1196
""" % (format.get_branch_format().get_format_description(),
1042
format.repository_format.get_format_description(),
1197
format.repository_format.get_format_description(),
1044
1199
self.assertEqual('', err)
1046
1201
def test_info_repository_hook(self):
1047
format = bzrdir.format_registry.make_bzrdir('knit')
1202
format = controldir.format_registry.make_controldir('knit')
1048
1204
def repo_info(repo, stats, outf):
1049
outf.write("more info\n")
1205
outf.write(u"more info\n")
1050
1206
info.hooks.install_named_hook('repository', repo_info, None)
1051
1207
# Create shared repository with working trees
1052
1208
repo = self.make_repository('repo', shared=True, format=format)
1053
1209
out, err = self.run_bzr('info -v repo')
1054
1210
self.assertEqualDiff(
1055
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1211
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1057
1213
shared repository: repo
1070
1229
self.assertEqual('', err)
1231
def test_info_unshared_repository_with_colocated_branches(self):
1232
format = controldir.format_registry.make_controldir('development-colo')
1233
transport = self.get_transport()
1235
# Create unshared repository
1236
repo = self.make_repository('repo', shared=False, format=format)
1237
repo.set_make_working_trees(True)
1238
repo.controldir.create_branch(name='foo')
1239
out, err = self.run_bzr('info repo')
1240
self.assertEqualDiff(
1241
"""Unshared repository with trees and colocated branches (format: development-colo)
1245
self.assertEqual('', err)
1072
1247
def assertCheckoutStatusOutput(self,
1073
command_string, lco_tree, shared_repo=None,
1076
branch_locked=False, repo_locked=False,
1078
light_checkout=True,
1079
checkout_root=None):
1248
command_string, lco_tree, shared_repo=None,
1251
branch_locked=False, repo_locked=False,
1253
light_checkout=True,
1254
checkout_root=None):
1080
1255
"""Check the output of info in a checkout.
1082
1257
This is not quite a mirror of the info code: rather than using the
1148
1323
extra_space = ''
1149
1324
if light_checkout:
1150
1325
tree_data = (" light checkout root: %s\n" %
1151
friendly_location(lco_tree.bzrdir.root_transport.base))
1326
friendly_location(lco_tree.controldir.root_transport.base))
1152
1327
extra_space = ' '
1153
1328
if lco_tree.branch.get_bound_location() is not None:
1154
1329
tree_data += ("%s checkout root: %s\n" % (extra_space,
1155
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1330
friendly_location(lco_tree.branch.controldir.root_transport.base)))
1156
1331
if shared_repo is not None:
1157
1332
branch_data = (
1158
1333
" checkout of branch: %s\n"
1159
1334
" shared repository: %s\n" %
1160
(friendly_location(repo_branch.bzrdir.root_transport.base),
1161
friendly_location(shared_repo.bzrdir.root_transport.base)))
1335
(friendly_location(repo_branch.controldir.root_transport.base),
1336
friendly_location(shared_repo.controldir.root_transport.base)))
1162
1337
elif repo_branch is not None:
1163
1338
branch_data = (
1164
1339
"%s checkout of branch: %s\n" %
1166
friendly_location(repo_branch.bzrdir.root_transport.base)))
1341
friendly_location(repo_branch.controldir.root_transport.base)))
1168
1343
branch_data = (" checkout of branch: %s\n" %
1169
lco_tree.branch.bzrdir.root_transport.base)
1344
lco_tree.branch.controldir.root_transport.base)
1171
1346
if verbose >= 2:
1172
1347
verbose_info = ' 0 committers\n'
1216
1395
repo = self.make_repository('repo', shared=True,
1217
1396
format=bzrdir.BzrDirMetaFormat1())
1218
1397
repo.set_make_working_trees(False)
1219
repo.bzrdir.root_transport.mkdir('branch')
1220
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1221
format=bzrdir.BzrDirMetaFormat1())
1398
repo.controldir.root_transport.mkdir('branch')
1399
repo_branch = controldir.ControlDir.create_branch_convenience(
1400
'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1222
1401
# Do a heavy checkout
1223
1402
transport.mkdir('tree')
1224
1403
transport.mkdir('tree/checkout')
1225
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
format=bzrdir.BzrDirMetaFormat1())
1404
co_branch = controldir.ControlDir.create_branch_convenience(
1405
'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1227
1406
co_branch.bind(repo_branch)
1228
1407
# Do a light checkout of the heavy one
1229
1408
transport.mkdir('tree/lightcheckout')
1230
1409
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1231
branch.BranchReferenceFormat().initialize(lco_dir,
1232
target_branch=co_branch)
1410
lco_dir.set_branch_reference(co_branch)
1233
1411
lco_dir.create_workingtree()
1234
1412
lco_tree = lco_dir.open_workingtree()
1241
1419
repo_branch=repo_branch,
1242
1420
verbose=True, light_checkout=True)
1244
lco_tree.branch.repository.lock_write()
1422
with lco_tree.branch.repository.lock_write():
1246
1423
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1247
lco_tree, repo_branch=repo_branch,
1248
repo_locked=True, verbose=True, light_checkout=True)
1250
lco_tree.branch.repository.unlock()
1424
lco_tree, repo_branch=repo_branch,
1425
repo_locked=True, verbose=True, light_checkout=True)
1252
lco_tree.branch.lock_write()
1427
with lco_tree.branch.lock_write():
1254
1428
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1258
repo_branch=repo_branch,
1261
lco_tree.branch.unlock()
1432
repo_branch=repo_branch,
1263
lco_tree.lock_write()
1435
with lco_tree.lock_write():
1265
1436
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1266
lco_tree, repo_branch=repo_branch,
1437
lco_tree, repo_branch=repo_branch,
1274
lco_tree.lock_write()
1275
lco_tree.branch.repository.unlock()
1443
with lco_tree.lock_write(), lco_tree.branch.repository.unlock():
1277
1444
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1278
lco_tree, repo_branch=repo_branch,
1283
lco_tree.branch.repository.lock_write()
1445
lco_tree, repo_branch=repo_branch,
1286
lco_tree.lock_write()
1287
lco_tree.branch.unlock()
1450
with lco_tree.lock_write(), lco_tree.branch.unlock():
1289
1451
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1290
lco_tree, repo_branch=repo_branch,
1294
lco_tree.branch.lock_write()
1452
lco_tree, repo_branch=repo_branch,
1297
lco_tree.lock_write()
1298
lco_tree.branch.unlock()
1299
lco_tree.branch.repository.lock_write()
1456
with lco_tree.lock_write(), lco_tree.branch.unlock(), \
1457
lco_tree.branch.repository.lock_write():
1301
1458
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1302
lco_tree, repo_branch=repo_branch,
1307
lco_tree.branch.repository.unlock()
1308
lco_tree.branch.lock_write()
1459
lco_tree, repo_branch=repo_branch,
1311
lco_tree.branch.lock_write()
1312
lco_tree.branch.repository.unlock()
1464
with lco_tree.branch.lock_write(), lco_tree.branch.repository.unlock():
1314
1465
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1315
lco_tree, repo_branch=repo_branch,
1319
lco_tree.branch.repository.lock_write()
1320
lco_tree.branch.unlock()
1466
lco_tree, repo_branch=repo_branch,
1322
1470
if sys.platform == 'win32':
1323
self.knownFailure('Win32 cannot run "bzr info"'
1471
self.knownFailure('Win32 cannot run "brz info"'
1324
1472
' when the tree is locked.')
1326
def test_info_locking_oslocks(self):
1327
if sys.platform == "win32":
1328
self.skip("don't use oslocks on win32 in unix manner")
1329
# This test tests old (all-in-one, OS lock using) behaviour which
1330
# simply cannot work on windows (and is indeed why we changed our
1331
# design. As such, don't try to remove the thisFailsStrictLockCheck
1333
self.thisFailsStrictLockCheck()
1335
tree = self.make_branch_and_tree('branch',
1336
format=bzrdir.BzrDirFormat6())
1338
# Test all permutations of locking the working tree, branch and repository
1339
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1340
# implemented by raising NotImplementedError and get_physical_lock_status()
1341
# always returns false. This makes bzr info hide the lock status. (Olaf)
1345
out, err = self.run_bzr('info -v branch')
1346
self.assertEqualDiff(
1347
"""Standalone tree (format: weave)
1352
control: All-in-one format 6
1353
working tree: Working tree format 2
1354
branch: Branch format 4
1357
In the working tree:
1365
0 versioned subdirectories
1372
""" % ('branch', tree.branch.repository._format.get_format_description(),
1374
self.assertEqual('', err)
1377
out, err = self.run_bzr('info -v branch')
1378
self.assertEqualDiff(
1379
"""Standalone tree (format: weave)
1384
control: All-in-one format 6
1385
working tree: Working tree format 2
1386
branch: Branch format 4
1389
In the working tree:
1397
0 versioned subdirectories
1404
""" % ('branch', tree.branch.repository._format.get_format_description(),
1406
self.assertEqual('', err)
1409
1474
def test_info_stacked(self):
1410
1475
# We have a mainline
1411
1476
trunk_tree = self.make_branch_and_tree('mainline',
1413
1478
trunk_tree.commit('mainline')
1414
1479
# and a branch from it which is stacked
1415
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1480
new_dir = trunk_tree.controldir.sprout('newbranch', stacked=True)
1416
1481
out, err = self.run_bzr('info newbranch')
1417
1482
self.assertEqual(
1418
"""Standalone tree (format: 1.6)
1483
"""Standalone tree (format: 1.6)
1420
1485
branch root: newbranch
1424
1489
stacked on: mainline
1426
1491
self.assertEqual("", err)
1493
def test_info_revinfo_optional(self):
1494
tree = self.make_branch_and_tree('.')
1496
def last_revision_info(self):
1497
raise errors.UnsupportedOperation(last_revision_info, self)
1499
branch.Branch, "last_revision_info", last_revision_info)
1500
out, err = self.run_bzr('info -v .')
1502
"""Standalone tree (format: 2a)
1507
control: Meta directory format 1
1508
working tree: Working tree format 6
1509
branch: Branch format 7
1510
repository: Repository format 2a - rich roots, group compression and chk inventories
1515
In the working tree:
1524
0 versioned subdirectories
1526
self.assertEqual("", err)
1528
def test_info_shows_colocated_branches(self):
1529
bzrdir = self.make_branch('.', format='development-colo').controldir
1530
bzrdir.create_branch(name="colo1")
1531
bzrdir.create_branch(name="colo2")
1532
bzrdir.create_branch(name="colo3")
1533
out, err = self.run_bzr('info -v .')
1534
self.assertEqualDiff(
1535
"""Standalone branch (format: development-colo)
1540
control: Meta directory format 1 with support for colocated branches
1541
branch: Branch format 7
1542
repository: Repository format 2a - rich roots, group compression and chk inventories
1553
self.assertEqual("", err)
1556
class TestSmartServerInfo(tests.TestCaseWithTransport):
1558
def test_simple_branch_info(self):
1559
self.setup_smart_server_with_call_log()
1560
t = self.make_branch_and_tree('branch')
1561
self.build_tree_contents([('branch/foo', b'thecontents')])
1564
self.reset_smart_call_log()
1565
out, err = self.run_bzr(['info', self.get_url('branch')])
1566
# This figure represent the amount of work to perform this use case. It
1567
# is entirely ok to reduce this number if a test fails due to rpc_count
1568
# being too low. If rpc_count increases, more network roundtrips have
1569
# become necessary for this use case. Please do not adjust this number
1570
# upwards without agreement from bzr's network support maintainers.
1571
self.assertLength(10, self.hpss_calls)
1572
self.assertLength(1, self.hpss_connections)
1573
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
1575
def test_verbose_branch_info(self):
1576
self.setup_smart_server_with_call_log()
1577
t = self.make_branch_and_tree('branch')
1578
self.build_tree_contents([('branch/foo', b'thecontents')])
1581
self.reset_smart_call_log()
1582
out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
1583
# This figure represent the amount of work to perform this use case. It
1584
# is entirely ok to reduce this number if a test fails due to rpc_count
1585
# being too low. If rpc_count increases, more network roundtrips have
1586
# become necessary for this use case. Please do not adjust this number
1587
# upwards without agreement from bzr's network support maintainers.
1588
self.assertLength(14, self.hpss_calls)
1589
self.assertLength(1, self.hpss_connections)
1590
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)