46
41
def test_info_non_existing(self):
47
42
self.vfs_transport_factory = memory.MemoryServer
48
43
location = self.get_url()
49
out, err = self.run_bzr('info ' + location, retcode=3)
44
out, err = self.run_bzr('info '+location, retcode=3)
50
45
self.assertEqual(out, '')
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, '')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
99
48
def test_info_standalone(self):
100
49
transport = self.get_transport()
102
51
# Create initial standalone branch
103
tree1 = self.make_branch_and_tree('standalone', 'knit')
52
tree1 = self.make_branch_and_tree('standalone', 'weave')
104
53
self.build_tree(['standalone/a'])
106
55
branch1 = tree1.branch
108
57
out, err = self.run_bzr('info standalone')
109
58
self.assertEqualDiff(
110
"""Standalone tree (format: knit)
59
"""Standalone tree (format: weave)
112
61
branch root: standalone
294
227
""" % (bound_tree._format.get_format_description(),
295
branch3._format.get_format_description(),
296
branch3.repository._format.get_format_description(),
297
datestring_first, datestring_first,
228
branch3._format.get_format_description(),
229
branch3.repository._format.get_format_description(),
230
datestring_first, datestring_first,
299
232
self.assertEqual('', err)
301
234
# Checkout standalone (same as above, but does not have parent set)
302
branch4 = controldir.ControlDir.create_branch_convenience('checkout',
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
304
237
branch4.bind(branch1)
305
branch4.controldir.open_workingtree().update()
238
branch4.bzrdir.open_workingtree().update()
306
239
out, err = self.run_bzr('info checkout --verbose')
307
240
self.assertEqualDiff(
308
"""Checkout (format: knit)
241
"""Checkout (format: knit)
310
243
checkout root: checkout
311
244
checkout of branch: standalone
525
434
""" % (branch4.repository._format.get_format_description(),
526
datestring_first, datestring_first,
435
datestring_first, datestring_first,
528
437
self.assertEqual('', err)
530
439
# Out of date lightweight checkout
531
440
out, err = self.run_bzr('info lightcheckout --verbose')
532
441
self.assertEqualDiff(
533
"""Lightweight checkout (format: %s)
442
"""Lightweight checkout (format: %s)
535
444
light checkout root: lightcheckout
536
445
checkout of branch: standalone
539
448
control: Meta directory format 1
540
working tree: Working tree format 3
541
branch: Branch format 5
542
repository: Knit repository format 1
449
working tree: Working tree format 6
450
branch: Branch format 4
451
repository: Weave repository format 6
547
453
Working tree is out of date: missing 1 revision.
657
553
transport.mkdir('tree')
658
554
transport.mkdir('tree/lightcheckout')
659
555
tree2 = branch1.create_checkout('tree/lightcheckout',
661
557
branch2 = tree2.branch
662
558
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
663
shared_repo=repo, repo_branch=branch1, verbose=True)
559
shared_repo=repo, repo_branch=branch1, verbose=True)
665
561
# Create normal checkout
666
562
tree3 = branch1.create_checkout('tree/checkout')
667
563
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
669
light_checkout=False, repo_branch=branch1)
565
light_checkout=False, repo_branch=branch1)
670
566
# Update lightweight checkout
671
567
self.build_tree(['tree/lightcheckout/a'])
673
569
tree2.commit('commit one')
674
rev = repo.get_revision(branch2.last_revision())
570
rev = repo.get_revision(branch2.revision_history()[0])
675
571
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
676
572
out, err = self.run_bzr('info tree/lightcheckout --verbose')
677
573
self.assertEqualDiff(
678
"""Lightweight checkout (format: %s)
574
"""Lightweight checkout (format: %s)
680
576
light checkout root: tree/lightcheckout
681
577
checkout of branch: repo/branch
797
681
""" % (format.get_branch_format().get_format_description(),
798
format.repository_format.get_format_description(),
799
datestring_first, datestring_first,
682
format.repository_format.get_format_description(),
683
datestring_first, datestring_first,
801
685
self.assertEqual('', err)
802
686
tree3.commit('commit two')
804
688
# Out of date lightweight checkout
805
rev = repo.get_revision(branch1.last_revision())
689
rev = repo.get_revision(branch1.revision_history()[-1])
806
690
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
807
691
out, err = self.run_bzr('info tree/lightcheckout --verbose')
808
692
self.assertEqualDiff(
809
"""Lightweight checkout (format: %s)
693
"""Lightweight checkout (format: %s)
811
695
light checkout root: tree/lightcheckout
812
696
checkout of branch: repo/branch
1196
1041
""" % (format.get_branch_format().get_format_description(),
1197
format.repository_format.get_format_description(),
1042
format.repository_format.get_format_description(),
1199
1044
self.assertEqual('', err)
1201
1046
def test_info_repository_hook(self):
1202
format = controldir.format_registry.make_controldir('knit')
1047
format = bzrdir.format_registry.make_bzrdir('knit')
1204
1048
def repo_info(repo, stats, outf):
1205
outf.write(u"more info\n")
1049
outf.write("more info\n")
1206
1050
info.hooks.install_named_hook('repository', repo_info, None)
1207
1051
# Create shared repository with working trees
1208
1052
repo = self.make_repository('repo', shared=True, format=format)
1209
1053
out, err = self.run_bzr('info -v repo')
1210
1054
self.assertEqualDiff(
1211
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1055
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1213
1057
shared repository: repo
1229
1070
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)
1247
1072
def assertCheckoutStatusOutput(self,
1248
command_string, lco_tree, shared_repo=None,
1251
branch_locked=False, repo_locked=False,
1253
light_checkout=True,
1254
checkout_root=None):
1073
command_string, lco_tree, shared_repo=None,
1076
branch_locked=False, repo_locked=False,
1078
light_checkout=True,
1079
checkout_root=None):
1255
1080
"""Check the output of info in a checkout.
1257
1082
This is not quite a mirror of the info code: rather than using the
1323
1148
extra_space = ''
1324
1149
if light_checkout:
1325
1150
tree_data = (" light checkout root: %s\n" %
1326
friendly_location(lco_tree.controldir.root_transport.base))
1151
friendly_location(lco_tree.bzrdir.root_transport.base))
1327
1152
extra_space = ' '
1328
1153
if lco_tree.branch.get_bound_location() is not None:
1329
1154
tree_data += ("%s checkout root: %s\n" % (extra_space,
1330
friendly_location(lco_tree.branch.controldir.root_transport.base)))
1155
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1331
1156
if shared_repo is not None:
1332
1157
branch_data = (
1333
1158
" checkout of branch: %s\n"
1334
1159
" shared repository: %s\n" %
1335
(friendly_location(repo_branch.controldir.root_transport.base),
1336
friendly_location(shared_repo.controldir.root_transport.base)))
1160
(friendly_location(repo_branch.bzrdir.root_transport.base),
1161
friendly_location(shared_repo.bzrdir.root_transport.base)))
1337
1162
elif repo_branch is not None:
1338
1163
branch_data = (
1339
1164
"%s checkout of branch: %s\n" %
1341
friendly_location(repo_branch.controldir.root_transport.base)))
1166
friendly_location(repo_branch.bzrdir.root_transport.base)))
1343
1168
branch_data = (" checkout of branch: %s\n" %
1344
lco_tree.branch.controldir.root_transport.base)
1169
lco_tree.branch.bzrdir.root_transport.base)
1346
1171
if verbose >= 2:
1347
1172
verbose_info = ' 0 committers\n'
1395
1216
repo = self.make_repository('repo', shared=True,
1396
1217
format=bzrdir.BzrDirMetaFormat1())
1397
1218
repo.set_make_working_trees(False)
1398
repo.controldir.root_transport.mkdir('branch')
1399
repo_branch = controldir.ControlDir.create_branch_convenience(
1400
'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1219
repo.bzrdir.root_transport.mkdir('branch')
1220
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1221
format=bzrdir.BzrDirMetaFormat1())
1401
1222
# Do a heavy checkout
1402
1223
transport.mkdir('tree')
1403
1224
transport.mkdir('tree/checkout')
1404
co_branch = controldir.ControlDir.create_branch_convenience(
1405
'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1225
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
format=bzrdir.BzrDirMetaFormat1())
1406
1227
co_branch.bind(repo_branch)
1407
1228
# Do a light checkout of the heavy one
1408
1229
transport.mkdir('tree/lightcheckout')
1409
1230
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1410
lco_dir.set_branch_reference(co_branch)
1231
branch.BranchReferenceFormat().initialize(lco_dir,
1232
target_branch=co_branch)
1411
1233
lco_dir.create_workingtree()
1412
1234
lco_tree = lco_dir.open_workingtree()
1419
1241
repo_branch=repo_branch,
1420
1242
verbose=True, light_checkout=True)
1422
with lco_tree.branch.repository.lock_write():
1244
lco_tree.branch.repository.lock_write()
1423
1246
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1424
lco_tree, repo_branch=repo_branch,
1425
repo_locked=True, verbose=True, light_checkout=True)
1247
lco_tree, repo_branch=repo_branch,
1248
repo_locked=True, verbose=True, light_checkout=True)
1250
lco_tree.branch.repository.unlock()
1427
with lco_tree.branch.lock_write():
1252
lco_tree.branch.lock_write()
1428
1254
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1432
repo_branch=repo_branch,
1258
repo_branch=repo_branch,
1261
lco_tree.branch.unlock()
1435
with lco_tree.lock_write():
1263
lco_tree.lock_write()
1436
1265
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1437
lco_tree, repo_branch=repo_branch,
1266
lco_tree, repo_branch=repo_branch,
1443
with lco_tree.lock_write(), lco_tree.branch.repository.unlock():
1274
lco_tree.lock_write()
1275
lco_tree.branch.repository.unlock()
1444
1277
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1445
lco_tree, repo_branch=repo_branch,
1278
lco_tree, repo_branch=repo_branch,
1283
lco_tree.branch.repository.lock_write()
1450
with lco_tree.lock_write(), lco_tree.branch.unlock():
1286
lco_tree.lock_write()
1287
lco_tree.branch.unlock()
1451
1289
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1452
lco_tree, repo_branch=repo_branch,
1290
lco_tree, repo_branch=repo_branch,
1294
lco_tree.branch.lock_write()
1456
with lco_tree.lock_write(), lco_tree.branch.unlock(), \
1457
lco_tree.branch.repository.lock_write():
1297
lco_tree.lock_write()
1298
lco_tree.branch.unlock()
1299
lco_tree.branch.repository.lock_write()
1458
1301
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1459
lco_tree, repo_branch=repo_branch,
1302
lco_tree, repo_branch=repo_branch,
1307
lco_tree.branch.repository.unlock()
1308
lco_tree.branch.lock_write()
1464
with lco_tree.branch.lock_write(), lco_tree.branch.repository.unlock():
1311
lco_tree.branch.lock_write()
1312
lco_tree.branch.repository.unlock()
1465
1314
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1466
lco_tree, repo_branch=repo_branch,
1315
lco_tree, repo_branch=repo_branch,
1319
lco_tree.branch.repository.lock_write()
1320
lco_tree.branch.unlock()
1470
1322
if sys.platform == 'win32':
1471
self.knownFailure('Win32 cannot run "brz info"'
1323
self.knownFailure('Win32 cannot run "bzr info"'
1472
1324
' 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)
1474
1409
def test_info_stacked(self):
1475
1410
# We have a mainline
1476
1411
trunk_tree = self.make_branch_and_tree('mainline',
1478
1413
trunk_tree.commit('mainline')
1479
1414
# and a branch from it which is stacked
1480
new_dir = trunk_tree.controldir.sprout('newbranch', stacked=True)
1415
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1481
1416
out, err = self.run_bzr('info newbranch')
1482
1417
self.assertEqual(
1483
"""Standalone tree (format: 1.6)
1418
"""Standalone tree (format: 1.6)
1485
1420
branch root: newbranch
1489
1424
stacked on: mainline
1491
1426
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)