30
37
class TestInfo(ExternalBase):
32
39
def test_info_non_existing(self):
33
out, err = self.runbzr('info /i/do/not/exist/', retcode=3)
40
if sys.platform == "win32":
41
location = "C:/i/do/not/exist/"
43
location = "/i/do/not/exist/"
44
out, err = self.run_bzr('info '+location, retcode=3)
34
45
self.assertEqual(out, '')
35
self.assertEqual(err, 'bzr: ERROR: Not a branch: /i/do/not/exist/\n')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
37
48
def test_info_standalone(self):
38
49
transport = self.get_transport()
40
51
# 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)
52
tree1 = self.make_branch_and_tree('standalone', 'weave')
45
53
self.build_tree(['standalone/a'])
47
55
branch1 = tree1.branch
48
out, err = self.runbzr('info standalone')
57
out, err = self.run_bzr('info standalone')
59
"""Standalone tree (format: weave)
61
branch root: standalone
63
self.assertEqual('', err)
65
out, err = self.run_bzr('info standalone -v')
67
"""Standalone tree (format: weave)
69
branch root: standalone
54
72
control: All-in-one format 6
230
260
self.assertEqual('', err)
232
262
# Lightweight checkout (same as above, different branch and repository)
233
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
234
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
235
transport.mkdir('lightcheckout')
236
dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
237
bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
238
dir5.create_workingtree()
239
tree5 = dir5.open_workingtree()
240
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
263
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
241
264
branch5 = tree5.branch
242
out, err = self.runbzr('info lightcheckout')
265
out, err = self.run_bzr('info -v lightcheckout')
243
266
self.assertEqualDiff(
245
light checkout root: %s
246
checkout of branch: %s
267
"""Lightweight checkout (format: dirstate or dirstate-tags or \
268
pack-0.92 or rich-root or rich-root-pack)
270
light checkout root: lightcheckout
271
checkout of branch: standalone
249
274
control: Meta directory format 1
250
working tree: Working tree format 3
275
working tree: Working tree format 4
251
276
branch: Branch format 4
252
277
repository: Weave repository format 6
451
474
first revision: %s
452
475
latest revision: %s
457
""" % (tree5.bzrdir.root_transport.base,
458
branch1.bzrdir.root_transport.base,
459
datestring_first, datestring_last,
480
""" % (datestring_first, datestring_last,), out)
461
481
self.assertEqual('', err)
463
483
def test_info_standalone_no_tree(self):
464
484
# create standalone branch without a working tree
485
format = bzrdir.format_registry.make_bzrdir('default')
465
486
branch = self.make_branch('branch')
466
487
repo = branch.repository
467
out, err = self.runbzr('info branch')
488
out, err = self.run_bzr('info branch -v')
468
489
self.assertEqualDiff(
490
"""Standalone branch (format: %s)
473
495
control: Meta directory format 1
474
branch: Branch format 5
483
""" % (branch.bzrdir.root_transport.base,
484
repo._format.get_format_description(),
506
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
507
format.get_branch_format().get_format_description(),
508
format.repository_format.get_format_description(),
486
510
self.assertEqual('', err)
488
512
def test_info_shared_repository(self):
489
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
490
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
513
format = bzrdir.format_registry.make_bzrdir('knit')
491
514
transport = self.get_transport()
493
516
# Create shared repository
494
repo = self.make_repository('repo', shared=True)
517
repo = self.make_repository('repo', shared=True, format=format)
495
518
repo.set_make_working_trees(False)
496
out, err = self.runbzr('info repo')
519
out, err = self.run_bzr('info -v repo')
497
520
self.assertEqualDiff(
521
"""Shared repository (format: dirstate or dirstate-tags or knit)
499
523
shared repository: %s
502
526
control: Meta directory format 1
508
""" % (repo.bzrdir.root_transport.base,
509
repo._format.get_format_description(),
532
""" % ('repo', format.repository_format.get_format_description(),
511
534
self.assertEqual('', err)
513
536
# Create branch inside shared repository
514
537
repo.bzrdir.root_transport.mkdir('branch')
515
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
516
out, err = self.runbzr('info repo/branch')
538
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
540
out, err = self.run_bzr('info -v repo/branch')
517
541
self.assertEqualDiff(
519
shared repository: %s
520
repository branch: branch
542
"""Repository branch (format: dirstate or knit)
544
shared repository: repo
545
repository branch: repo/branch
523
548
control: Meta directory format 1
524
branch: Branch format 5
533
""" % (repo.bzrdir.root_transport.base,
534
repo._format.get_format_description(),
559
""" % (format.get_branch_format().get_format_description(),
560
format.repository_format.get_format_description(),
536
562
self.assertEqual('', err)
538
564
# Create lightweight checkout
539
565
transport.mkdir('tree')
540
566
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()
567
tree2 = branch1.create_checkout('tree/lightcheckout',
545
569
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)
570
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
571
shared_repo=repo, repo_branch=branch1, verbose=True)
581
573
# 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)
574
tree3 = branch1.create_checkout('tree/checkout')
575
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
577
light_checkout=False, repo_branch=branch1)
621
578
# Update lightweight checkout
622
579
self.build_tree(['tree/lightcheckout/a'])
624
581
tree2.commit('commit one')
625
582
rev = repo.get_revision(branch2.revision_history()[0])
626
583
datestring_first = format_date(rev.timestamp, rev.timezone)
627
out, err = self.runbzr('info tree/lightcheckout --verbose')
584
out, err = self.run_bzr('info tree/lightcheckout --verbose')
628
585
self.assertEqualDiff(
630
light checkout root: %s
631
shared repository: %s
632
repository branch: branch
586
"""Lightweight checkout (format: dirstate or dirstate-tags or \
587
pack-0.92 or rich-root or rich-root-pack)
589
light checkout root: tree/lightcheckout
590
checkout of branch: repo/branch
591
shared repository: repo
635
594
control: Meta directory format 1
636
working tree: Working tree format 3
637
branch: Branch format 5
595
working tree: Working tree format 4
640
599
In the working tree:
830
792
self.assertEqual('', err)
832
794
# Show info about repository with revisions
833
out, err = self.runbzr('info repo')
795
out, err = self.run_bzr('info -v repo')
834
796
self.assertEqualDiff(
836
shared repository: %s
797
"""Shared repository (format: dirstate or dirstate-tags or knit)
799
shared repository: repo
839
802
control: Meta directory format 1
845
""" % (repo.bzrdir.root_transport.base,
846
repo._format.get_format_description(),
808
""" % (format.repository_format.get_format_description(),
847
809
# poking at _revision_store isn't all that clean, but neither is
848
810
# having the ui test dependent on the exact overhead of a given store.
849
811
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
851
813
self.assertEqual('', err)
853
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
855
815
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())
816
format = bzrdir.format_registry.make_bzrdir('knit')
858
817
transport = self.get_transport()
860
819
# Create shared repository with working trees
861
repo = self.make_repository('repo', shared=True)
820
repo = self.make_repository('repo', shared=True, format=format)
862
821
repo.set_make_working_trees(True)
863
out, err = self.runbzr('info repo')
822
out, err = self.run_bzr('info -v repo')
864
823
self.assertEqualDiff(
866
shared repository: %s
824
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
826
shared repository: repo
869
829
control: Meta directory format 1
1068
1033
Create working tree for new branches inside the repository.
1073
""" % (repo.bzrdir.root_transport.base,
1074
repo._format.get_format_description(),
1038
""" % (format.repository_format.get_format_description(),
1075
1039
# poking at _revision_store isn't all that clean, but neither is
1076
1040
# having the ui test dependent on the exact overhead of a given store.
1077
1041
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1080
1044
self.assertEqual('', err)
1082
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1084
1046
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())
1047
format = bzrdir.format_registry.make_bzrdir('knit')
1087
1048
transport = self.get_transport()
1089
1050
# Create shared repository with working trees
1090
repo = self.make_repository('repo', shared=True)
1051
repo = self.make_repository('repo', shared=True, format=format)
1091
1052
repo.set_make_working_trees(True)
1092
out, err = self.runbzr('info repo')
1053
out, err = self.run_bzr('info -v repo')
1093
1054
self.assertEqualDiff(
1095
shared repository: %s
1055
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1057
shared repository: repo
1098
1060
control: Meta directory format 1
1137
1099
Branch history:
1143
""" % (repo.bzrdir.root_transport.base,
1144
repo._format.get_format_description(),
1106
""" % (format.get_branch_format().get_format_description(),
1107
format.repository_format.get_format_description(),
1146
1109
self.assertEqual('', err)
1148
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1111
def assertCheckoutStatusOutput(self,
1112
command_string, lco_tree, shared_repo=None,
1115
branch_locked=False, repo_locked=False,
1117
light_checkout=True,
1118
checkout_root=None):
1119
"""Check the output of info in a checkout.
1121
This is not quite a mirror of the info code: rather than using the
1122
tree being examined to predict output, it uses a bunch of flags which
1123
allow us, the test writers, to document what *should* be present in
1124
the output. Removing this separation would remove the value of the
1127
:param path: the path to the light checkout.
1128
:param lco_tree: the tree object for the light checkout.
1129
:param shared_repo: A shared repository is in use, expect that in
1131
:param repo_branch: A branch in a shared repository for non light
1133
:param tree_locked: If true, expect the tree to be locked.
1134
:param branch_locked: If true, expect the branch to be locked.
1135
:param repo_locked: If true, expect the repository to be locked.
1136
Note that the lco_tree.branch.repository is inspected, and if is not
1137
actually locked then this parameter is overridden. This is because
1138
pack repositories do not have any public API for obtaining an
1139
exclusive repository wide lock.
1140
:param verbose: If true, expect verbose output
1142
def friendly_location(url):
1143
path = urlutils.unescape_for_display(url, 'ascii')
1145
return osutils.relpath(osutils.getcwd(), path)
1146
except errors.PathNotChild:
1150
# We expect this to fail because of locking errors.
1151
# (A write-locked file cannot be read-locked
1152
# in the different process -- either on win32 or on linux).
1153
# This should be removed when the locking errors are fixed.
1154
self.expectFailure('OS locks are exclusive '
1155
'for different processes (Bug #174055)',
1156
self.run_bzr_subprocess,
1157
'info ' + command_string)
1158
out, err = self.run_bzr('info %s' % command_string)
1160
(True, True): 'Lightweight checkout',
1161
(True, False): 'Repository checkout',
1162
(False, True): 'Lightweight checkout',
1163
(False, False): 'Checkout',
1164
}[(shared_repo is not None, light_checkout)]
1165
format = {True: 'dirstate or dirstate-tags or pack-0.92'
1166
' or rich-root or rich-root-pack',
1167
False: 'dirstate'}[light_checkout]
1169
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1170
if repo_locked or branch_locked or tree_locked:
1171
def locked_message(a_bool):
1176
expected_lock_output = (
1179
" working tree: %s\n"
1181
" repository: %s\n" % (
1182
locked_message(tree_locked),
1183
locked_message(branch_locked),
1184
locked_message(repo_locked)))
1186
expected_lock_output = ''
1190
tree_data = (" light checkout root: %s\n" %
1191
friendly_location(lco_tree.bzrdir.root_transport.base))
1193
if lco_tree.branch.get_bound_location() is not None:
1194
tree_data += ("%s checkout root: %s\n" % (extra_space,
1195
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1196
if shared_repo is not None:
1198
" checkout of branch: %s\n"
1199
" shared repository: %s\n" %
1200
(friendly_location(repo_branch.bzrdir.root_transport.base),
1201
friendly_location(shared_repo.bzrdir.root_transport.base)))
1202
elif repo_branch is not None:
1204
"%s checkout of branch: %s\n" %
1206
friendly_location(repo_branch.bzrdir.root_transport.base)))
1208
branch_data = (" checkout of branch: %s\n" %
1209
lco_tree.branch.bzrdir.root_transport.base)
1212
verbose_info = ' 0 committers\n'
1216
self.assertEqualDiff(
1221
control: Meta directory format 1
1226
In the working tree:
1234
0 versioned subdirectories
1246
lco_tree._format.get_format_description(),
1247
lco_tree.branch._format.get_format_description(),
1248
lco_tree.branch.repository._format.get_format_description(),
1249
expected_lock_output,
1252
self.assertEqual('', err)
1150
1254
def test_info_locking(self):
1151
1255
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)
1280
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1281
repo_branch=repo_branch,
1282
verbose=True, light_checkout=True)
1210
1284
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()
1286
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1287
lco_tree, repo_branch=repo_branch,
1288
repo_locked=True, verbose=True, light_checkout=True)
1290
lco_tree.branch.repository.unlock()
1251
1292
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()
1294
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1298
repo_branch=repo_branch,
1301
lco_tree.branch.unlock()
1292
1303
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)
1305
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1306
lco_tree, repo_branch=repo_branch,
1333
1314
lco_tree.lock_write()
1334
1315
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()
1317
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1318
lco_tree, repo_branch=repo_branch,
1323
lco_tree.branch.repository.lock_write()
1376
1326
lco_tree.lock_write()
1377
1327
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()
1329
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1330
lco_tree, repo_branch=repo_branch,
1334
lco_tree.branch.lock_write()
1419
1337
lco_tree.lock_write()
1420
1338
lco_tree.branch.unlock()
1421
1339
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()
1341
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1342
lco_tree, repo_branch=repo_branch,
1347
lco_tree.branch.repository.unlock()
1348
lco_tree.branch.lock_write()
1464
1351
lco_tree.branch.lock_write()
1465
1352
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()
1354
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1355
lco_tree, repo_branch=repo_branch,
1359
lco_tree.branch.repository.lock_write()
1360
lco_tree.branch.unlock()
1362
if sys.platform == 'win32':
1363
self.knownFailure('Win32 cannot run "bzr info"'
1364
' when the tree is locked.')
1507
1366
def test_info_locking_oslocks(self):
1367
if sys.platform == "win32":
1368
raise TestSkipped("don't use oslocks on win32 in unix manner")
1508
1370
tree = self.make_branch_and_tree('branch',
1509
1371
format=bzrlib.bzrdir.BzrDirFormat6())