45
44
def test_info_non_existing(self):
46
45
self.vfs_transport_factory = memory.MemoryServer
47
46
location = self.get_url()
48
out, err = self.run_bzr('info ' + location, retcode=3)
47
out, err = self.run_bzr('info '+location, retcode=3)
49
48
self.assertEqual(out, '')
50
49
self.assertEqual(err, 'brz: ERROR: Not a branch: "%s".\n' % location)
52
51
def test_info_empty_controldir(self):
53
self.make_controldir('ctrl')
52
self.make_bzrdir('ctrl')
54
53
out, err = self.run_bzr('info ctrl')
55
54
self.assertEqual(out,
56
'Empty control directory (format: 2a)\n'
58
' control directory: ctrl\n')
55
'Empty control directory (format: 2a or pack-0.92)\n'
57
' control directory: ctrl\n')
59
58
self.assertEqual(err, '')
61
60
def test_info_empty_controldir_verbose(self):
62
self.make_controldir('ctrl')
61
self.make_bzrdir('ctrl')
63
62
out, err = self.run_bzr('info -v ctrl')
64
63
self.assertEqualDiff(out,
65
'Empty control directory (format: 2a)\n'
67
' control directory: ctrl\n\n'
69
' control: Meta directory format 1\n\n'
70
'Control directory:\n'
64
'Empty control directory (format: 2a or pack-0.92)\n'
66
' control directory: ctrl\n\n'
68
' control: Meta directory format 1\n\n'
69
'Control directory:\n'
72
71
self.assertEqual(err, '')
74
73
def test_info_dangling_branch_reference(self):
77
76
shutil.rmtree('target')
78
77
out, err = self.run_bzr('info from')
79
78
self.assertEqual(out,
80
'Dangling branch reference (format: 2a)\n'
82
' control directory: from\n'
83
' checkout of branch: target\n')
84
self.assertEqual(err, '')
86
def test_info_colocated(self):
87
br = self.make_branch_and_tree('target', format='development-colo')
88
target = br.controldir.create_branch(name='dichtbij')
89
br.controldir.set_branch_reference(target)
90
out, err = self.run_bzr('info target')
92
'Standalone tree (format: development-colo)\n'
94
' light checkout root: target\n'
95
' checkout of co-located branch: dichtbij\n')
79
'Dangling branch reference (format: 2a or pack-0.92)\n'
81
' control directory: from\n'
82
' checkout of branch: target\n')
96
83
self.assertEqual(err, '')
98
85
def test_info_standalone(self):
187
172
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
189
174
# Branch standalone with push location
190
branch2 = branch1.controldir.sprout('branch').open_branch()
191
branch2.set_push_location(branch1.controldir.root_transport.base)
175
branch2 = branch1.bzrdir.sprout('branch').open_branch()
176
branch2.set_push_location(branch1.bzrdir.root_transport.base)
193
178
out, err = self.run_bzr('info branch')
194
179
self.assertEqualDiff(
195
"""Standalone tree (format: knit)
180
"""Standalone tree (format: knit)
197
182
branch root: branch
247
231
# Branch and bind to standalone, needs upgrade to metadir
248
232
# (creates backup as unknown)
249
branch1.controldir.sprout('bound')
250
knit1_format = controldir.format_registry.make_controldir('knit')
233
branch1.bzrdir.sprout('bound')
234
knit1_format = controldir.format_registry.make_bzrdir('knit')
251
235
upgrade.upgrade('bound', knit1_format)
252
236
branch3 = controldir.ControlDir.open('bound').open_branch()
253
237
branch3.bind(branch1)
254
bound_tree = branch3.controldir.open_workingtree()
238
bound_tree = branch3.bzrdir.open_workingtree()
255
239
out, err = self.run_bzr('info -v bound')
256
240
self.assertEqualDiff(
257
"""Checkout (format: knit)
241
"""Checkout (format: knit)
259
243
checkout root: bound
260
244
checkout of branch: standalone
293
276
""" % (bound_tree._format.get_format_description(),
294
branch3._format.get_format_description(),
295
branch3.repository._format.get_format_description(),
296
datestring_first, datestring_first,
277
branch3._format.get_format_description(),
278
branch3.repository._format.get_format_description(),
279
datestring_first, datestring_first,
298
281
self.assertEqual('', err)
300
283
# Checkout standalone (same as above, but does not have parent set)
301
284
branch4 = controldir.ControlDir.create_branch_convenience('checkout',
303
286
branch4.bind(branch1)
304
branch4.controldir.open_workingtree().update()
287
branch4.bzrdir.open_workingtree().update()
305
288
out, err = self.run_bzr('info checkout --verbose')
306
289
self.assertEqualDiff(
307
"""Checkout (format: knit)
290
"""Checkout (format: knit)
309
292
checkout root: checkout
310
293
checkout of branch: standalone
481
460
""" % (branch3.repository._format.get_format_description(),
482
datestring_first, datestring_first,
461
datestring_first, datestring_first,
484
463
self.assertEqual('', err)
486
465
# Out of date checkout
487
466
out, err = self.run_bzr('info -v checkout')
488
467
self.assertEqualDiff(
489
"""Checkout (format: knit)
468
"""Checkout (format: knit)
491
470
checkout root: checkout
492
471
checkout of branch: standalone
524
502
""" % (branch4.repository._format.get_format_description(),
525
datestring_first, datestring_first,
503
datestring_first, datestring_first,
527
505
self.assertEqual('', err)
529
507
# Out of date lightweight checkout
530
508
out, err = self.run_bzr('info lightcheckout --verbose')
531
509
self.assertEqualDiff(
532
"""Lightweight checkout (format: %s)
510
"""Lightweight checkout (format: %s)
534
512
light checkout root: lightcheckout
535
513
checkout of branch: standalone
594
""" % (info.describe_format(repo.controldir, repo, branch, None),
595
format.get_branch_format().get_format_description(),
596
format.repository_format.get_format_description(),
571
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
572
format.get_branch_format().get_format_description(),
573
format.repository_format.get_format_description(),
598
575
self.assertEqual('', err)
600
577
def test_info_shared_repository(self):
601
format = controldir.format_registry.make_controldir('knit')
578
format = controldir.format_registry.make_bzrdir('knit')
602
579
transport = self.get_transport()
604
581
# Create shared repository
624
601
self.assertEqual('', err)
626
603
# Create branch inside shared repository
627
repo.controldir.root_transport.mkdir('branch')
604
repo.bzrdir.root_transport.mkdir('branch')
628
605
branch1 = controldir.ControlDir.create_branch_convenience(
629
606
'repo/branch', format=format)
630
607
out, err = self.run_bzr('info -v repo/branch')
631
608
self.assertEqualDiff(
632
"""Repository branch (format: dirstate or knit)
609
"""Repository branch (format: dirstate or knit)
634
611
shared repository: repo
635
612
repository branch: repo/branch
656
633
transport.mkdir('tree')
657
634
transport.mkdir('tree/lightcheckout')
658
635
tree2 = branch1.create_checkout('tree/lightcheckout',
660
637
branch2 = tree2.branch
661
638
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
662
shared_repo=repo, repo_branch=branch1, verbose=True)
639
shared_repo=repo, repo_branch=branch1, verbose=True)
664
641
# Create normal checkout
665
642
tree3 = branch1.create_checkout('tree/checkout')
666
643
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
668
light_checkout=False, repo_branch=branch1)
645
light_checkout=False, repo_branch=branch1)
669
646
# Update lightweight checkout
670
647
self.build_tree(['tree/lightcheckout/a'])
711
687
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
712
format.repository_format.get_format_description(),
713
datestring_first, datestring_first,
688
format.repository_format.get_format_description(),
689
datestring_first, datestring_first,
715
691
self.assertEqual('', err)
717
693
# Out of date checkout
718
694
out, err = self.run_bzr('info -v tree/checkout')
719
695
self.assertEqualDiff(
720
"""Checkout (format: unnamed)
696
"""Checkout (format: unnamed)
722
698
checkout root: tree/checkout
723
699
checkout of branch: repo/branch
796
770
""" % (format.get_branch_format().get_format_description(),
797
format.repository_format.get_format_description(),
798
datestring_first, datestring_first,
771
format.repository_format.get_format_description(),
772
datestring_first, datestring_first,
800
774
self.assertEqual('', err)
801
775
tree3.commit('commit two')
844
817
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
845
format.repository_format.get_format_description(),
846
datestring_first, datestring_last,
818
format.repository_format.get_format_description(),
819
datestring_first, datestring_last,
848
821
self.assertEqual('', err)
850
823
# Show info about shared branch
851
824
out, err = self.run_bzr('info repo/branch --verbose')
852
825
self.assertEqualDiff(
853
"""Repository branch (format: dirstate or knit)
826
"""Repository branch (format: dirstate or knit)
855
828
shared repository: repo
856
829
repository branch: repo/branch
874
847
""" % (format.get_branch_format().get_format_description(),
875
format.repository_format.get_format_description(),
876
datestring_first, datestring_last,
848
format.repository_format.get_format_description(),
849
datestring_first, datestring_last,
878
851
self.assertEqual('', err)
880
853
# Show info about repository with revisions
881
854
out, err = self.run_bzr('info -v repo')
882
855
self.assertEqualDiff(
883
"""Shared repository (format: dirstate or dirstate-tags or knit)
856
"""Shared repository (format: dirstate or dirstate-tags or knit)
885
858
shared repository: repo
926
899
self.assertEqual('', err)
928
901
# Create two branches
929
repo.controldir.root_transport.mkdir('branch1')
902
repo.bzrdir.root_transport.mkdir('branch1')
930
903
branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
932
branch2 = branch1.controldir.sprout('repo/branch2').open_branch()
905
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
934
907
# Empty first branch
935
908
out, err = self.run_bzr('info repo/branch1 --verbose')
936
909
self.assertEqualDiff(
937
"""Repository tree (format: knit)
910
"""Repository tree (format: knit)
939
912
shared repository: repo
940
913
repository branch: repo/branch1
967
939
""" % (format.get_branch_format().get_format_description(),
968
format.repository_format.get_format_description(),
940
format.repository_format.get_format_description(),
970
942
self.assertEqual('', err)
972
944
# Update first branch
973
945
self.build_tree(['repo/branch1/a'])
974
tree1 = branch1.controldir.open_workingtree()
946
tree1 = branch1.bzrdir.open_workingtree()
976
948
tree1.commit('commit one')
977
949
rev = repo.get_revision(branch1.last_revision())
978
950
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
979
951
out, err = self.run_bzr('info -v repo/branch1')
980
952
self.assertEqualDiff(
981
"""Repository tree (format: knit)
953
"""Repository tree (format: knit)
983
955
shared repository: repo
984
956
repository branch: repo/branch1
1014
985
""" % (format.get_branch_format().get_format_description(),
1015
format.repository_format.get_format_description(),
1016
datestring_first, datestring_first,
986
format.repository_format.get_format_description(),
987
datestring_first, datestring_first,
1018
989
self.assertEqual('', err)
1020
991
# Out of date second branch
1021
992
out, err = self.run_bzr('info repo/branch2 --verbose')
1022
993
self.assertEqualDiff(
1023
"""Repository tree (format: knit)
994
"""Repository tree (format: knit)
1025
996
shared repository: repo
1026
997
repository branch: repo/branch2
1056
1026
""" % (format.get_branch_format().get_format_description(),
1057
format.repository_format.get_format_description(),
1027
format.repository_format.get_format_description(),
1059
1029
self.assertEqual('', err)
1061
1031
# Update second branch
1062
tree2 = branch2.controldir.open_workingtree()
1032
tree2 = branch2.bzrdir.open_workingtree()
1063
1033
tree2.pull(branch1)
1064
1034
out, err = self.run_bzr('info -v repo/branch2')
1065
1035
self.assertEqualDiff(
1066
"""Repository tree (format: knit)
1036
"""Repository tree (format: knit)
1068
1038
shared repository: repo
1069
1039
repository branch: repo/branch2
1102
1071
""" % (format.get_branch_format().get_format_description(),
1103
format.repository_format.get_format_description(),
1104
datestring_first, datestring_first,
1072
format.repository_format.get_format_description(),
1073
datestring_first, datestring_first,
1106
1075
self.assertEqual('', err)
1108
1077
# Show info about repository with revisions
1109
1078
out, err = self.run_bzr('info -v repo')
1110
1079
self.assertEqualDiff(
1111
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1080
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1113
1082
shared repository: repo
1195
1163
""" % (format.get_branch_format().get_format_description(),
1196
format.repository_format.get_format_description(),
1164
format.repository_format.get_format_description(),
1198
1166
self.assertEqual('', err)
1200
1168
def test_info_repository_hook(self):
1201
format = controldir.format_registry.make_controldir('knit')
1169
format = controldir.format_registry.make_bzrdir('knit')
1203
1170
def repo_info(repo, stats, outf):
1204
outf.write(u"more info\n")
1171
outf.write("more info\n")
1205
1172
info.hooks.install_named_hook('repository', repo_info, None)
1206
1173
# Create shared repository with working trees
1207
1174
repo = self.make_repository('repo', shared=True, format=format)
1208
1175
out, err = self.run_bzr('info -v repo')
1209
1176
self.assertEqualDiff(
1210
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1177
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1212
1179
shared repository: repo
1228
1195
self.assertEqual('', err)
1230
1197
def test_info_unshared_repository_with_colocated_branches(self):
1231
format = controldir.format_registry.make_controldir('development-colo')
1198
format = controldir.format_registry.make_bzrdir('development-colo')
1232
1199
transport = self.get_transport()
1234
1201
# Create unshared repository
1235
1202
repo = self.make_repository('repo', shared=False, format=format)
1236
1203
repo.set_make_working_trees(True)
1237
repo.controldir.create_branch(name='foo')
1204
repo.bzrdir.create_branch(name='foo')
1238
1205
out, err = self.run_bzr('info repo')
1239
1206
self.assertEqualDiff(
1240
"""Unshared repository with trees and colocated branches (format: development-colo)
1207
"""Unshared repository with trees and colocated branches (format: development-colo)
1242
1209
repository: repo
1244
1211
self.assertEqual('', err)
1246
1213
def assertCheckoutStatusOutput(self,
1247
command_string, lco_tree, shared_repo=None,
1250
branch_locked=False, repo_locked=False,
1252
light_checkout=True,
1253
checkout_root=None):
1214
command_string, lco_tree, shared_repo=None,
1217
branch_locked=False, repo_locked=False,
1219
light_checkout=True,
1220
checkout_root=None):
1254
1221
"""Check the output of info in a checkout.
1256
1223
This is not quite a mirror of the info code: rather than using the
1287
1254
# in the different process -- either on win32 or on linux).
1288
1255
# This should be removed when the locking errors are fixed.
1289
1256
self.expectFailure('OS locks are exclusive '
1290
'for different processes (Bug #174055)',
1291
self.run_bzr_subprocess,
1292
'info ' + command_string)
1257
'for different processes (Bug #174055)',
1258
self.run_bzr_subprocess,
1259
'info ' + command_string)
1293
1260
out, err = self.run_bzr('info %s' % command_string)
1294
1261
description = {
1295
1262
(True, True): 'Lightweight checkout',
1322
1289
extra_space = ''
1323
1290
if light_checkout:
1324
1291
tree_data = (" light checkout root: %s\n" %
1325
friendly_location(lco_tree.controldir.root_transport.base))
1292
friendly_location(lco_tree.bzrdir.root_transport.base))
1326
1293
extra_space = ' '
1327
1294
if lco_tree.branch.get_bound_location() is not None:
1328
1295
tree_data += ("%s checkout root: %s\n" % (extra_space,
1329
friendly_location(lco_tree.branch.controldir.root_transport.base)))
1296
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1330
1297
if shared_repo is not None:
1331
1298
branch_data = (
1332
1299
" checkout of branch: %s\n"
1333
1300
" shared repository: %s\n" %
1334
(friendly_location(repo_branch.controldir.root_transport.base),
1335
friendly_location(shared_repo.controldir.root_transport.base)))
1301
(friendly_location(repo_branch.bzrdir.root_transport.base),
1302
friendly_location(shared_repo.bzrdir.root_transport.base)))
1336
1303
elif repo_branch is not None:
1337
1304
branch_data = (
1338
1305
"%s checkout of branch: %s\n" %
1340
friendly_location(repo_branch.controldir.root_transport.base)))
1307
friendly_location(repo_branch.bzrdir.root_transport.base)))
1342
1309
branch_data = (" checkout of branch: %s\n" %
1343
lco_tree.branch.controldir.root_transport.base)
1310
lco_tree.branch.bzrdir.root_transport.base)
1345
1312
if verbose >= 2:
1346
1313
verbose_info = ' 0 committers\n'
1383
lco_tree._format.get_format_description(),
1384
lco_tree.branch._format.get_format_description(),
1385
lco_tree.branch.repository._format.get_format_description(),
1386
expected_lock_output,
1349
lco_tree._format.get_format_description(),
1350
lco_tree.branch._format.get_format_description(),
1351
lco_tree.branch.repository._format.get_format_description(),
1352
expected_lock_output,
1389
1355
self.assertEqual('', err)
1391
1357
def test_info_locking(self):
1418
1384
repo_branch=repo_branch,
1419
1385
verbose=True, light_checkout=True)
1421
with lco_tree.branch.repository.lock_write():
1387
lco_tree.branch.repository.lock_write()
1422
1389
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1423
lco_tree, repo_branch=repo_branch,
1424
repo_locked=True, verbose=True, light_checkout=True)
1390
lco_tree, repo_branch=repo_branch,
1391
repo_locked=True, verbose=True, light_checkout=True)
1393
lco_tree.branch.repository.unlock()
1426
with lco_tree.branch.lock_write():
1395
lco_tree.branch.lock_write()
1427
1397
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1431
repo_branch=repo_branch,
1401
repo_branch=repo_branch,
1404
lco_tree.branch.unlock()
1434
with lco_tree.lock_write():
1406
lco_tree.lock_write()
1435
1408
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1436
lco_tree, repo_branch=repo_branch,
1409
lco_tree, repo_branch=repo_branch,
1442
with lco_tree.lock_write(), lco_tree.branch.repository.unlock():
1417
lco_tree.lock_write()
1418
lco_tree.branch.repository.unlock()
1443
1420
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1444
lco_tree, repo_branch=repo_branch,
1421
lco_tree, repo_branch=repo_branch,
1426
lco_tree.branch.repository.lock_write()
1449
with lco_tree.lock_write(), lco_tree.branch.unlock():
1429
lco_tree.lock_write()
1430
lco_tree.branch.unlock()
1450
1432
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1451
lco_tree, repo_branch=repo_branch,
1433
lco_tree, repo_branch=repo_branch,
1437
lco_tree.branch.lock_write()
1455
with lco_tree.lock_write(), lco_tree.branch.unlock(), \
1456
lco_tree.branch.repository.lock_write():
1440
lco_tree.lock_write()
1441
lco_tree.branch.unlock()
1442
lco_tree.branch.repository.lock_write()
1457
1444
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1458
lco_tree, repo_branch=repo_branch,
1445
lco_tree, repo_branch=repo_branch,
1450
lco_tree.branch.repository.unlock()
1451
lco_tree.branch.lock_write()
1463
with lco_tree.branch.lock_write(), lco_tree.branch.repository.unlock():
1454
lco_tree.branch.lock_write()
1455
lco_tree.branch.repository.unlock()
1464
1457
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1465
lco_tree, repo_branch=repo_branch,
1458
lco_tree, repo_branch=repo_branch,
1462
lco_tree.branch.repository.lock_write()
1463
lco_tree.branch.unlock()
1469
1465
if sys.platform == 'win32':
1470
1466
self.knownFailure('Win32 cannot run "brz info"'
1473
1469
def test_info_stacked(self):
1474
1470
# We have a mainline
1475
1471
trunk_tree = self.make_branch_and_tree('mainline',
1477
1473
trunk_tree.commit('mainline')
1478
1474
# and a branch from it which is stacked
1479
new_dir = trunk_tree.controldir.sprout('newbranch', stacked=True)
1475
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1480
1476
out, err = self.run_bzr('info newbranch')
1481
1477
self.assertEqual(
1482
"""Standalone tree (format: 1.6)
1478
"""Standalone tree (format: 1.6)
1484
1480
branch root: newbranch
1492
1488
def test_info_revinfo_optional(self):
1493
1489
tree = self.make_branch_and_tree('.')
1495
1490
def last_revision_info(self):
1496
1491
raise errors.UnsupportedOperation(last_revision_info, self)
1497
1492
self.overrideAttr(
1498
1493
branch.Branch, "last_revision_info", last_revision_info)
1499
1494
out, err = self.run_bzr('info -v .')
1500
1495
self.assertEqual(
1501
"""Standalone tree (format: 2a)
1496
"""Standalone tree (format: 2a)
1525
1519
self.assertEqual("", err)
1527
1521
def test_info_shows_colocated_branches(self):
1528
bzrdir = self.make_branch('.', format='development-colo').controldir
1522
bzrdir = self.make_branch('.', format='development-colo').bzrdir
1529
1523
bzrdir.create_branch(name="colo1")
1530
1524
bzrdir.create_branch(name="colo2")
1531
1525
bzrdir.create_branch(name="colo3")
1532
1526
out, err = self.run_bzr('info -v .')
1533
1527
self.assertEqualDiff(
1534
"""Standalone branch (format: development-colo)
1528
"""Standalone branch (format: development-colo)
1552
1546
self.assertEqual("", err)
1549
class TestSmartServerInfo(tests.TestCaseWithTransport):
1551
def test_simple_branch_info(self):
1552
self.setup_smart_server_with_call_log()
1553
t = self.make_branch_and_tree('branch')
1554
self.build_tree_contents([('branch/foo', 'thecontents')])
1557
self.reset_smart_call_log()
1558
out, err = self.run_bzr(['info', self.get_url('branch')])
1559
# This figure represent the amount of work to perform this use case. It
1560
# is entirely ok to reduce this number if a test fails due to rpc_count
1561
# being too low. If rpc_count increases, more network roundtrips have
1562
# become necessary for this use case. Please do not adjust this number
1563
# upwards without agreement from bzr's network support maintainers.
1564
self.assertLength(10, self.hpss_calls)
1565
self.assertLength(1, self.hpss_connections)
1566
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
1568
def test_verbose_branch_info(self):
1569
self.setup_smart_server_with_call_log()
1570
t = self.make_branch_and_tree('branch')
1571
self.build_tree_contents([('branch/foo', 'thecontents')])
1574
self.reset_smart_call_log()
1575
out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
1576
# This figure represent the amount of work to perform this use case. It
1577
# is entirely ok to reduce this number if a test fails due to rpc_count
1578
# being too low. If rpc_count increases, more network roundtrips have
1579
# become necessary for this use case. Please do not adjust this number
1580
# upwards without agreement from bzr's network support maintainers.
1581
self.assertLength(14, self.hpss_calls)
1582
self.assertLength(1, self.hpss_connections)
1583
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)