33
41
location = "C:/i/do/not/exist/"
35
43
location = "/i/do/not/exist/"
36
out, err = self.runbzr('info '+location, retcode=3)
44
out, err = self.run_bzr('info '+location, retcode=3)
37
45
self.assertEqual(out, '')
38
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
40
48
def test_info_standalone(self):
41
49
transport = self.get_transport()
43
51
# Create initial standalone branch
44
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
45
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
46
tree1 = self.make_branch_and_tree('standalone')
47
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
52
tree1 = self.make_branch_and_tree('standalone', 'weave')
48
53
self.build_tree(['standalone/a'])
50
55
branch1 = tree1.branch
51
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
57
72
control: All-in-one format 6
233
260
self.assertEqual('', err)
235
262
# Lightweight checkout (same as above, different branch and repository)
236
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
237
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
238
transport.mkdir('lightcheckout')
239
dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
240
bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
241
dir5.create_workingtree()
242
tree5 = dir5.open_workingtree()
243
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
263
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
244
264
branch5 = tree5.branch
245
out, err = self.runbzr('info lightcheckout')
265
out, err = self.run_bzr('info -v lightcheckout')
246
266
self.assertEqualDiff(
248
light checkout root: %s
249
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
252
274
control: Meta directory format 1
253
working tree: Working tree format 3
275
working tree: Working tree format 4
254
276
branch: Branch format 4
255
277
repository: Weave repository format 6
454
474
first revision: %s
455
475
latest revision: %s
460
""" % (tree5.bzrdir.root_transport.base,
461
branch1.bzrdir.root_transport.base,
462
datestring_first, datestring_last,
480
""" % (datestring_first, datestring_last,), out)
464
481
self.assertEqual('', err)
466
483
def test_info_standalone_no_tree(self):
467
484
# create standalone branch without a working tree
485
format = bzrdir.format_registry.make_bzrdir('default')
468
486
branch = self.make_branch('branch')
469
487
repo = branch.repository
470
out, err = self.runbzr('info branch')
488
out, err = self.run_bzr('info branch -v')
471
489
self.assertEqualDiff(
490
"""Standalone branch (format: %s)
476
495
control: Meta directory format 1
477
branch: Branch format 5
486
""" % (branch.bzrdir.root_transport.base,
487
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(),
489
510
self.assertEqual('', err)
491
512
def test_info_shared_repository(self):
492
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
493
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
513
format = bzrdir.format_registry.make_bzrdir('knit')
494
514
transport = self.get_transport()
496
516
# Create shared repository
497
repo = self.make_repository('repo', shared=True)
517
repo = self.make_repository('repo', shared=True, format=format)
498
518
repo.set_make_working_trees(False)
499
out, err = self.runbzr('info repo')
519
out, err = self.run_bzr('info -v repo')
500
520
self.assertEqualDiff(
521
"""Shared repository (format: dirstate or dirstate-tags or knit)
502
523
shared repository: %s
505
526
control: Meta directory format 1
511
""" % (repo.bzrdir.root_transport.base,
512
repo._format.get_format_description(),
532
""" % ('repo', format.repository_format.get_format_description(),
514
534
self.assertEqual('', err)
516
536
# Create branch inside shared repository
517
537
repo.bzrdir.root_transport.mkdir('branch')
518
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
519
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')
520
541
self.assertEqualDiff(
522
shared repository: %s
523
repository branch: branch
542
"""Repository branch (format: dirstate or knit)
544
shared repository: repo
545
repository branch: repo/branch
526
548
control: Meta directory format 1
527
branch: Branch format 5
536
""" % (repo.bzrdir.root_transport.base,
537
repo._format.get_format_description(),
559
""" % (format.get_branch_format().get_format_description(),
560
format.repository_format.get_format_description(),
539
562
self.assertEqual('', err)
541
564
# Create lightweight checkout
542
565
transport.mkdir('tree')
543
566
transport.mkdir('tree/lightcheckout')
544
dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
545
bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
546
dir2.create_workingtree()
547
tree2 = dir2.open_workingtree()
567
tree2 = branch1.create_checkout('tree/lightcheckout',
548
569
branch2 = tree2.branch
549
out, err = self.runbzr('info tree/lightcheckout')
550
self.assertEqualDiff(
552
light checkout root: %s
553
shared repository: %s
554
repository branch: branch
557
control: Meta directory format 1
558
working tree: Working tree format 3
559
branch: Branch format 5
570
0 versioned subdirectories
578
""" % (tree2.bzrdir.root_transport.base,
579
repo.bzrdir.root_transport.base,
580
repo._format.get_format_description(),
582
self.assertEqual('', err)
570
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
571
shared_repo=repo, repo_branch=branch1, verbose=True)
584
573
# Create normal checkout
585
branch3 = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout')
586
branch3.bind(branch1)
587
tree3 = branch3.bzrdir.open_workingtree()
589
out, err = self.runbzr('info tree/checkout --verbose')
590
self.assertEqualDiff(
593
checkout of branch: %s
596
control: Meta directory format 1
597
working tree: Working tree format 3
598
branch: Branch format 5
609
0 versioned subdirectories
618
""" % (branch3.bzrdir.root_transport.base,
619
branch1.bzrdir.root_transport.base,
620
repo._format.get_format_description(),
622
self.assertEqual('', err)
574
tree3 = branch1.create_checkout('tree/checkout')
575
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
577
light_checkout=False, repo_branch=branch1)
624
578
# Update lightweight checkout
625
579
self.build_tree(['tree/lightcheckout/a'])
627
581
tree2.commit('commit one')
628
582
rev = repo.get_revision(branch2.revision_history()[0])
629
583
datestring_first = format_date(rev.timestamp, rev.timezone)
630
out, err = self.runbzr('info tree/lightcheckout --verbose')
584
out, err = self.run_bzr('info tree/lightcheckout --verbose')
631
585
self.assertEqualDiff(
633
light checkout root: %s
634
shared repository: %s
635
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
638
594
control: Meta directory format 1
639
working tree: Working tree format 3
640
branch: Branch format 5
595
working tree: Working tree format 4
643
599
In the working tree:
833
792
self.assertEqual('', err)
835
794
# Show info about repository with revisions
836
out, err = self.runbzr('info repo')
795
out, err = self.run_bzr('info -v repo')
837
796
self.assertEqualDiff(
839
shared repository: %s
797
"""Shared repository (format: dirstate or dirstate-tags or knit)
799
shared repository: repo
842
802
control: Meta directory format 1
848
""" % (repo.bzrdir.root_transport.base,
849
repo._format.get_format_description(),
808
""" % (format.repository_format.get_format_description(),
850
809
# poking at _revision_store isn't all that clean, but neither is
851
810
# having the ui test dependent on the exact overhead of a given store.
852
811
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
854
813
self.assertEqual('', err)
856
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
858
815
def test_info_shared_repository_with_trees(self):
859
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
860
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
816
format = bzrdir.format_registry.make_bzrdir('knit')
861
817
transport = self.get_transport()
863
819
# Create shared repository with working trees
864
repo = self.make_repository('repo', shared=True)
820
repo = self.make_repository('repo', shared=True, format=format)
865
821
repo.set_make_working_trees(True)
866
out, err = self.runbzr('info repo')
822
out, err = self.run_bzr('info -v repo')
867
823
self.assertEqualDiff(
869
shared repository: %s
824
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
826
shared repository: repo
872
829
control: Meta directory format 1
1071
1033
Create working tree for new branches inside the repository.
1076
""" % (repo.bzrdir.root_transport.base,
1077
repo._format.get_format_description(),
1038
""" % (format.repository_format.get_format_description(),
1078
1039
# poking at _revision_store isn't all that clean, but neither is
1079
1040
# having the ui test dependent on the exact overhead of a given store.
1080
1041
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1083
1044
self.assertEqual('', err)
1085
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1087
1046
def test_info_shared_repository_with_tree_in_root(self):
1088
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1089
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
1047
format = bzrdir.format_registry.make_bzrdir('knit')
1090
1048
transport = self.get_transport()
1092
1050
# Create shared repository with working trees
1093
repo = self.make_repository('repo', shared=True)
1051
repo = self.make_repository('repo', shared=True, format=format)
1094
1052
repo.set_make_working_trees(True)
1095
out, err = self.runbzr('info repo')
1053
out, err = self.run_bzr('info -v repo')
1096
1054
self.assertEqualDiff(
1098
shared repository: %s
1055
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1057
shared repository: repo
1101
1060
control: Meta directory format 1
1140
1099
Branch history:
1146
""" % (repo.bzrdir.root_transport.base,
1147
repo._format.get_format_description(),
1106
""" % (format.get_branch_format().get_format_description(),
1107
format.repository_format.get_format_description(),
1149
1109
self.assertEqual('', err)
1151
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)
1153
1254
def test_info_locking(self):
1154
1255
transport = self.get_transport()
1179
out, err = self.runbzr('info tree/lightcheckout')
1180
self.assertEqualDiff(
1182
light checkout root: %s
1183
checkout of branch: %s
1186
control: Meta directory format 1
1187
working tree: Working tree format 3
1188
branch: Branch format 5
1191
In the working tree:
1199
0 versioned subdirectories
1207
""" % (lco_tree.bzrdir.root_transport.base,
1208
lco_tree.branch.bzrdir.root_transport.base,
1209
lco_tree.branch.repository._format.get_format_description(),
1211
self.assertEqual('', err)
1280
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1281
repo_branch=repo_branch,
1282
verbose=True, light_checkout=True)
1213
1284
lco_tree.branch.repository.lock_write()
1214
out, err = self.runbzr('info tree/lightcheckout')
1215
self.assertEqualDiff(
1217
light checkout root: %s
1218
checkout of branch: %s
1221
control: Meta directory format 1
1222
working tree: Working tree format 3
1223
branch: Branch format 5
1227
working tree: unlocked
1231
In the working tree:
1239
0 versioned subdirectories
1247
""" % (lco_tree.bzrdir.root_transport.base,
1248
lco_tree.branch.bzrdir.root_transport.base,
1249
lco_tree.branch.repository._format.get_format_description(),
1251
self.assertEqual('', err)
1252
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()
1254
1292
lco_tree.branch.lock_write()
1255
out, err = self.runbzr('info tree/lightcheckout')
1256
self.assertEqualDiff(
1258
light checkout root: %s
1259
checkout of branch: %s
1262
control: Meta directory format 1
1263
working tree: Working tree format 3
1264
branch: Branch format 5
1268
working tree: unlocked
1272
In the working tree:
1280
0 versioned subdirectories
1288
""" % (lco_tree.bzrdir.root_transport.base,
1289
lco_tree.branch.bzrdir.root_transport.base,
1290
lco_tree.branch.repository._format.get_format_description(),
1292
self.assertEqual('', err)
1293
lco_tree.branch.unlock()
1294
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1298
repo_branch=repo_branch,
1301
lco_tree.branch.unlock()
1295
1303
lco_tree.lock_write()
1296
out, err = self.runbzr('info tree/lightcheckout')
1297
self.assertEqualDiff(
1299
light checkout root: %s
1300
checkout of branch: %s
1303
control: Meta directory format 1
1304
working tree: Working tree format 3
1305
branch: Branch format 5
1309
working tree: locked
1313
In the working tree:
1321
0 versioned subdirectories
1329
""" % (lco_tree.bzrdir.root_transport.base,
1330
lco_tree.branch.bzrdir.root_transport.base,
1331
lco_tree.branch.repository._format.get_format_description(),
1333
self.assertEqual('', err)
1305
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1306
lco_tree, repo_branch=repo_branch,
1336
1314
lco_tree.lock_write()
1337
1315
lco_tree.branch.repository.unlock()
1338
out, err = self.runbzr('info tree/lightcheckout')
1339
self.assertEqualDiff(
1341
light checkout root: %s
1342
checkout of branch: %s
1345
control: Meta directory format 1
1346
working tree: Working tree format 3
1347
branch: Branch format 5
1351
working tree: locked
1353
repository: unlocked
1355
In the working tree:
1363
0 versioned subdirectories
1371
""" % (lco_tree.bzrdir.root_transport.base,
1372
lco_tree.branch.bzrdir.root_transport.base,
1373
lco_tree.branch.repository._format.get_format_description(),
1375
self.assertEqual('', err)
1376
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()
1379
1326
lco_tree.lock_write()
1380
1327
lco_tree.branch.unlock()
1381
out, err = self.runbzr('info tree/lightcheckout')
1382
self.assertEqualDiff(
1384
light checkout root: %s
1385
checkout of branch: %s
1388
control: Meta directory format 1
1389
working tree: Working tree format 3
1390
branch: Branch format 5
1394
working tree: locked
1396
repository: unlocked
1398
In the working tree:
1406
0 versioned subdirectories
1414
""" % (lco_tree.bzrdir.root_transport.base,
1415
lco_tree.branch.bzrdir.root_transport.base,
1416
lco_tree.branch.repository._format.get_format_description(),
1418
self.assertEqual('', err)
1419
lco_tree.branch.lock_write()
1329
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1330
lco_tree, repo_branch=repo_branch,
1334
lco_tree.branch.lock_write()
1422
1337
lco_tree.lock_write()
1423
1338
lco_tree.branch.unlock()
1424
1339
lco_tree.branch.repository.lock_write()
1425
out, err = self.runbzr('info tree/lightcheckout')
1426
self.assertEqualDiff(
1428
light checkout root: %s
1429
checkout of branch: %s
1432
control: Meta directory format 1
1433
working tree: Working tree format 3
1434
branch: Branch format 5
1438
working tree: locked
1442
In the working tree:
1450
0 versioned subdirectories
1458
""" % (lco_tree.bzrdir.root_transport.base,
1459
lco_tree.branch.bzrdir.root_transport.base,
1460
lco_tree.branch.repository._format.get_format_description(),
1462
self.assertEqual('', err)
1463
lco_tree.branch.repository.unlock()
1464
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()
1467
1351
lco_tree.branch.lock_write()
1468
1352
lco_tree.branch.repository.unlock()
1469
out, err = self.runbzr('info tree/lightcheckout')
1470
self.assertEqualDiff(
1472
light checkout root: %s
1473
checkout of branch: %s
1476
control: Meta directory format 1
1477
working tree: Working tree format 3
1478
branch: Branch format 5
1482
working tree: unlocked
1484
repository: unlocked
1486
In the working tree:
1494
0 versioned subdirectories
1502
""" % (lco_tree.bzrdir.root_transport.base,
1503
lco_tree.branch.bzrdir.root_transport.base,
1504
lco_tree.branch.repository._format.get_format_description(),
1506
self.assertEqual('', err)
1507
lco_tree.branch.repository.lock_write()
1508
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.')
1510
1366
def test_info_locking_oslocks(self):
1511
1367
if sys.platform == "win32":