48
45
self.assertEqual(out, '')
49
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
51
def test_info_empty_controldir(self):
52
self.make_bzrdir('ctrl')
53
out, err = self.run_bzr('info ctrl')
54
self.assertEquals(out,
55
'Empty control directory (format: 2a or pack-0.92)\n'
57
' control directory: ctrl\n')
58
self.assertEquals(err, '')
60
def test_info_empty_controldir_verbose(self):
61
self.make_bzrdir('ctrl')
62
out, err = self.run_bzr('info -v ctrl')
63
self.assertEqualDiff(out,
64
'Empty control directory (format: 2a or pack-0.92)\n'
66
' control directory: ctrl\n\n'
68
' control: Meta directory format 1\n\n'
69
'Control directory:\n'
71
self.assertEquals(err, '')
73
def test_info_dangling_branch_reference(self):
74
br = self.make_branch('target')
75
br.create_checkout('from', lightweight=True)
76
shutil.rmtree('target')
77
out, err = self.run_bzr('info from')
78
self.assertEquals(out,
79
'Dangling branch reference (format: 2a or pack-0.92)\n'
81
' control directory: from\n'
82
' checkout of branch: target\n')
83
self.assertEquals(err, '')
85
48
def test_info_standalone(self):
86
49
transport = self.get_transport()
88
51
# Create initial standalone branch
89
tree1 = self.make_branch_and_tree('standalone', 'knit')
52
tree1 = self.make_branch_and_tree('standalone', 'weave')
90
53
self.build_tree(['standalone/a'])
92
55
branch1 = tree1.branch
94
57
out, err = self.run_bzr('info standalone')
95
58
self.assertEqualDiff(
96
"""Standalone tree (format: knit)
59
"""Standalone tree (format: weave)
98
61
branch root: standalone
102
65
# Standalone branch - verbose mode
103
66
out, err = self.run_bzr('info standalone -v')
104
67
self.assertEqualDiff(
105
"""Standalone tree (format: knit)
68
"""Standalone tree (format: weave)
107
70
branch root: standalone
110
control: Meta directory format 1
111
working tree: Working tree format 3
112
branch: Branch format 5
113
repository: Knit repository format 1
73
control: All-in-one format 6
74
working tree: Working tree format 2
75
branch: Branch format 4
76
repository: Weave repository format 6
118
78
In the working tree:
136
96
# Standalone branch - really verbose mode
137
97
out, err = self.run_bzr('info standalone -vv')
138
98
self.assertEqualDiff(
139
"""Standalone tree (format: knit)
99
"""Standalone tree (format: weave)
141
101
branch root: standalone
144
control: Meta directory format 1
145
working tree: Working tree format 3
146
branch: Branch format 5
147
repository: Knit repository format 1
104
control: All-in-one format 6
105
working tree: Working tree format 2
106
branch: Branch format 4
107
repository: Weave repository format 6
152
109
In the working tree:
231
185
# Branch and bind to standalone, needs upgrade to metadir
232
186
# (creates backup as unknown)
233
187
branch1.bzrdir.sprout('bound')
234
knit1_format = controldir.format_registry.make_bzrdir('knit')
188
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
235
189
upgrade.upgrade('bound', knit1_format)
236
branch3 = controldir.ControlDir.open('bound').open_branch()
190
branch3 = bzrdir.BzrDir.open('bound').open_branch()
237
191
branch3.bind(branch1)
238
192
bound_tree = branch3.bzrdir.open_workingtree()
239
193
out, err = self.run_bzr('info -v bound')
368
""" % (format_description, datestring_first, datestring_first,), out)
309
""" % (self._repo_strings, datestring_first, datestring_first,), out)
369
310
self.assertEqual('', err)
371
312
# Update initial standalone branch
372
313
self.build_tree(['standalone/b'])
374
315
tree1.commit('commit two')
375
rev = branch1.repository.get_revision(branch1.last_revision())
316
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
376
317
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
378
319
# Out of date branched standalone branch will not be detected
379
320
out, err = self.run_bzr('info -v branch')
380
321
self.assertEqualDiff(
381
"""Standalone tree (format: knit)
322
"""Standalone tree (format: weave)
383
324
branch root: branch
544
""" % (format_description, datestring_first, datestring_last,), out)
473
""" % (self._repo_strings, datestring_first, datestring_last,), out)
545
474
self.assertEqual('', err)
547
476
def test_info_standalone_no_tree(self):
548
477
# create standalone branch without a working tree
549
format = controldir.format_registry.make_bzrdir('default')
478
format = bzrdir.format_registry.make_bzrdir('default')
550
479
branch = self.make_branch('branch')
551
480
repo = branch.repository
552
481
out, err = self.run_bzr('info branch -v')
1195
1070
self.assertEqual('', err)
1197
def test_info_unshared_repository_with_colocated_branches(self):
1198
format = controldir.format_registry.make_bzrdir('development-colo')
1199
transport = self.get_transport()
1201
# Create unshared repository
1202
repo = self.make_repository('repo', shared=False, format=format)
1203
repo.set_make_working_trees(True)
1204
repo.bzrdir.create_branch(name='foo')
1205
out, err = self.run_bzr('info repo')
1206
self.assertEqualDiff(
1207
"""Unshared repository with trees and colocated branches (format: development-colo)
1211
self.assertEqual('', err)
1213
1072
def assertCheckoutStatusOutput(self,
1214
1073
command_string, lco_tree, shared_repo=None,
1215
1074
repo_branch=None,
1361
1217
format=bzrdir.BzrDirMetaFormat1())
1362
1218
repo.set_make_working_trees(False)
1363
1219
repo.bzrdir.root_transport.mkdir('branch')
1364
repo_branch = controldir.ControlDir.create_branch_convenience(
1365
'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1220
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1221
format=bzrdir.BzrDirMetaFormat1())
1366
1222
# Do a heavy checkout
1367
1223
transport.mkdir('tree')
1368
1224
transport.mkdir('tree/checkout')
1369
co_branch = controldir.ControlDir.create_branch_convenience(
1370
'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1225
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
format=bzrdir.BzrDirMetaFormat1())
1371
1227
co_branch.bind(repo_branch)
1372
1228
# Do a light checkout of the heavy one
1373
1229
transport.mkdir('tree/lightcheckout')
1374
1230
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1375
lco_dir.set_branch_reference(co_branch)
1231
branch.BranchReferenceFormat().initialize(lco_dir,
1232
target_branch=co_branch)
1376
1233
lco_dir.create_workingtree()
1377
1234
lco_tree = lco_dir.open_workingtree()
1466
1323
self.knownFailure('Win32 cannot run "bzr info"'
1467
1324
' 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)
1469
1409
def test_info_stacked(self):
1470
1410
# We have a mainline
1471
1411
trunk_tree = self.make_branch_and_tree('mainline',
1484
1424
stacked on: mainline
1486
1426
self.assertEqual("", err)
1488
def test_info_revinfo_optional(self):
1489
tree = self.make_branch_and_tree('.')
1490
def last_revision_info(self):
1491
raise errors.UnsupportedOperation(last_revision_info, self)
1493
branch.Branch, "last_revision_info", last_revision_info)
1494
out, err = self.run_bzr('info -v .')
1496
"""Standalone tree (format: 2a)
1501
control: Meta directory format 1
1502
working tree: Working tree format 6
1503
branch: Branch format 7
1504
repository: Repository format 2a - rich roots, group compression and chk inventories
1509
In the working tree:
1517
0 versioned subdirectories
1519
self.assertEqual("", err)
1521
def test_info_shows_colocated_branches(self):
1522
bzrdir = self.make_branch('.', format='development-colo').bzrdir
1523
bzrdir.create_branch(name="colo1")
1524
bzrdir.create_branch(name="colo2")
1525
bzrdir.create_branch(name="colo3")
1526
out, err = self.run_bzr('info -v .')
1527
self.assertEqualDiff(
1528
"""Standalone branch (format: development-colo)
1533
control: Meta directory format 1 with support for colocated branches
1534
branch: Branch format 7
1535
repository: Repository format 2a - rich roots, group compression and chk inventories
1546
self.assertEqual("", err)
1549
class TestSmartServerInfo(tests.TestCaseWithTransport):
1551
def test_simple_branch_info(self):
1552
self.setup_smart_server_with_call_log()
1553
t = self.make_branch_and_tree('branch')
1554
self.build_tree_contents([('branch/foo', 'thecontents')])
1557
self.reset_smart_call_log()
1558
out, err = self.run_bzr(['info', self.get_url('branch')])
1559
# This figure represent the amount of work to perform this use case. It
1560
# is entirely ok to reduce this number if a test fails due to rpc_count
1561
# being too low. If rpc_count increases, more network roundtrips have
1562
# become necessary for this use case. Please do not adjust this number
1563
# upwards without agreement from bzr's network support maintainers.
1564
self.assertLength(10, self.hpss_calls)
1565
self.assertLength(1, self.hpss_connections)
1566
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
1568
def test_verbose_branch_info(self):
1569
self.setup_smart_server_with_call_log()
1570
t = self.make_branch_and_tree('branch')
1571
self.build_tree_contents([('branch/foo', 'thecontents')])
1574
self.reset_smart_call_log()
1575
out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
1576
# This figure represent the amount of work to perform this use case. It
1577
# is entirely ok to reduce this number if a test fails due to rpc_count
1578
# being too low. If rpc_count increases, more network roundtrips have
1579
# become necessary for this use case. Please do not adjust this number
1580
# upwards without agreement from bzr's network support maintainers.
1581
self.assertLength(14, self.hpss_calls)
1582
self.assertLength(1, self.hpss_connections)
1583
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)