41
45
def test_info_non_existing(self):
42
46
self.vfs_transport_factory = memory.MemoryServer
43
47
location = self.get_url()
44
out, err = self.run_bzr('info '+location, retcode=3)
48
out, err = self.run_bzr('info ' + location, retcode=3)
45
49
self.assertEqual(out, '')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
50
self.assertEqual(err, 'brz: ERROR: Not a branch: "%s".\n' % location)
52
def test_info_empty_controldir(self):
53
self.make_controldir('ctrl')
54
out, err = self.run_bzr('info ctrl')
56
'Empty control directory (format: 2a)\n'
58
' control directory: ctrl\n')
59
self.assertEqual(err, '')
61
def test_info_empty_controldir_verbose(self):
62
self.make_controldir('ctrl')
63
out, err = self.run_bzr('info -v ctrl')
64
self.assertEqualDiff(out,
65
'Empty control directory (format: 2a)\n'
67
' control directory: ctrl\n\n'
69
' control: Meta directory format 1\n\n'
70
'Control directory:\n'
72
self.assertEqual(err, '')
74
def test_info_dangling_branch_reference(self):
75
br = self.make_branch('target')
76
br.create_checkout('from', lightweight=True)
77
shutil.rmtree('target')
78
out, err = self.run_bzr('info from')
80
'Dangling branch reference (format: 2a)\n'
82
' control directory: from\n'
83
' checkout of branch: target\n')
84
self.assertEqual(err, '')
86
def test_info_colocated(self):
87
br = self.make_branch_and_tree('target', format='development-colo')
88
target = br.controldir.create_branch(name='dichtbij')
89
br.controldir.set_branch_reference(target)
90
out, err = self.run_bzr('info target')
92
'Standalone tree (format: development-colo)\n'
94
' light checkout root: target\n'
95
' checkout of co-located branch: dichtbij\n')
96
self.assertEqual(err, '')
48
98
def test_info_standalone(self):
49
99
transport = self.get_transport()
51
101
# Create initial standalone branch
52
tree1 = self.make_branch_and_tree('standalone', 'weave')
102
tree1 = self.make_branch_and_tree('standalone', 'knit')
53
103
self.build_tree(['standalone/a'])
55
105
branch1 = tree1.branch
57
107
out, err = self.run_bzr('info standalone')
58
108
self.assertEqualDiff(
59
"""Standalone tree (format: weave)
109
"""Standalone tree (format: knit)
61
111
branch root: standalone
227
293
""" % (bound_tree._format.get_format_description(),
228
branch3._format.get_format_description(),
229
branch3.repository._format.get_format_description(),
230
datestring_first, datestring_first,
294
branch3._format.get_format_description(),
295
branch3.repository._format.get_format_description(),
296
datestring_first, datestring_first,
232
298
self.assertEqual('', err)
234
300
# Checkout standalone (same as above, but does not have parent set)
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
301
branch4 = controldir.ControlDir.create_branch_convenience('checkout',
237
303
branch4.bind(branch1)
238
branch4.bzrdir.open_workingtree().update()
304
branch4.controldir.open_workingtree().update()
239
305
out, err = self.run_bzr('info checkout --verbose')
240
306
self.assertEqualDiff(
241
"""Checkout (format: knit)
307
"""Checkout (format: knit)
243
309
checkout root: checkout
244
310
checkout of branch: standalone
434
524
""" % (branch4.repository._format.get_format_description(),
435
datestring_first, datestring_first,
525
datestring_first, datestring_first,
437
527
self.assertEqual('', err)
439
529
# Out of date lightweight checkout
440
530
out, err = self.run_bzr('info lightcheckout --verbose')
441
531
self.assertEqualDiff(
442
"""Lightweight checkout (format: %s)
532
"""Lightweight checkout (format: %s)
444
534
light checkout root: lightcheckout
445
535
checkout of branch: standalone
448
538
control: Meta directory format 1
449
working tree: Working tree format 6
450
branch: Branch format 4
451
repository: Weave repository format 6
539
working tree: Working tree format 3
540
branch: Branch format 5
541
repository: Knit repository format 1
453
546
Working tree is out of date: missing 1 revision.
553
656
transport.mkdir('tree')
554
657
transport.mkdir('tree/lightcheckout')
555
658
tree2 = branch1.create_checkout('tree/lightcheckout',
557
660
branch2 = tree2.branch
558
661
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
559
shared_repo=repo, repo_branch=branch1, verbose=True)
662
shared_repo=repo, repo_branch=branch1, verbose=True)
561
664
# Create normal checkout
562
665
tree3 = branch1.create_checkout('tree/checkout')
563
666
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
565
light_checkout=False, repo_branch=branch1)
668
light_checkout=False, repo_branch=branch1)
566
669
# Update lightweight checkout
567
670
self.build_tree(['tree/lightcheckout/a'])
569
672
tree2.commit('commit one')
570
rev = repo.get_revision(branch2.revision_history()[0])
673
rev = repo.get_revision(branch2.last_revision())
571
674
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
572
675
out, err = self.run_bzr('info tree/lightcheckout --verbose')
573
676
self.assertEqualDiff(
574
"""Lightweight checkout (format: %s)
677
"""Lightweight checkout (format: %s)
576
679
light checkout root: tree/lightcheckout
577
680
checkout of branch: repo/branch
681
796
""" % (format.get_branch_format().get_format_description(),
682
format.repository_format.get_format_description(),
683
datestring_first, datestring_first,
797
format.repository_format.get_format_description(),
798
datestring_first, datestring_first,
685
800
self.assertEqual('', err)
686
801
tree3.commit('commit two')
688
803
# Out of date lightweight checkout
689
rev = repo.get_revision(branch1.revision_history()[-1])
804
rev = repo.get_revision(branch1.last_revision())
690
805
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
691
806
out, err = self.run_bzr('info tree/lightcheckout --verbose')
692
807
self.assertEqualDiff(
693
"""Lightweight checkout (format: %s)
808
"""Lightweight checkout (format: %s)
695
810
light checkout root: tree/lightcheckout
696
811
checkout of branch: repo/branch
1041
1195
""" % (format.get_branch_format().get_format_description(),
1042
format.repository_format.get_format_description(),
1196
format.repository_format.get_format_description(),
1044
1198
self.assertEqual('', err)
1046
1200
def test_info_repository_hook(self):
1047
format = bzrdir.format_registry.make_bzrdir('knit')
1201
format = controldir.format_registry.make_controldir('knit')
1048
1203
def repo_info(repo, stats, outf):
1049
outf.write("more info\n")
1204
outf.write(u"more info\n")
1050
1205
info.hooks.install_named_hook('repository', repo_info, None)
1051
1206
# Create shared repository with working trees
1052
1207
repo = self.make_repository('repo', shared=True, format=format)
1053
1208
out, err = self.run_bzr('info -v repo')
1054
1209
self.assertEqualDiff(
1055
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1210
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1057
1212
shared repository: repo
1070
1228
self.assertEqual('', err)
1230
def test_info_unshared_repository_with_colocated_branches(self):
1231
format = controldir.format_registry.make_controldir('development-colo')
1232
transport = self.get_transport()
1234
# Create unshared repository
1235
repo = self.make_repository('repo', shared=False, format=format)
1236
repo.set_make_working_trees(True)
1237
repo.controldir.create_branch(name='foo')
1238
out, err = self.run_bzr('info repo')
1239
self.assertEqualDiff(
1240
"""Unshared repository with trees and colocated branches (format: development-colo)
1244
self.assertEqual('', err)
1072
1246
def assertCheckoutStatusOutput(self,
1073
command_string, lco_tree, shared_repo=None,
1076
branch_locked=False, repo_locked=False,
1078
light_checkout=True,
1079
checkout_root=None):
1247
command_string, lco_tree, shared_repo=None,
1250
branch_locked=False, repo_locked=False,
1252
light_checkout=True,
1253
checkout_root=None):
1080
1254
"""Check the output of info in a checkout.
1082
1256
This is not quite a mirror of the info code: rather than using the
1148
1322
extra_space = ''
1149
1323
if light_checkout:
1150
1324
tree_data = (" light checkout root: %s\n" %
1151
friendly_location(lco_tree.bzrdir.root_transport.base))
1325
friendly_location(lco_tree.controldir.root_transport.base))
1152
1326
extra_space = ' '
1153
1327
if lco_tree.branch.get_bound_location() is not None:
1154
1328
tree_data += ("%s checkout root: %s\n" % (extra_space,
1155
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1329
friendly_location(lco_tree.branch.controldir.root_transport.base)))
1156
1330
if shared_repo is not None:
1157
1331
branch_data = (
1158
1332
" checkout of branch: %s\n"
1159
1333
" shared repository: %s\n" %
1160
(friendly_location(repo_branch.bzrdir.root_transport.base),
1161
friendly_location(shared_repo.bzrdir.root_transport.base)))
1334
(friendly_location(repo_branch.controldir.root_transport.base),
1335
friendly_location(shared_repo.controldir.root_transport.base)))
1162
1336
elif repo_branch is not None:
1163
1337
branch_data = (
1164
1338
"%s checkout of branch: %s\n" %
1166
friendly_location(repo_branch.bzrdir.root_transport.base)))
1340
friendly_location(repo_branch.controldir.root_transport.base)))
1168
1342
branch_data = (" checkout of branch: %s\n" %
1169
lco_tree.branch.bzrdir.root_transport.base)
1343
lco_tree.branch.controldir.root_transport.base)
1171
1345
if verbose >= 2:
1172
1346
verbose_info = ' 0 committers\n'
1216
1394
repo = self.make_repository('repo', shared=True,
1217
1395
format=bzrdir.BzrDirMetaFormat1())
1218
1396
repo.set_make_working_trees(False)
1219
repo.bzrdir.root_transport.mkdir('branch')
1220
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1221
format=bzrdir.BzrDirMetaFormat1())
1397
repo.controldir.root_transport.mkdir('branch')
1398
repo_branch = controldir.ControlDir.create_branch_convenience(
1399
'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1222
1400
# Do a heavy checkout
1223
1401
transport.mkdir('tree')
1224
1402
transport.mkdir('tree/checkout')
1225
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
format=bzrdir.BzrDirMetaFormat1())
1403
co_branch = controldir.ControlDir.create_branch_convenience(
1404
'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1227
1405
co_branch.bind(repo_branch)
1228
1406
# Do a light checkout of the heavy one
1229
1407
transport.mkdir('tree/lightcheckout')
1230
1408
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1231
branch.BranchReferenceFormat().initialize(lco_dir,
1232
target_branch=co_branch)
1409
lco_dir.set_branch_reference(co_branch)
1233
1410
lco_dir.create_workingtree()
1234
1411
lco_tree = lco_dir.open_workingtree()
1241
1418
repo_branch=repo_branch,
1242
1419
verbose=True, light_checkout=True)
1244
lco_tree.branch.repository.lock_write()
1421
with lco_tree.branch.repository.lock_write():
1246
1422
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1247
lco_tree, repo_branch=repo_branch,
1248
repo_locked=True, verbose=True, light_checkout=True)
1250
lco_tree.branch.repository.unlock()
1423
lco_tree, repo_branch=repo_branch,
1424
repo_locked=True, verbose=True, light_checkout=True)
1252
lco_tree.branch.lock_write()
1426
with lco_tree.branch.lock_write():
1254
1427
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1258
repo_branch=repo_branch,
1261
lco_tree.branch.unlock()
1431
repo_branch=repo_branch,
1263
lco_tree.lock_write()
1434
with lco_tree.lock_write():
1265
1435
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1266
lco_tree, repo_branch=repo_branch,
1436
lco_tree, repo_branch=repo_branch,
1274
lco_tree.lock_write()
1275
lco_tree.branch.repository.unlock()
1442
with lco_tree.lock_write(), lco_tree.branch.repository.unlock():
1277
1443
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1278
lco_tree, repo_branch=repo_branch,
1283
lco_tree.branch.repository.lock_write()
1444
lco_tree, repo_branch=repo_branch,
1286
lco_tree.lock_write()
1287
lco_tree.branch.unlock()
1449
with lco_tree.lock_write(), lco_tree.branch.unlock():
1289
1450
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1290
lco_tree, repo_branch=repo_branch,
1294
lco_tree.branch.lock_write()
1451
lco_tree, repo_branch=repo_branch,
1297
lco_tree.lock_write()
1298
lco_tree.branch.unlock()
1299
lco_tree.branch.repository.lock_write()
1455
with lco_tree.lock_write(), lco_tree.branch.unlock(), \
1456
lco_tree.branch.repository.lock_write():
1301
1457
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1302
lco_tree, repo_branch=repo_branch,
1307
lco_tree.branch.repository.unlock()
1308
lco_tree.branch.lock_write()
1458
lco_tree, repo_branch=repo_branch,
1311
lco_tree.branch.lock_write()
1312
lco_tree.branch.repository.unlock()
1463
with lco_tree.branch.lock_write(), lco_tree.branch.repository.unlock():
1314
1464
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1315
lco_tree, repo_branch=repo_branch,
1319
lco_tree.branch.repository.lock_write()
1320
lco_tree.branch.unlock()
1465
lco_tree, repo_branch=repo_branch,
1322
1469
if sys.platform == 'win32':
1323
self.knownFailure('Win32 cannot run "bzr info"'
1470
self.knownFailure('Win32 cannot run "brz info"'
1324
1471
' when the tree is locked.')
1326
def test_info_locking_oslocks(self):
1327
if sys.platform == "win32":
1328
self.skip("don't use oslocks on win32 in unix manner")
1329
# This test tests old (all-in-one, OS lock using) behaviour which
1330
# simply cannot work on windows (and is indeed why we changed our
1331
# design. As such, don't try to remove the thisFailsStrictLockCheck
1333
self.thisFailsStrictLockCheck()
1335
tree = self.make_branch_and_tree('branch',
1336
format=bzrdir.BzrDirFormat6())
1338
# Test all permutations of locking the working tree, branch and repository
1339
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1340
# implemented by raising NotImplementedError and get_physical_lock_status()
1341
# always returns false. This makes bzr info hide the lock status. (Olaf)
1345
out, err = self.run_bzr('info -v branch')
1346
self.assertEqualDiff(
1347
"""Standalone tree (format: weave)
1352
control: All-in-one format 6
1353
working tree: Working tree format 2
1354
branch: Branch format 4
1357
In the working tree:
1365
0 versioned subdirectories
1372
""" % ('branch', tree.branch.repository._format.get_format_description(),
1374
self.assertEqual('', err)
1377
out, err = self.run_bzr('info -v branch')
1378
self.assertEqualDiff(
1379
"""Standalone tree (format: weave)
1384
control: All-in-one format 6
1385
working tree: Working tree format 2
1386
branch: Branch format 4
1389
In the working tree:
1397
0 versioned subdirectories
1404
""" % ('branch', tree.branch.repository._format.get_format_description(),
1406
self.assertEqual('', err)
1409
1473
def test_info_stacked(self):
1410
1474
# We have a mainline
1411
1475
trunk_tree = self.make_branch_and_tree('mainline',
1413
1477
trunk_tree.commit('mainline')
1414
1478
# and a branch from it which is stacked
1415
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1479
new_dir = trunk_tree.controldir.sprout('newbranch', stacked=True)
1416
1480
out, err = self.run_bzr('info newbranch')
1417
1481
self.assertEqual(
1418
"""Standalone tree (format: 1.6)
1482
"""Standalone tree (format: 1.6)
1420
1484
branch root: newbranch
1424
1488
stacked on: mainline
1426
1490
self.assertEqual("", err)
1492
def test_info_revinfo_optional(self):
1493
tree = self.make_branch_and_tree('.')
1495
def last_revision_info(self):
1496
raise errors.UnsupportedOperation(last_revision_info, self)
1498
branch.Branch, "last_revision_info", last_revision_info)
1499
out, err = self.run_bzr('info -v .')
1501
"""Standalone tree (format: 2a)
1506
control: Meta directory format 1
1507
working tree: Working tree format 6
1508
branch: Branch format 7
1509
repository: Repository format 2a - rich roots, group compression and chk inventories
1514
In the working tree:
1523
0 versioned subdirectories
1525
self.assertEqual("", err)
1527
def test_info_shows_colocated_branches(self):
1528
bzrdir = self.make_branch('.', format='development-colo').controldir
1529
bzrdir.create_branch(name="colo1")
1530
bzrdir.create_branch(name="colo2")
1531
bzrdir.create_branch(name="colo3")
1532
out, err = self.run_bzr('info -v .')
1533
self.assertEqualDiff(
1534
"""Standalone branch (format: development-colo)
1539
control: Meta directory format 1 with support for colocated branches
1540
branch: Branch format 7
1541
repository: Repository format 2a - rich roots, group compression and chk inventories
1552
self.assertEqual("", err)