32
30
class TestInfo(ExternalBase):
34
32
def test_info_non_existing(self):
35
if sys.platform == "win32":
36
location = "C:/i/do/not/exist/"
38
location = "/i/do/not/exist/"
39
out, err = self.run_bzr('info '+location, retcode=3)
33
out, err = self.runbzr('info /i/do/not/exist/', retcode=3)
40
34
self.assertEqual(out, '')
41
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
35
self.assertEqual(err, 'bzr: ERROR: Not a branch: /i/do/not/exist/\n')
43
37
def test_info_standalone(self):
44
38
transport = self.get_transport()
46
40
# Create initial standalone branch
47
tree1 = self.make_branch_and_tree('standalone', 'weave')
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)
48
45
self.build_tree(['standalone/a'])
50
47
branch1 = tree1.branch
51
out, err = self.run_bzr('info standalone -v')
48
out, err = self.runbzr('info standalone')
52
49
self.assertEqualDiff(
53
"""Standalone tree (format: weave)
476
463
def test_info_standalone_no_tree(self):
477
464
# create standalone branch without a working tree
478
format = bzrdir.format_registry.make_bzrdir('default')
479
465
branch = self.make_branch('branch')
480
466
repo = branch.repository
481
out, err = self.run_bzr('info branch -v')
467
out, err = self.runbzr('info branch')
482
468
self.assertEqualDiff(
483
"""Standalone branch (format: dirstate or knit)
488
473
control: Meta directory format 1
474
branch: Branch format 5
499
483
""" % (branch.bzrdir.root_transport.base,
500
format.get_branch_format().get_format_description(),
501
format.repository_format.get_format_description(),
484
repo._format.get_format_description(),
503
486
self.assertEqual('', err)
505
488
def test_info_shared_repository(self):
506
format = bzrdir.format_registry.make_bzrdir('knit')
489
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
490
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
507
491
transport = self.get_transport()
509
493
# Create shared repository
510
repo = self.make_repository('repo', shared=True, format=format)
494
repo = self.make_repository('repo', shared=True)
511
495
repo.set_make_working_trees(False)
512
out, err = self.run_bzr('info -v repo')
496
out, err = self.runbzr('info repo')
513
497
self.assertEqualDiff(
514
"""Shared repository (format: dirstate or dirstate-tags or knit)
516
499
shared repository: %s
519
502
control: Meta directory format 1
525
508
""" % (repo.bzrdir.root_transport.base,
526
format.repository_format.get_format_description(),
509
repo._format.get_format_description(),
528
511
self.assertEqual('', err)
530
513
# Create branch inside shared repository
531
514
repo.bzrdir.root_transport.mkdir('branch')
532
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
534
out, err = self.run_bzr('info -v repo/branch')
515
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
516
out, err = self.runbzr('info repo/branch')
535
517
self.assertEqualDiff(
536
"""Repository branch (format: dirstate or knit)
538
519
shared repository: %s
539
520
repository branch: branch
542
523
control: Meta directory format 1
524
branch: Branch format 5
553
533
""" % (repo.bzrdir.root_transport.base,
554
format.get_branch_format().get_format_description(),
555
format.repository_format.get_format_description(),
534
repo._format.get_format_description(),
557
536
self.assertEqual('', err)
559
538
# Create lightweight checkout
560
539
transport.mkdir('tree')
561
540
transport.mkdir('tree/lightcheckout')
562
tree2 = branch1.create_checkout('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()
564
545
branch2 = tree2.branch
565
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
566
shared_repo=repo, repo_branch=branch1, verbose=True)
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)
568
581
# Create normal checkout
569
tree3 = branch1.create_checkout('tree/checkout')
570
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
572
light_checkout=False, repo_branch=branch1)
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)
573
621
# Update lightweight checkout
574
622
self.build_tree(['tree/lightcheckout/a'])
576
624
tree2.commit('commit one')
577
625
rev = repo.get_revision(branch2.revision_history()[0])
578
626
datestring_first = format_date(rev.timestamp, rev.timezone)
579
out, err = self.run_bzr('info tree/lightcheckout --verbose')
627
out, err = self.runbzr('info tree/lightcheckout --verbose')
580
628
self.assertEqualDiff(
581
"""Lightweight checkout (format: dirstate or dirstate-tags)
583
630
light checkout root: %s
584
checkout of branch: %s
585
631
shared repository: %s
632
repository branch: branch
588
635
control: Meta directory format 1
589
working tree: Working tree format 4
636
working tree: Working tree format 3
637
branch: Branch format 5
593
640
In the working tree:
795
830
self.assertEqual('', err)
797
832
# Show info about repository with revisions
798
out, err = self.run_bzr('info -v repo')
833
out, err = self.runbzr('info repo')
799
834
self.assertEqualDiff(
800
"""Shared repository (format: dirstate or dirstate-tags or knit)
802
836
shared repository: %s
805
839
control: Meta directory format 1
811
845
""" % (repo.bzrdir.root_transport.base,
812
format.repository_format.get_format_description(),
846
repo._format.get_format_description(),
813
847
# poking at _revision_store isn't all that clean, but neither is
814
848
# having the ui test dependent on the exact overhead of a given store.
815
849
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
817
851
self.assertEqual('', err)
853
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
819
855
def test_info_shared_repository_with_trees(self):
820
format = bzrdir.format_registry.make_bzrdir('knit')
856
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
857
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
821
858
transport = self.get_transport()
823
860
# Create shared repository with working trees
824
repo = self.make_repository('repo', shared=True, format=format)
861
repo = self.make_repository('repo', shared=True)
825
862
repo.set_make_working_trees(True)
826
out, err = self.run_bzr('info -v repo')
863
out, err = self.runbzr('info repo')
827
864
self.assertEqualDiff(
828
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
830
866
shared repository: %s
1044
1068
Create working tree for new branches inside the repository.
1049
1073
""" % (repo.bzrdir.root_transport.base,
1050
format.repository_format.get_format_description(),
1074
repo._format.get_format_description(),
1051
1075
# poking at _revision_store isn't all that clean, but neither is
1052
1076
# having the ui test dependent on the exact overhead of a given store.
1053
1077
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1056
1080
self.assertEqual('', err)
1082
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1058
1084
def test_info_shared_repository_with_tree_in_root(self):
1059
format = bzrdir.format_registry.make_bzrdir('knit')
1085
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1086
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
1060
1087
transport = self.get_transport()
1062
1089
# Create shared repository with working trees
1063
repo = self.make_repository('repo', shared=True, format=format)
1090
repo = self.make_repository('repo', shared=True)
1064
1091
repo.set_make_working_trees(True)
1065
out, err = self.run_bzr('info -v repo')
1092
out, err = self.runbzr('info repo')
1066
1093
self.assertEqualDiff(
1067
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1069
1095
shared repository: %s
1112
1137
Branch history:
1119
1143
""" % (repo.bzrdir.root_transport.base,
1120
format.get_branch_format().get_format_description(),
1121
format.repository_format.get_format_description(),
1144
repo._format.get_format_description(),
1123
1146
self.assertEqual('', err)
1125
def assertCheckoutStatusOutput(self,
1126
command_string, lco_tree, shared_repo=None,
1129
branch_locked=False, repo_locked=False,
1131
light_checkout=True,
1132
checkout_root=None):
1133
"""Check the output of info in a checkout.
1135
This is not quite a mirror of the info code: rather than using the
1136
tree being examined to predict output, it uses a bunch of flags which
1137
allow us, the test writers, to document what *should* be present in
1138
the output. Removing this separation would remove the value of the
1141
:param path: the path to the light checkout.
1142
:param lco_tree: the tree object for the light checkout.
1143
:param shared_repo: A shared repository is in use, expect that in
1145
:param repo_branch: A branch in a shared repository for non light
1147
:param tree_locked: If true, expect the tree to be locked.
1148
:param branch_locked: If true, expect the branch to be locked.
1149
:param repo_locked: If true, expect the repository to be locked.
1150
:param verbose: If true, expect verbose output
1152
if tree_locked and sys.platform == 'win32':
1153
# We expect this to fail because of locking errors. (A write-locked
1154
# file cannot be read-locked in the same process).
1155
# This should be removed when the locking errors are fixed.
1156
args = command_string.split(' ')
1157
self.run_bzr_error([], 'info', *args)
1159
out, err = self.run_bzr('info %s' % command_string)
1161
(True, True): 'Lightweight checkout',
1162
(True, False): 'Repository checkout',
1163
(False, True): 'Lightweight checkout',
1164
(False, False): 'Checkout',
1165
}[(shared_repo is not None, light_checkout)]
1166
format = {True: 'dirstate or dirstate-tags',
1167
False: 'dirstate'}[light_checkout]
1168
if repo_locked or branch_locked or tree_locked:
1169
def locked_message(a_bool):
1174
expected_lock_output = (
1177
" working tree: %s\n"
1179
" repository: %s\n" % (
1180
locked_message(tree_locked),
1181
locked_message(branch_locked),
1182
locked_message(repo_locked)))
1184
expected_lock_output = ''
1188
tree_data = (" light checkout root: %s\n" %
1189
lco_tree.bzrdir.root_transport.base)
1191
if lco_tree.branch.get_bound_location() is not None:
1192
tree_data += ("%s checkout root: %s\n" % (extra_space,
1193
lco_tree.branch.bzrdir.root_transport.base))
1194
if shared_repo is not None:
1196
" checkout of branch: %s\n"
1197
" shared repository: %s\n" %
1198
(repo_branch.bzrdir.root_transport.base,
1199
shared_repo.bzrdir.root_transport.base))
1200
elif repo_branch is not None:
1202
"%s checkout of branch: %s\n" %
1204
repo_branch.bzrdir.root_transport.base))
1206
branch_data = (" checkout of branch: %s\n" %
1207
lco_tree.branch.bzrdir.root_transport.base)
1210
verbose_info = ' 0 committers\n'
1214
self.assertEqualDiff(
1219
control: Meta directory format 1
1224
In the working tree:
1232
0 versioned subdirectories
1244
lco_tree._format.get_format_description(),
1245
lco_tree.branch._format.get_format_description(),
1246
lco_tree.branch.repository._format.get_format_description(),
1247
expected_lock_output,
1250
self.assertEqual('', err)
1148
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1252
1150
def test_info_locking(self):
1253
1151
transport = self.get_transport()
1278
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1279
repo_branch=repo_branch,
1280
verbose=True, light_checkout=True)
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)
1282
1210
lco_tree.branch.repository.lock_write()
1284
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1285
lco_tree, repo_branch=repo_branch,
1286
repo_locked=True, verbose=True, light_checkout=True)
1288
lco_tree.branch.repository.unlock()
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()
1290
1251
lco_tree.branch.lock_write()
1292
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1296
repo_branch=repo_branch,
1299
lco_tree.branch.unlock()
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()
1301
1292
lco_tree.lock_write()
1303
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1304
lco_tree, repo_branch=repo_branch,
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)
1312
1333
lco_tree.lock_write()
1313
1334
lco_tree.branch.repository.unlock()
1315
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1316
lco_tree, repo_branch=repo_branch,
1321
lco_tree.branch.repository.lock_write()
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()
1324
1376
lco_tree.lock_write()
1325
1377
lco_tree.branch.unlock()
1327
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1328
lco_tree, repo_branch=repo_branch,
1332
lco_tree.branch.lock_write()
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()
1335
1419
lco_tree.lock_write()
1336
1420
lco_tree.branch.unlock()
1337
1421
lco_tree.branch.repository.lock_write()
1339
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1340
lco_tree, repo_branch=repo_branch,
1345
lco_tree.branch.repository.unlock()
1346
lco_tree.branch.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()
1349
1464
lco_tree.branch.lock_write()
1350
1465
lco_tree.branch.repository.unlock()
1352
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1353
lco_tree, repo_branch=repo_branch,
1357
lco_tree.branch.repository.lock_write()
1358
lco_tree.branch.unlock()
1360
if sys.platform == 'win32':
1361
self.knownFailure('Win32 cannot run "bzr info"'
1362
' when the tree is locked.')
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()
1364
1507
def test_info_locking_oslocks(self):
1365
if sys.platform == "win32":
1366
raise TestSkipped("don't use oslocks on win32 in unix manner")
1368
1508
tree = self.make_branch_and_tree('branch',
1369
1509
format=bzrlib.bzrdir.BzrDirFormat6())