46
44
def test_info_non_existing(self):
47
45
self.vfs_transport_factory = memory.MemoryServer
48
46
location = self.get_url()
49
out, err = self.run_bzr('info ' + location, retcode=3)
47
out, err = self.run_bzr('info '+location, retcode=3)
50
48
self.assertEqual(out, '')
51
self.assertEqual(err, 'brz: ERROR: Not a branch: "%s".\n' % location)
49
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
53
51
def test_info_empty_controldir(self):
54
self.make_controldir('ctrl')
52
self.make_bzrdir('ctrl')
55
53
out, err = self.run_bzr('info ctrl')
56
54
self.assertEqual(out,
57
'Empty control directory (format: 2a)\n'
59
' control directory: ctrl\n')
55
'Empty control directory (format: 2a or pack-0.92)\n'
57
' control directory: ctrl\n')
60
58
self.assertEqual(err, '')
62
60
def test_info_empty_controldir_verbose(self):
63
self.make_controldir('ctrl')
61
self.make_bzrdir('ctrl')
64
62
out, err = self.run_bzr('info -v ctrl')
65
63
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'
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'
73
71
self.assertEqual(err, '')
75
73
def test_info_dangling_branch_reference(self):
78
76
shutil.rmtree('target')
79
77
out, err = self.run_bzr('info from')
80
78
self.assertEqual(out,
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')
79
'Dangling branch reference (format: 2a or pack-0.92)\n'
81
' control directory: from\n'
82
' checkout of branch: target\n')
97
83
self.assertEqual(err, '')
99
85
def test_info_standalone(self):
248
231
# Branch and bind to standalone, needs upgrade to metadir
249
232
# (creates backup as unknown)
250
branch1.controldir.sprout('bound')
251
knit1_format = controldir.format_registry.make_controldir('knit')
233
branch1.bzrdir.sprout('bound')
234
knit1_format = controldir.format_registry.make_bzrdir('knit')
252
235
upgrade.upgrade('bound', knit1_format)
253
236
branch3 = controldir.ControlDir.open('bound').open_branch()
254
237
branch3.bind(branch1)
255
bound_tree = branch3.controldir.open_workingtree()
238
bound_tree = branch3.bzrdir.open_workingtree()
256
239
out, err = self.run_bzr('info -v bound')
257
240
self.assertEqualDiff(
258
"""Checkout (format: knit)
241
"""Checkout (format: knit)
260
243
checkout root: bound
261
244
checkout of branch: standalone
294
276
""" % (bound_tree._format.get_format_description(),
295
branch3._format.get_format_description(),
296
branch3.repository._format.get_format_description(),
297
datestring_first, datestring_first,
277
branch3._format.get_format_description(),
278
branch3.repository._format.get_format_description(),
279
datestring_first, datestring_first,
299
281
self.assertEqual('', err)
301
283
# Checkout standalone (same as above, but does not have parent set)
302
284
branch4 = controldir.ControlDir.create_branch_convenience('checkout',
304
286
branch4.bind(branch1)
305
branch4.controldir.open_workingtree().update()
287
branch4.bzrdir.open_workingtree().update()
306
288
out, err = self.run_bzr('info checkout --verbose')
307
289
self.assertEqualDiff(
308
"""Checkout (format: knit)
290
"""Checkout (format: knit)
310
292
checkout root: checkout
311
293
checkout of branch: standalone
525
502
""" % (branch4.repository._format.get_format_description(),
526
datestring_first, datestring_first,
503
datestring_first, datestring_first,
528
505
self.assertEqual('', err)
530
507
# Out of date lightweight checkout
531
508
out, err = self.run_bzr('info lightcheckout --verbose')
532
509
self.assertEqualDiff(
533
"""Lightweight checkout (format: %s)
510
"""Lightweight checkout (format: %s)
535
512
light checkout root: lightcheckout
536
513
checkout of branch: standalone
595
""" % (info.describe_format(repo.controldir, repo, branch, None),
596
format.get_branch_format().get_format_description(),
597
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(),
599
575
self.assertEqual('', err)
601
577
def test_info_shared_repository(self):
602
format = controldir.format_registry.make_controldir('knit')
578
format = controldir.format_registry.make_bzrdir('knit')
603
579
transport = self.get_transport()
605
581
# Create shared repository
657
633
transport.mkdir('tree')
658
634
transport.mkdir('tree/lightcheckout')
659
635
tree2 = branch1.create_checkout('tree/lightcheckout',
661
637
branch2 = tree2.branch
662
638
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
663
shared_repo=repo, repo_branch=branch1, verbose=True)
639
shared_repo=repo, repo_branch=branch1, verbose=True)
665
641
# Create normal checkout
666
642
tree3 = branch1.create_checkout('tree/checkout')
667
643
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
669
light_checkout=False, repo_branch=branch1)
645
light_checkout=False, repo_branch=branch1)
670
646
# Update lightweight checkout
671
647
self.build_tree(['tree/lightcheckout/a'])
712
687
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
713
format.repository_format.get_format_description(),
714
datestring_first, datestring_first,
688
format.repository_format.get_format_description(),
689
datestring_first, datestring_first,
716
691
self.assertEqual('', err)
718
693
# Out of date checkout
719
694
out, err = self.run_bzr('info -v tree/checkout')
720
695
self.assertEqualDiff(
721
"""Checkout (format: unnamed)
696
"""Checkout (format: unnamed)
723
698
checkout root: tree/checkout
724
699
checkout of branch: repo/branch
845
817
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
846
format.repository_format.get_format_description(),
847
datestring_first, datestring_last,
818
format.repository_format.get_format_description(),
819
datestring_first, datestring_last,
849
821
self.assertEqual('', err)
851
823
# Show info about shared branch
852
824
out, err = self.run_bzr('info repo/branch --verbose')
853
825
self.assertEqualDiff(
854
"""Repository branch (format: dirstate or knit)
826
"""Repository branch (format: dirstate or knit)
856
828
shared repository: repo
857
829
repository branch: repo/branch
875
847
""" % (format.get_branch_format().get_format_description(),
876
format.repository_format.get_format_description(),
877
datestring_first, datestring_last,
848
format.repository_format.get_format_description(),
849
datestring_first, datestring_last,
879
851
self.assertEqual('', err)
881
853
# Show info about repository with revisions
882
854
out, err = self.run_bzr('info -v repo')
883
855
self.assertEqualDiff(
884
"""Shared repository (format: dirstate or dirstate-tags or knit)
856
"""Shared repository (format: dirstate or dirstate-tags or knit)
886
858
shared repository: repo
927
899
self.assertEqual('', err)
929
901
# Create two branches
930
repo.controldir.root_transport.mkdir('branch1')
902
repo.bzrdir.root_transport.mkdir('branch1')
931
903
branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
933
branch2 = branch1.controldir.sprout('repo/branch2').open_branch()
905
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
935
907
# Empty first branch
936
908
out, err = self.run_bzr('info repo/branch1 --verbose')
937
909
self.assertEqualDiff(
938
"""Repository tree (format: knit)
910
"""Repository tree (format: knit)
940
912
shared repository: repo
941
913
repository branch: repo/branch1
968
939
""" % (format.get_branch_format().get_format_description(),
969
format.repository_format.get_format_description(),
940
format.repository_format.get_format_description(),
971
942
self.assertEqual('', err)
973
944
# Update first branch
974
945
self.build_tree(['repo/branch1/a'])
975
tree1 = branch1.controldir.open_workingtree()
946
tree1 = branch1.bzrdir.open_workingtree()
977
948
tree1.commit('commit one')
978
949
rev = repo.get_revision(branch1.last_revision())
979
950
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
980
951
out, err = self.run_bzr('info -v repo/branch1')
981
952
self.assertEqualDiff(
982
"""Repository tree (format: knit)
953
"""Repository tree (format: knit)
984
955
shared repository: repo
985
956
repository branch: repo/branch1
1015
985
""" % (format.get_branch_format().get_format_description(),
1016
format.repository_format.get_format_description(),
1017
datestring_first, datestring_first,
986
format.repository_format.get_format_description(),
987
datestring_first, datestring_first,
1019
989
self.assertEqual('', err)
1021
991
# Out of date second branch
1022
992
out, err = self.run_bzr('info repo/branch2 --verbose')
1023
993
self.assertEqualDiff(
1024
"""Repository tree (format: knit)
994
"""Repository tree (format: knit)
1026
996
shared repository: repo
1027
997
repository branch: repo/branch2
1057
1026
""" % (format.get_branch_format().get_format_description(),
1058
format.repository_format.get_format_description(),
1027
format.repository_format.get_format_description(),
1060
1029
self.assertEqual('', err)
1062
1031
# Update second branch
1063
tree2 = branch2.controldir.open_workingtree()
1032
tree2 = branch2.bzrdir.open_workingtree()
1064
1033
tree2.pull(branch1)
1065
1034
out, err = self.run_bzr('info -v repo/branch2')
1066
1035
self.assertEqualDiff(
1067
"""Repository tree (format: knit)
1036
"""Repository tree (format: knit)
1069
1038
shared repository: repo
1070
1039
repository branch: repo/branch2
1103
1071
""" % (format.get_branch_format().get_format_description(),
1104
format.repository_format.get_format_description(),
1105
datestring_first, datestring_first,
1072
format.repository_format.get_format_description(),
1073
datestring_first, datestring_first,
1107
1075
self.assertEqual('', err)
1109
1077
# Show info about repository with revisions
1110
1078
out, err = self.run_bzr('info -v repo')
1111
1079
self.assertEqualDiff(
1112
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1080
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1114
1082
shared repository: repo
1196
1163
""" % (format.get_branch_format().get_format_description(),
1197
format.repository_format.get_format_description(),
1164
format.repository_format.get_format_description(),
1199
1166
self.assertEqual('', err)
1201
1168
def test_info_repository_hook(self):
1202
format = controldir.format_registry.make_controldir('knit')
1169
format = controldir.format_registry.make_bzrdir('knit')
1204
1170
def repo_info(repo, stats, outf):
1205
outf.write(u"more info\n")
1171
outf.write("more info\n")
1206
1172
info.hooks.install_named_hook('repository', repo_info, None)
1207
1173
# Create shared repository with working trees
1208
1174
repo = self.make_repository('repo', shared=True, format=format)
1209
1175
out, err = self.run_bzr('info -v repo')
1210
1176
self.assertEqualDiff(
1211
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1177
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1213
1179
shared repository: repo
1229
1195
self.assertEqual('', err)
1231
1197
def test_info_unshared_repository_with_colocated_branches(self):
1232
format = controldir.format_registry.make_controldir('development-colo')
1198
format = controldir.format_registry.make_bzrdir('development-colo')
1233
1199
transport = self.get_transport()
1235
1201
# Create unshared repository
1236
1202
repo = self.make_repository('repo', shared=False, format=format)
1237
1203
repo.set_make_working_trees(True)
1238
repo.controldir.create_branch(name='foo')
1204
repo.bzrdir.create_branch(name='foo')
1239
1205
out, err = self.run_bzr('info repo')
1240
1206
self.assertEqualDiff(
1241
"""Unshared repository with trees and colocated branches (format: development-colo)
1207
"""Unshared repository with trees and colocated branches (format: development-colo)
1243
1209
repository: repo
1245
1211
self.assertEqual('', err)
1247
1213
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):
1214
command_string, lco_tree, shared_repo=None,
1217
branch_locked=False, repo_locked=False,
1219
light_checkout=True,
1220
checkout_root=None):
1255
1221
"""Check the output of info in a checkout.
1257
1223
This is not quite a mirror of the info code: rather than using the
1323
1289
extra_space = ''
1324
1290
if light_checkout:
1325
1291
tree_data = (" light checkout root: %s\n" %
1326
friendly_location(lco_tree.controldir.root_transport.base))
1292
friendly_location(lco_tree.bzrdir.root_transport.base))
1327
1293
extra_space = ' '
1328
1294
if lco_tree.branch.get_bound_location() is not None:
1329
1295
tree_data += ("%s checkout root: %s\n" % (extra_space,
1330
friendly_location(lco_tree.branch.controldir.root_transport.base)))
1296
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1331
1297
if shared_repo is not None:
1332
1298
branch_data = (
1333
1299
" checkout of branch: %s\n"
1334
1300
" shared repository: %s\n" %
1335
(friendly_location(repo_branch.controldir.root_transport.base),
1336
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)))
1337
1303
elif repo_branch is not None:
1338
1304
branch_data = (
1339
1305
"%s checkout of branch: %s\n" %
1341
friendly_location(repo_branch.controldir.root_transport.base)))
1307
friendly_location(repo_branch.bzrdir.root_transport.base)))
1343
1309
branch_data = (" checkout of branch: %s\n" %
1344
lco_tree.branch.controldir.root_transport.base)
1310
lco_tree.branch.bzrdir.root_transport.base)
1346
1312
if verbose >= 2:
1347
1313
verbose_info = ' 0 committers\n'
1419
1384
repo_branch=repo_branch,
1420
1385
verbose=True, light_checkout=True)
1422
with lco_tree.branch.repository.lock_write():
1387
lco_tree.branch.repository.lock_write()
1423
1389
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1424
lco_tree, repo_branch=repo_branch,
1425
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()
1427
with lco_tree.branch.lock_write():
1395
lco_tree.branch.lock_write()
1428
1397
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1432
repo_branch=repo_branch,
1401
repo_branch=repo_branch,
1404
lco_tree.branch.unlock()
1435
with lco_tree.lock_write():
1406
lco_tree.lock_write()
1436
1408
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1437
lco_tree, repo_branch=repo_branch,
1409
lco_tree, repo_branch=repo_branch,
1443
with lco_tree.lock_write(), lco_tree.branch.repository.unlock():
1417
lco_tree.lock_write()
1418
lco_tree.branch.repository.unlock()
1444
1420
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1445
lco_tree, repo_branch=repo_branch,
1421
lco_tree, repo_branch=repo_branch,
1426
lco_tree.branch.repository.lock_write()
1450
with lco_tree.lock_write(), lco_tree.branch.unlock():
1429
lco_tree.lock_write()
1430
lco_tree.branch.unlock()
1451
1432
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1452
lco_tree, repo_branch=repo_branch,
1433
lco_tree, repo_branch=repo_branch,
1437
lco_tree.branch.lock_write()
1456
with lco_tree.lock_write(), lco_tree.branch.unlock(), \
1457
lco_tree.branch.repository.lock_write():
1440
lco_tree.lock_write()
1441
lco_tree.branch.unlock()
1442
lco_tree.branch.repository.lock_write()
1458
1444
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1459
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()
1464
with lco_tree.branch.lock_write(), lco_tree.branch.repository.unlock():
1454
lco_tree.branch.lock_write()
1455
lco_tree.branch.repository.unlock()
1465
1457
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1466
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()
1470
1465
if sys.platform == 'win32':
1471
self.knownFailure('Win32 cannot run "brz info"'
1466
self.knownFailure('Win32 cannot run "bzr info"'
1472
1467
' when the tree is locked.')
1474
1469
def test_info_stacked(self):
1475
1470
# We have a mainline
1476
1471
trunk_tree = self.make_branch_and_tree('mainline',
1478
1473
trunk_tree.commit('mainline')
1479
1474
# and a branch from it which is stacked
1480
new_dir = trunk_tree.controldir.sprout('newbranch', stacked=True)
1475
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1481
1476
out, err = self.run_bzr('info newbranch')
1482
1477
self.assertEqual(
1483
"""Standalone tree (format: 1.6)
1478
"""Standalone tree (format: 1.6)
1485
1480
branch root: newbranch
1526
1519
self.assertEqual("", err)
1528
1521
def test_info_shows_colocated_branches(self):
1529
bzrdir = self.make_branch('.', format='development-colo').controldir
1522
bzrdir = self.make_branch('.', format='development-colo').bzrdir
1530
1523
bzrdir.create_branch(name="colo1")
1531
1524
bzrdir.create_branch(name="colo2")
1532
1525
bzrdir.create_branch(name="colo3")
1533
1526
out, err = self.run_bzr('info -v .')
1534
1527
self.assertEqualDiff(
1535
"""Standalone branch (format: development-colo)
1528
"""Standalone branch (format: development-colo)