13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
"""Tests for the info command of bzr."""
23
23
from bzrlib import (
27
from bzrlib.osutils import format_date
28
from bzrlib.tests import TestSkipped
29
from bzrlib.tests.blackbox import ExternalBase
32
class TestInfo(ExternalBase):
34
from bzrlib.tests.matchers import ContainsNoVfsCalls
35
from bzrlib.transport import memory
38
class TestInfo(tests.TestCaseWithTransport):
41
super(TestInfo, self).setUp()
42
self._repo_strings = "2a"
34
44
def test_info_non_existing(self):
35
if sys.platform == "win32":
36
location = "C:/i/do/not/exist/"
38
location = "/i/do/not/exist/"
45
self.vfs_transport_factory = memory.MemoryServer
46
location = self.get_url()
39
47
out, err = self.run_bzr('info '+location, retcode=3)
40
48
self.assertEqual(out, '')
41
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
49
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, '')
43
85
def test_info_standalone(self):
44
86
transport = self.get_transport()
46
88
# Create initial standalone branch
47
tree1 = self.make_branch_and_tree('standalone', 'weave')
89
tree1 = self.make_branch_and_tree('standalone', 'knit')
48
90
self.build_tree(['standalone/a'])
50
92
branch1 = tree1.branch
94
out, err = self.run_bzr('info standalone')
96
"""Standalone tree (format: knit)
98
branch root: standalone
100
self.assertEqual('', err)
102
# Standalone branch - verbose mode
51
103
out, err = self.run_bzr('info standalone -v')
52
104
self.assertEqualDiff(
53
"""Standalone tree (format: weave)
58
control: All-in-one format 6
59
working tree: Working tree format 2
60
branch: Branch format 4
61
repository: Weave repository format 6
105
"""Standalone tree (format: knit)
107
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
126
0 versioned subdirectories
134
self.assertEqual('', err)
136
# Standalone branch - really verbose mode
137
out, err = self.run_bzr('info standalone -vv')
138
self.assertEqualDiff(
139
"""Standalone tree (format: knit)
141
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
63
152
In the working tree:
80
""" % branch1.bzrdir.root_transport.base, out)
81
169
self.assertEqual('', err)
82
170
tree1.commit('commit one')
83
rev = branch1.repository.get_revision(branch1.revision_history()[0])
84
datestring_first = format_date(rev.timestamp, rev.timezone)
171
rev = branch1.repository.get_revision(branch1.last_revision())
172
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
86
174
# Branch standalone with push location
87
175
branch2 = branch1.bzrdir.sprout('branch').open_branch()
88
176
branch2.set_push_location(branch1.bzrdir.root_transport.base)
178
out, err = self.run_bzr('info branch')
179
self.assertEqualDiff(
180
"""Standalone tree (format: knit)
185
push branch: standalone
186
parent branch: standalone
188
self.assertEqual('', err)
89
190
out, err = self.run_bzr('info branch --verbose')
90
191
self.assertEqualDiff(
91
"""Standalone tree (format: weave)
192
"""Standalone tree (format: knit)
197
push branch: standalone
198
parent branch: standalone
100
control: All-in-one format 6
101
working tree: Working tree format 2
102
branch: Branch format 4
103
repository: Weave repository format 6
201
control: Meta directory format 1
202
working tree: Working tree format 3
203
branch: Branch format 5
204
repository: Knit repository format 1
105
209
In the working tree:
119
222
first revision: %s
120
223
latest revision: %s
125
""" % (branch2.bzrdir.root_transport.base,
126
branch1.bzrdir.root_transport.base,
127
branch1.bzrdir.root_transport.base,
128
datestring_first, datestring_first,
129
# poking at _revision_store isn't all that clean, but neither is
130
# having the ui test dependent on the exact overhead of a given store.
131
branch2.repository._revision_store.total_size(
132
branch2.repository.get_transaction())[1] / 1024,
227
""" % (datestring_first, datestring_first,
134
229
self.assertEqual('', err)
136
231
# Branch and bind to standalone, needs upgrade to metadir
137
232
# (creates backup as unknown)
138
233
branch1.bzrdir.sprout('bound')
139
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
140
bzrlib.upgrade.upgrade('bound', knit1_format)
141
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
234
knit1_format = controldir.format_registry.make_bzrdir('knit')
235
upgrade.upgrade('bound', knit1_format)
236
branch3 = controldir.ControlDir.open('bound').open_branch()
142
237
branch3.bind(branch1)
143
238
bound_tree = branch3.bzrdir.open_workingtree()
144
239
out, err = self.run_bzr('info -v bound')
145
240
self.assertEqualDiff(
146
241
"""Checkout (format: knit)
149
checkout of branch: %s
244
checkout of branch: standalone
151
246
Related branches:
247
parent branch: standalone
155
250
control: Meta directory format 1
160
258
In the working tree:
168
266
0 versioned subdirectories
174
271
first revision: %s
175
272
latest revision: %s
180
""" % (branch3.bzrdir.root_transport.base,
181
branch1.bzrdir.root_transport.base,
182
branch1.bzrdir.root_transport.base,
183
bound_tree._format.get_format_description(),
276
""" % (bound_tree._format.get_format_description(),
184
277
branch3._format.get_format_description(),
185
278
branch3.repository._format.get_format_description(),
186
279
datestring_first, datestring_first,
187
# poking at _revision_store isn't all that clean, but neither is
188
# having the ui test dependent on the exact overhead of a given store.
189
branch3.repository._revision_store.total_size(
190
branch3.repository.get_transaction())[1] / 1024,
192
281
self.assertEqual('', err)
194
283
# Checkout standalone (same as above, but does not have parent set)
195
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
284
branch4 = controldir.ControlDir.create_branch_convenience('checkout',
196
285
format=knit1_format)
197
286
branch4.bind(branch1)
198
287
branch4.bzrdir.open_workingtree().update()
273
363
first revision: %s
274
364
latest revision: %s
279
""" % (tree5.bzrdir.root_transport.base,
280
branch1.bzrdir.root_transport.base,
281
datestring_first, datestring_first,
368
""" % (format_description, datestring_first, datestring_first,), out)
283
369
self.assertEqual('', err)
285
371
# Update initial standalone branch
286
372
self.build_tree(['standalone/b'])
288
374
tree1.commit('commit two')
289
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
290
datestring_last = format_date(rev.timestamp, rev.timezone)
375
rev = branch1.repository.get_revision(branch1.last_revision())
376
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
292
378
# Out of date branched standalone branch will not be detected
293
379
out, err = self.run_bzr('info -v branch')
294
380
self.assertEqualDiff(
295
"""Standalone tree (format: weave)
381
"""Standalone tree (format: knit)
299
385
Related branches:
301
publish to branch: %s
386
push branch: standalone
387
parent branch: standalone
304
control: All-in-one format 6
305
working tree: Working tree format 2
306
branch: Branch format 4
307
repository: Weave repository format 6
390
control: Meta directory format 1
391
working tree: Working tree format 3
392
branch: Branch format 5
393
repository: Knit repository format 1
309
398
In the working tree:
417
497
first revision: %s
418
498
latest revision: %s
423
""" % (branch4.bzrdir.root_transport.base,
424
branch1.bzrdir.root_transport.base,
425
branch4.repository._format.get_format_description(),
502
""" % (branch4.repository._format.get_format_description(),
426
503
datestring_first, datestring_first,
427
# poking at _revision_store isn't all that clean, but neither is
428
# having the ui test dependent on the exact overhead of a given store.
429
branch4.repository._revision_store.total_size(
430
branch4.repository.get_transaction())[1] / 1024,
432
505
self.assertEqual('', err)
434
507
# Out of date lightweight checkout
435
508
out, err = self.run_bzr('info lightcheckout --verbose')
436
509
self.assertEqualDiff(
437
"""Lightweight checkout (format: dirstate or dirstate-tags)
510
"""Lightweight checkout (format: %s)
439
light checkout root: %s
440
checkout of branch: %s
512
light checkout root: lightcheckout
513
checkout of branch: standalone
443
516
control: Meta directory format 1
444
working tree: Working tree format 4
445
branch: Branch format 4
446
repository: Weave repository format 6
517
working tree: Working tree format 3
518
branch: Branch format 5
519
repository: Knit repository format 1
448
524
Working tree is out of date: missing 1 revision.
464
539
first revision: %s
465
540
latest revision: %s
470
""" % (tree5.bzrdir.root_transport.base,
471
branch1.bzrdir.root_transport.base,
472
datestring_first, datestring_last,
544
""" % (format_description, datestring_first, datestring_last,), out)
474
545
self.assertEqual('', err)
476
547
def test_info_standalone_no_tree(self):
477
548
# create standalone branch without a working tree
478
format = bzrdir.format_registry.make_bzrdir('default')
549
format = controldir.format_registry.make_bzrdir('default')
479
550
branch = self.make_branch('branch')
480
551
repo = branch.repository
481
552
out, err = self.run_bzr('info branch -v')
482
553
self.assertEqualDiff(
483
"""Standalone branch (format: dirstate or knit)
554
"""Standalone branch (format: %s)
488
559
control: Meta directory format 1
499
""" % (branch.bzrdir.root_transport.base,
571
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
500
572
format.get_branch_format().get_format_description(),
501
573
format.repository_format.get_format_description(),
503
575
self.assertEqual('', err)
505
577
def test_info_shared_repository(self):
506
format = bzrdir.format_registry.make_bzrdir('knit')
578
format = controldir.format_registry.make_bzrdir('knit')
507
579
transport = self.get_transport()
509
581
# Create shared repository
519
591
control: Meta directory format 1
525
""" % (repo.bzrdir.root_transport.base,
526
format.repository_format.get_format_description(),
599
""" % ('repo', format.repository_format.get_format_description(),
528
601
self.assertEqual('', err)
530
603
# Create branch inside shared repository
531
604
repo.bzrdir.root_transport.mkdir('branch')
532
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
605
branch1 = controldir.ControlDir.create_branch_convenience(
606
'repo/branch', format=format)
534
607
out, err = self.run_bzr('info -v repo/branch')
535
608
self.assertEqualDiff(
536
609
"""Repository branch (format: dirstate or knit)
538
shared repository: %s
539
repository branch: branch
611
shared repository: repo
612
repository branch: repo/branch
542
615
control: Meta directory format 1
553
""" % (repo.bzrdir.root_transport.base,
554
format.get_branch_format().get_format_description(),
627
""" % (format.get_branch_format().get_format_description(),
555
628
format.repository_format.get_format_description(),
557
630
self.assertEqual('', err)
607
682
first revision: %s
608
683
latest revision: %s
613
""" % (tree2.bzrdir.root_transport.base,
614
tree2.branch.bzrdir.root_transport.base,
615
repo.bzrdir.root_transport.base,
616
format.get_branch_format().get_format_description(),
687
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
617
688
format.repository_format.get_format_description(),
618
689
datestring_first, datestring_first,
619
# poking at _revision_store isn't all that clean, but neither is
620
# having the ui test dependent on the exact overhead of a given store.
621
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
623
691
self.assertEqual('', err)
625
693
# Out of date checkout
626
694
out, err = self.run_bzr('info -v tree/checkout')
627
695
self.assertEqualDiff(
628
"""Checkout (format: dirstate)
696
"""Checkout (format: unnamed)
631
checkout of branch: %s
698
checkout root: tree/checkout
699
checkout of branch: repo/branch
634
702
control: Meta directory format 1
635
working tree: Working tree format 4
703
working tree: Working tree format 6
639
710
Branch is out of date: missing 1 revision.
641
712
In the working tree:
696
765
first revision: %s
697
766
latest revision: %s
702
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
703
format.get_branch_format().get_format_description(),
770
""" % (format.get_branch_format().get_format_description(),
704
771
format.repository_format.get_format_description(),
705
772
datestring_first, datestring_first,
706
# poking at _revision_store isn't all that clean, but neither is
707
# having the ui test dependent on the exact overhead of a given store.
708
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
710
774
self.assertEqual('', err)
711
775
tree3.commit('commit two')
713
777
# Out of date lightweight checkout
714
rev = repo.get_revision(branch1.revision_history()[-1])
715
datestring_last = format_date(rev.timestamp, rev.timezone)
778
rev = repo.get_revision(branch1.last_revision())
779
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
716
780
out, err = self.run_bzr('info tree/lightcheckout --verbose')
717
781
self.assertEqualDiff(
718
"""Lightweight checkout (format: dirstate or dirstate-tags)
782
"""Lightweight checkout (format: %s)
720
light checkout root: %s
721
checkout of branch: %s
722
shared repository: %s
784
light checkout root: tree/lightcheckout
785
checkout of branch: repo/branch
786
shared repository: repo
725
789
control: Meta directory format 1
726
working tree: Working tree format 4
790
working tree: Working tree format 6
730
797
Working tree is out of date: missing 1 revision.
732
799
In the working tree:
1035
1079
self.assertEqualDiff(
1036
1080
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1038
shared repository: %s
1082
shared repository: repo
1041
1085
control: Meta directory format 1
1044
1091
Create working tree for new branches inside the repository.
1049
""" % (repo.bzrdir.root_transport.base,
1050
format.repository_format.get_format_description(),
1051
# poking at _revision_store isn't all that clean, but neither is
1052
# having the ui test dependent on the exact overhead of a given store.
1053
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1095
""" % (format.repository_format.get_format_description(),
1056
1098
self.assertEqual('', err)
1058
1100
def test_info_shared_repository_with_tree_in_root(self):
1059
format = bzrdir.format_registry.make_bzrdir('knit')
1101
format = controldir.format_registry.make_bzrdir('knit')
1060
1102
transport = self.get_transport()
1062
1104
# Create shared repository with working trees
1112
1158
Branch history:
1119
""" % (repo.bzrdir.root_transport.base,
1120
format.get_branch_format().get_format_description(),
1163
""" % (format.get_branch_format().get_format_description(),
1121
1164
format.repository_format.get_format_description(),
1123
1166
self.assertEqual('', err)
1125
def assertCheckoutStatusOutput(self,
1168
def test_info_repository_hook(self):
1169
format = controldir.format_registry.make_bzrdir('knit')
1170
def repo_info(repo, stats, outf):
1171
outf.write("more info\n")
1172
info.hooks.install_named_hook('repository', repo_info, None)
1173
# Create shared repository with working trees
1174
repo = self.make_repository('repo', shared=True, format=format)
1175
out, err = self.run_bzr('info -v repo')
1176
self.assertEqualDiff(
1177
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1179
shared repository: repo
1182
control: Meta directory format 1
1188
Create working tree for new branches inside the repository.
1193
""" % (format.repository_format.get_format_description(),
1195
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
def assertCheckoutStatusOutput(self,
1126
1214
command_string, lco_tree, shared_repo=None,
1127
1215
repo_branch=None,
1128
1216
tree_locked=False,
1147
1235
:param tree_locked: If true, expect the tree to be locked.
1148
1236
:param branch_locked: If true, expect the branch to be locked.
1149
1237
:param repo_locked: If true, expect the repository to be locked.
1150
:param verbose: If true, expect verbose output
1238
Note that the lco_tree.branch.repository is inspected, and if is not
1239
actually locked then this parameter is overridden. This is because
1240
pack repositories do not have any public API for obtaining an
1241
exclusive repository wide lock.
1242
:param verbose: verbosity level: 2 or higher to show committers
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).
1244
def friendly_location(url):
1245
path = urlutils.unescape_for_display(url, 'ascii')
1247
return osutils.relpath(osutils.getcwd(), path)
1248
except errors.PathNotChild:
1252
# We expect this to fail because of locking errors.
1253
# (A write-locked file cannot be read-locked
1254
# in the different process -- either on win32 or on linux).
1155
1255
# This should be removed when the locking errors are fixed.
1156
args = command_string.split(' ')
1157
self.run_bzr_error([], 'info', *args)
1256
self.expectFailure('OS locks are exclusive '
1257
'for different processes (Bug #174055)',
1258
self.run_bzr_subprocess,
1259
'info ' + command_string)
1159
1260
out, err = self.run_bzr('info %s' % command_string)
1160
1261
description = {
1161
1262
(True, True): 'Lightweight checkout',
1186
1289
extra_space = ''
1187
1290
if light_checkout:
1188
1291
tree_data = (" light checkout root: %s\n" %
1189
lco_tree.bzrdir.root_transport.base)
1292
friendly_location(lco_tree.bzrdir.root_transport.base))
1190
1293
extra_space = ' '
1191
1294
if lco_tree.branch.get_bound_location() is not None:
1192
1295
tree_data += ("%s checkout root: %s\n" % (extra_space,
1193
lco_tree.branch.bzrdir.root_transport.base))
1296
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1194
1297
if shared_repo is not None:
1195
1298
branch_data = (
1196
1299
" checkout of branch: %s\n"
1197
1300
" shared repository: %s\n" %
1198
(repo_branch.bzrdir.root_transport.base,
1199
shared_repo.bzrdir.root_transport.base))
1301
(friendly_location(repo_branch.bzrdir.root_transport.base),
1302
friendly_location(shared_repo.bzrdir.root_transport.base)))
1200
1303
elif repo_branch is not None:
1201
1304
branch_data = (
1202
1305
"%s checkout of branch: %s\n" %
1204
repo_branch.bzrdir.root_transport.base))
1307
friendly_location(repo_branch.bzrdir.root_transport.base)))
1206
1309
branch_data = (" checkout of branch: %s\n" %
1207
1310
lco_tree.branch.bzrdir.root_transport.base)
1210
1313
verbose_info = ' 0 committers\n'
1212
1315
verbose_info = ''
1214
1317
self.assertEqualDiff(
1215
1318
"""%s (format: %s)
1253
1358
transport = self.get_transport()
1254
1359
# Create shared repository with a branch
1255
1360
repo = self.make_repository('repo', shared=True,
1256
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1361
format=bzrdir.BzrDirMetaFormat1())
1257
1362
repo.set_make_working_trees(False)
1258
1363
repo.bzrdir.root_transport.mkdir('branch')
1259
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1260
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1364
repo_branch = controldir.ControlDir.create_branch_convenience(
1365
'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1261
1366
# Do a heavy checkout
1262
1367
transport.mkdir('tree')
1263
1368
transport.mkdir('tree/checkout')
1264
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1265
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1369
co_branch = controldir.ControlDir.create_branch_convenience(
1370
'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1266
1371
co_branch.bind(repo_branch)
1267
1372
# Do a light checkout of the heavy one
1268
1373
transport.mkdir('tree/lightcheckout')
1269
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1270
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1374
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1375
lco_dir.set_branch_reference(co_branch)
1271
1376
lco_dir.create_workingtree()
1272
1377
lco_tree = lco_dir.open_workingtree()
1361
1466
self.knownFailure('Win32 cannot run "bzr info"'
1362
1467
' when the tree is locked.')
1364
def test_info_locking_oslocks(self):
1365
if sys.platform == "win32":
1366
raise TestSkipped("don't use oslocks on win32 in unix manner")
1368
tree = self.make_branch_and_tree('branch',
1369
format=bzrlib.bzrdir.BzrDirFormat6())
1371
# Test all permutations of locking the working tree, branch and repository
1372
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1373
# implemented by raising NotImplementedError and get_physical_lock_status()
1374
# always returns false. This makes bzr info hide the lock status. (Olaf)
1378
out, err = self.run_bzr('info -v branch')
1379
self.assertEqualDiff(
1380
"""Standalone tree (format: weave)
1385
control: All-in-one format 6
1386
working tree: Working tree format 2
1387
branch: Branch format 4
1390
In the working tree:
1398
0 versioned subdirectories
1407
""" % (tree.bzrdir.root_transport.base,
1408
tree.branch.repository._format.get_format_description(),
1410
self.assertEqual('', err)
1413
out, err = self.run_bzr('info -v branch')
1414
self.assertEqualDiff(
1415
"""Standalone tree (format: weave)
1420
control: All-in-one format 6
1421
working tree: Working tree format 2
1422
branch: Branch format 4
1425
In the working tree:
1433
0 versioned subdirectories
1442
""" % (tree.bzrdir.root_transport.base,
1443
tree.branch.repository._format.get_format_description(),
1445
self.assertEqual('', err)
1469
def test_info_stacked(self):
1470
# We have a mainline
1471
trunk_tree = self.make_branch_and_tree('mainline',
1473
trunk_tree.commit('mainline')
1474
# and a branch from it which is stacked
1475
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1476
out, err = self.run_bzr('info newbranch')
1478
"""Standalone tree (format: 1.6)
1480
branch root: newbranch
1483
parent branch: mainline
1484
stacked on: mainline
1486
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)