30
32
class TestInfo(ExternalBase):
32
34
def test_info_non_existing(self):
33
out, err = self.runbzr('info /i/do/not/exist/', retcode=3)
35
if sys.platform == "win32":
36
location = "C:/i/do/not/exist/"
38
location = "/i/do/not/exist/"
39
out, err = self.runbzr('info '+location, retcode=3)
34
40
self.assertEqual(out, '')
35
self.assertEqual(err, 'bzr: ERROR: Not a branch: /i/do/not/exist/\n')
41
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
37
43
def test_info_standalone(self):
38
44
transport = self.get_transport()
40
46
# Create initial standalone branch
41
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
42
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
43
tree1 = self.make_branch_and_tree('standalone')
44
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
47
tree1 = self.make_branch_and_tree('standalone', 'weave')
45
48
self.build_tree(['standalone/a'])
47
50
branch1 = tree1.branch
533
533
""" % (repo.bzrdir.root_transport.base,
534
repo._format.get_format_description(),
534
format.get_branch_format().get_format_description(),
535
format.repository_format.get_format_description(),
536
537
self.assertEqual('', err)
538
539
# Create lightweight checkout
539
540
transport.mkdir('tree')
540
541
transport.mkdir('tree/lightcheckout')
541
dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
542
bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
543
dir2.create_workingtree()
544
tree2 = dir2.open_workingtree()
542
tree2 = branch1.create_checkout('tree/lightcheckout',
545
544
branch2 = tree2.branch
546
out, err = self.runbzr('info tree/lightcheckout')
547
self.assertEqualDiff(
549
light checkout root: %s
550
shared repository: %s
551
repository branch: branch
554
control: Meta directory format 1
555
working tree: Working tree format 3
556
branch: Branch format 5
567
0 versioned subdirectories
575
""" % (tree2.bzrdir.root_transport.base,
576
repo.bzrdir.root_transport.base,
577
repo._format.get_format_description(),
579
self.assertEqual('', err)
545
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2,
581
548
# Create normal checkout
582
branch3 = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout')
583
branch3.bind(branch1)
584
tree3 = branch3.bzrdir.open_workingtree()
586
out, err = self.runbzr('info tree/checkout --verbose')
587
self.assertEqualDiff(
590
checkout of branch: %s
593
control: Meta directory format 1
594
working tree: Working tree format 3
595
branch: Branch format 5
606
0 versioned subdirectories
615
""" % (branch3.bzrdir.root_transport.base,
616
branch1.bzrdir.root_transport.base,
617
repo._format.get_format_description(),
619
self.assertEqual('', err)
549
tree3 = branch1.create_checkout('tree/checkout')
550
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
552
light_checkout=False, repo_branch=branch1)
621
553
# Update lightweight checkout
622
554
self.build_tree(['tree/lightcheckout/a'])
845
782
""" % (repo.bzrdir.root_transport.base,
846
repo._format.get_format_description(),
783
format.repository_format.get_format_description(),
847
784
# poking at _revision_store isn't all that clean, but neither is
848
785
# having the ui test dependent on the exact overhead of a given store.
849
786
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
851
788
self.assertEqual('', err)
853
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
855
790
def test_info_shared_repository_with_trees(self):
856
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
857
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
791
format = bzrdir.format_registry.make_bzrdir('knit')
858
792
transport = self.get_transport()
860
794
# Create shared repository with working trees
861
repo = self.make_repository('repo', shared=True)
795
repo = self.make_repository('repo', shared=True, format=format)
862
796
repo.set_make_working_trees(True)
863
797
out, err = self.runbzr('info repo')
864
798
self.assertEqualDiff(
1073
1012
""" % (repo.bzrdir.root_transport.base,
1074
repo._format.get_format_description(),
1013
format.repository_format.get_format_description(),
1075
1014
# poking at _revision_store isn't all that clean, but neither is
1076
1015
# having the ui test dependent on the exact overhead of a given store.
1077
1016
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1080
1019
self.assertEqual('', err)
1082
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1084
1021
def test_info_shared_repository_with_tree_in_root(self):
1085
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1086
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
1022
format = bzrdir.format_registry.make_bzrdir('knit')
1087
1023
transport = self.get_transport()
1089
1025
# Create shared repository with working trees
1090
repo = self.make_repository('repo', shared=True)
1026
repo = self.make_repository('repo', shared=True, format=format)
1091
1027
repo.set_make_working_trees(True)
1092
1028
out, err = self.runbzr('info repo')
1093
1029
self.assertEqualDiff(
1143
1079
""" % (repo.bzrdir.root_transport.base,
1144
repo._format.get_format_description(),
1080
format.get_branch_format().get_format_description(),
1081
format.repository_format.get_format_description(),
1146
1083
self.assertEqual('', err)
1148
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1085
def assertCheckoutStatusOutput(self,
1086
command_string, lco_tree, shared_repo=None,
1089
branch_locked=False, repo_locked=False,
1091
light_checkout=True):
1092
"""Check the output of info in a light checkout tree.
1094
This is not quite a mirror of the info code: rather than using the
1095
tree being examined to predict output, it uses a bunch of flags which
1096
allow us, the test writers, to document what *should* be present in
1097
the output. Removing this separation would remove the value of the
1100
:param path: the path to the light checkout.
1101
:param lco_tree: the tree object for the light checkout.
1102
:param shared_repo: A shared repository is in use, expect that in
1104
:param repo_branch: A branch in a shared repository for non light
1106
:param tree_locked: If true, expect the tree to be locked.
1107
:param branch_locked: If true, expect the branch to be locked.
1108
:param repo_locked: If true, expect the repository to be locked.
1109
:param verbose: If true, expect verbose output
1111
out, err = self.runbzr('info %s' % command_string)
1112
if repo_locked or branch_locked or tree_locked:
1113
def locked_message(a_bool):
1118
expected_lock_output = (
1121
" working tree: %s\n"
1123
" repository: %s\n" % (
1124
locked_message(tree_locked),
1125
locked_message(branch_locked),
1126
locked_message(repo_locked)))
1128
expected_lock_output = ''
1130
tree_data = (" light checkout root: %s" %
1131
lco_tree.bzrdir.root_transport.base)
1133
tree_data = (" checkout root: %s" %
1134
lco_tree.bzrdir.root_transport.base)
1135
if shared_repo is not None:
1137
" shared repository: %s\n"
1138
" repository branch: branch\n" %
1139
shared_repo.bzrdir.root_transport.base)
1140
elif repo_branch is not None:
1142
" checkout of branch: %s\n" %
1143
repo_branch.bzrdir.root_transport.base)
1145
branch_data = (" checkout of branch: %s\n" %
1146
lco_tree.branch.bzrdir.root_transport.base)
1149
verbose_info = ' 0 committers\n'
1153
self.assertEqualDiff(
1158
control: Meta directory format 1
1163
In the working tree:
1171
0 versioned subdirectories
1181
lco_tree._format.get_format_description(),
1182
lco_tree.branch._format.get_format_description(),
1183
lco_tree.branch.repository._format.get_format_description(),
1184
expected_lock_output,
1187
self.assertEqual('', err)
1150
1189
def test_info_locking(self):
1151
1190
transport = self.get_transport()
1176
out, err = self.runbzr('info tree/lightcheckout')
1177
self.assertEqualDiff(
1179
light checkout root: %s
1180
checkout of branch: %s
1183
control: Meta directory format 1
1184
working tree: Working tree format 3
1185
branch: Branch format 5
1188
In the working tree:
1196
0 versioned subdirectories
1204
""" % (lco_tree.bzrdir.root_transport.base,
1205
lco_tree.branch.bzrdir.root_transport.base,
1206
lco_tree.branch.repository._format.get_format_description(),
1208
self.assertEqual('', err)
1215
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1210
1217
lco_tree.branch.repository.lock_write()
1211
out, err = self.runbzr('info tree/lightcheckout')
1212
self.assertEqualDiff(
1214
light checkout root: %s
1215
checkout of branch: %s
1218
control: Meta directory format 1
1219
working tree: Working tree format 3
1220
branch: Branch format 5
1224
working tree: unlocked
1228
In the working tree:
1236
0 versioned subdirectories
1244
""" % (lco_tree.bzrdir.root_transport.base,
1245
lco_tree.branch.bzrdir.root_transport.base,
1246
lco_tree.branch.repository._format.get_format_description(),
1248
self.assertEqual('', err)
1249
lco_tree.branch.repository.unlock()
1219
self.assertCheckoutStatusOutput('tree/lightcheckout',
1223
lco_tree.branch.repository.unlock()
1251
1225
lco_tree.branch.lock_write()
1252
out, err = self.runbzr('info tree/lightcheckout')
1253
self.assertEqualDiff(
1255
light checkout root: %s
1256
checkout of branch: %s
1259
control: Meta directory format 1
1260
working tree: Working tree format 3
1261
branch: Branch format 5
1265
working tree: unlocked
1269
In the working tree:
1277
0 versioned subdirectories
1285
""" % (lco_tree.bzrdir.root_transport.base,
1286
lco_tree.branch.bzrdir.root_transport.base,
1287
lco_tree.branch.repository._format.get_format_description(),
1289
self.assertEqual('', err)
1290
lco_tree.branch.unlock()
1227
self.assertCheckoutStatusOutput('tree/lightcheckout',
1232
lco_tree.branch.unlock()
1292
1234
lco_tree.lock_write()
1293
out, err = self.runbzr('info tree/lightcheckout')
1294
self.assertEqualDiff(
1296
light checkout root: %s
1297
checkout of branch: %s
1300
control: Meta directory format 1
1301
working tree: Working tree format 3
1302
branch: Branch format 5
1306
working tree: locked
1310
In the working tree:
1318
0 versioned subdirectories
1326
""" % (lco_tree.bzrdir.root_transport.base,
1327
lco_tree.branch.bzrdir.root_transport.base,
1328
lco_tree.branch.repository._format.get_format_description(),
1330
self.assertEqual('', err)
1236
self.assertCheckoutStatusOutput('tree/lightcheckout',
1333
1244
lco_tree.lock_write()
1334
1245
lco_tree.branch.repository.unlock()
1335
out, err = self.runbzr('info tree/lightcheckout')
1336
self.assertEqualDiff(
1338
light checkout root: %s
1339
checkout of branch: %s
1342
control: Meta directory format 1
1343
working tree: Working tree format 3
1344
branch: Branch format 5
1348
working tree: locked
1350
repository: unlocked
1352
In the working tree:
1360
0 versioned subdirectories
1368
""" % (lco_tree.bzrdir.root_transport.base,
1369
lco_tree.branch.bzrdir.root_transport.base,
1370
lco_tree.branch.repository._format.get_format_description(),
1372
self.assertEqual('', err)
1373
lco_tree.branch.repository.lock_write()
1247
self.assertCheckoutStatusOutput('tree/lightcheckout',
1252
lco_tree.branch.repository.lock_write()
1376
1255
lco_tree.lock_write()
1377
1256
lco_tree.branch.unlock()
1378
out, err = self.runbzr('info tree/lightcheckout')
1379
self.assertEqualDiff(
1381
light checkout root: %s
1382
checkout of branch: %s
1385
control: Meta directory format 1
1386
working tree: Working tree format 3
1387
branch: Branch format 5
1391
working tree: locked
1393
repository: unlocked
1395
In the working tree:
1403
0 versioned subdirectories
1411
""" % (lco_tree.bzrdir.root_transport.base,
1412
lco_tree.branch.bzrdir.root_transport.base,
1413
lco_tree.branch.repository._format.get_format_description(),
1415
self.assertEqual('', err)
1416
lco_tree.branch.lock_write()
1258
self.assertCheckoutStatusOutput('tree/lightcheckout',
1262
lco_tree.branch.lock_write()
1419
1265
lco_tree.lock_write()
1420
1266
lco_tree.branch.unlock()
1421
1267
lco_tree.branch.repository.lock_write()
1422
out, err = self.runbzr('info tree/lightcheckout')
1423
self.assertEqualDiff(
1425
light checkout root: %s
1426
checkout of branch: %s
1429
control: Meta directory format 1
1430
working tree: Working tree format 3
1431
branch: Branch format 5
1435
working tree: locked
1439
In the working tree:
1447
0 versioned subdirectories
1455
""" % (lco_tree.bzrdir.root_transport.base,
1456
lco_tree.branch.bzrdir.root_transport.base,
1457
lco_tree.branch.repository._format.get_format_description(),
1459
self.assertEqual('', err)
1460
lco_tree.branch.repository.unlock()
1461
lco_tree.branch.lock_write()
1269
self.assertCheckoutStatusOutput('tree/lightcheckout',
1274
lco_tree.branch.repository.unlock()
1275
lco_tree.branch.lock_write()
1464
1278
lco_tree.branch.lock_write()
1465
1279
lco_tree.branch.repository.unlock()
1466
out, err = self.runbzr('info tree/lightcheckout')
1467
self.assertEqualDiff(
1469
light checkout root: %s
1470
checkout of branch: %s
1473
control: Meta directory format 1
1474
working tree: Working tree format 3
1475
branch: Branch format 5
1479
working tree: unlocked
1481
repository: unlocked
1483
In the working tree:
1491
0 versioned subdirectories
1499
""" % (lco_tree.bzrdir.root_transport.base,
1500
lco_tree.branch.bzrdir.root_transport.base,
1501
lco_tree.branch.repository._format.get_format_description(),
1503
self.assertEqual('', err)
1504
lco_tree.branch.repository.lock_write()
1505
lco_tree.branch.unlock()
1281
self.assertCheckoutStatusOutput('tree/lightcheckout',
1285
lco_tree.branch.repository.lock_write()
1286
lco_tree.branch.unlock()
1507
1288
def test_info_locking_oslocks(self):
1289
if sys.platform == "win32":
1290
raise TestSkipped("don't use oslocks on win32 in unix manner")
1508
1292
tree = self.make_branch_and_tree('branch',
1509
1293
format=bzrlib.bzrdir.BzrDirFormat6())