1
# Copyright (C) 2006-2012, 2016 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
"""Tests for the info command of bzr."""
33
from breezy.bzr import (
36
from breezy.tests.matchers import ContainsNoVfsCalls
37
from breezy.transport import memory
40
class TestInfo(tests.TestCaseWithTransport):
43
super(TestInfo, self).setUp()
44
self._repo_strings = "2a"
46
def test_info_non_existing(self):
47
self.vfs_transport_factory = memory.MemoryServer
48
location = self.get_url()
49
out, err = self.run_bzr('info '+location, retcode=3)
50
self.assertEqual(out, '')
51
self.assertEqual(err, 'brz: ERROR: Not a branch: "%s".\n' % location)
53
def test_info_empty_controldir(self):
54
self.make_controldir('ctrl')
55
out, err = self.run_bzr('info ctrl')
57
'Empty control directory (format: 2a or pack-0.92)\n'
59
' control directory: ctrl\n')
60
self.assertEqual(err, '')
62
def test_info_empty_controldir_verbose(self):
63
self.make_controldir('ctrl')
64
out, err = self.run_bzr('info -v ctrl')
65
self.assertEqualDiff(out,
66
'Empty control directory (format: 2a or pack-0.92)\n'
68
' control directory: ctrl\n\n'
70
' control: Meta directory format 1\n\n'
71
'Control directory:\n'
73
self.assertEqual(err, '')
75
def test_info_dangling_branch_reference(self):
76
br = self.make_branch('target')
77
br.create_checkout('from', lightweight=True)
78
shutil.rmtree('target')
79
out, err = self.run_bzr('info from')
81
'Dangling branch reference (format: 2a or pack-0.92)\n'
83
' control directory: from\n'
84
' checkout of branch: target\n')
85
self.assertEqual(err, '')
87
def test_info_standalone(self):
88
transport = self.get_transport()
90
# Create initial standalone branch
91
tree1 = self.make_branch_and_tree('standalone', 'knit')
92
self.build_tree(['standalone/a'])
94
branch1 = tree1.branch
96
out, err = self.run_bzr('info standalone')
98
"""Standalone tree (format: knit)
100
branch root: standalone
102
self.assertEqual('', err)
104
# Standalone branch - verbose mode
105
out, err = self.run_bzr('info standalone -v')
106
self.assertEqualDiff(
107
"""Standalone tree (format: knit)
109
branch root: standalone
112
control: Meta directory format 1
113
working tree: Working tree format 3
114
branch: Branch format 5
115
repository: Knit repository format 1
128
0 versioned subdirectories
136
self.assertEqual('', err)
138
# Standalone branch - really verbose mode
139
out, err = self.run_bzr('info standalone -vv')
140
self.assertEqualDiff(
141
"""Standalone tree (format: knit)
143
branch root: standalone
146
control: Meta directory format 1
147
working tree: Working tree format 3
148
branch: Branch format 5
149
repository: Knit repository format 1
162
0 versioned subdirectories
171
self.assertEqual('', err)
172
tree1.commit('commit one')
173
rev = branch1.repository.get_revision(branch1.last_revision())
174
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
176
# Branch standalone with push location
177
branch2 = branch1.controldir.sprout('branch').open_branch()
178
branch2.set_push_location(branch1.controldir.root_transport.base)
180
out, err = self.run_bzr('info branch')
181
self.assertEqualDiff(
182
"""Standalone tree (format: knit)
187
push branch: standalone
188
parent branch: standalone
190
self.assertEqual('', err)
192
out, err = self.run_bzr('info branch --verbose')
193
self.assertEqualDiff(
194
"""Standalone tree (format: knit)
199
push branch: standalone
200
parent branch: standalone
203
control: Meta directory format 1
204
working tree: Working tree format 3
205
branch: Branch format 5
206
repository: Knit repository format 1
219
0 versioned subdirectories
229
""" % (datestring_first, datestring_first,
231
self.assertEqual('', err)
233
# Branch and bind to standalone, needs upgrade to metadir
234
# (creates backup as unknown)
235
branch1.controldir.sprout('bound')
236
knit1_format = controldir.format_registry.make_controldir('knit')
237
upgrade.upgrade('bound', knit1_format)
238
branch3 = controldir.ControlDir.open('bound').open_branch()
239
branch3.bind(branch1)
240
bound_tree = branch3.controldir.open_workingtree()
241
out, err = self.run_bzr('info -v bound')
242
self.assertEqualDiff(
243
"""Checkout (format: knit)
246
checkout of branch: standalone
249
parent branch: standalone
252
control: Meta directory format 1
268
0 versioned subdirectories
278
""" % (bound_tree._format.get_format_description(),
279
branch3._format.get_format_description(),
280
branch3.repository._format.get_format_description(),
281
datestring_first, datestring_first,
283
self.assertEqual('', err)
285
# Checkout standalone (same as above, but does not have parent set)
286
branch4 = controldir.ControlDir.create_branch_convenience('checkout',
288
branch4.bind(branch1)
289
branch4.controldir.open_workingtree().update()
290
out, err = self.run_bzr('info checkout --verbose')
291
self.assertEqualDiff(
292
"""Checkout (format: knit)
294
checkout root: checkout
295
checkout of branch: standalone
298
control: Meta directory format 1
299
working tree: Working tree format 3
300
branch: Branch format 5
314
0 versioned subdirectories
324
""" % (branch4.repository._format.get_format_description(),
325
datestring_first, datestring_first,
327
self.assertEqual('', err)
329
# Lightweight checkout (same as above, different branch and repository)
330
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
331
branch5 = tree5.branch
332
out, err = self.run_bzr('info -v lightcheckout')
333
if "metaweave" in controldir.format_registry:
334
format_description = "knit or metaweave"
336
format_description = "knit"
337
self.assertEqualDiff(
338
"""Lightweight checkout (format: %s)
340
light checkout root: lightcheckout
341
checkout of branch: standalone
344
control: Meta directory format 1
345
working tree: Working tree format 3
346
branch: Branch format 5
347
repository: Knit repository format 1
360
0 versioned subdirectories
370
""" % (format_description, datestring_first, datestring_first,), out)
371
self.assertEqual('', err)
373
# Update initial standalone branch
374
self.build_tree(['standalone/b'])
376
tree1.commit('commit two')
377
rev = branch1.repository.get_revision(branch1.last_revision())
378
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
380
# Out of date branched standalone branch will not be detected
381
out, err = self.run_bzr('info -v branch')
382
self.assertEqualDiff(
383
"""Standalone tree (format: knit)
388
push branch: standalone
389
parent branch: standalone
392
control: Meta directory format 1
393
working tree: Working tree format 3
394
branch: Branch format 5
395
repository: Knit repository format 1
408
0 versioned subdirectories
418
""" % (datestring_first, datestring_first,
420
self.assertEqual('', err)
422
# Out of date bound branch
423
out, err = self.run_bzr('info -v bound')
424
self.assertEqualDiff(
425
"""Checkout (format: knit)
428
checkout of branch: standalone
431
parent branch: standalone
434
control: Meta directory format 1
435
working tree: Working tree format 3
436
branch: Branch format 5
442
Branch is out of date: missing 1 revision.
452
0 versioned subdirectories
462
""" % (branch3.repository._format.get_format_description(),
463
datestring_first, datestring_first,
465
self.assertEqual('', err)
467
# Out of date checkout
468
out, err = self.run_bzr('info -v checkout')
469
self.assertEqualDiff(
470
"""Checkout (format: knit)
472
checkout root: checkout
473
checkout of branch: standalone
476
control: Meta directory format 1
477
working tree: Working tree format 3
478
branch: Branch format 5
484
Branch is out of date: missing 1 revision.
494
0 versioned subdirectories
504
""" % (branch4.repository._format.get_format_description(),
505
datestring_first, datestring_first,
507
self.assertEqual('', err)
509
# Out of date lightweight checkout
510
out, err = self.run_bzr('info lightcheckout --verbose')
511
self.assertEqualDiff(
512
"""Lightweight checkout (format: %s)
514
light checkout root: lightcheckout
515
checkout of branch: standalone
518
control: Meta directory format 1
519
working tree: Working tree format 3
520
branch: Branch format 5
521
repository: Knit repository format 1
526
Working tree is out of date: missing 1 revision.
536
0 versioned subdirectories
546
""" % (format_description, datestring_first, datestring_last,), out)
547
self.assertEqual('', err)
549
def test_info_standalone_no_tree(self):
550
# create standalone branch without a working tree
551
format = controldir.format_registry.make_controldir('default')
552
branch = self.make_branch('branch')
553
repo = branch.repository
554
out, err = self.run_bzr('info branch -v')
555
self.assertEqualDiff(
556
"""Standalone branch (format: %s)
561
control: Meta directory format 1
573
""" % (info.describe_format(repo.controldir, repo, branch, None),
574
format.get_branch_format().get_format_description(),
575
format.repository_format.get_format_description(),
577
self.assertEqual('', err)
579
def test_info_shared_repository(self):
580
format = controldir.format_registry.make_controldir('knit')
581
transport = self.get_transport()
583
# Create shared repository
584
repo = self.make_repository('repo', shared=True, format=format)
585
repo.set_make_working_trees(False)
586
out, err = self.run_bzr('info -v repo')
587
self.assertEqualDiff(
588
"""Shared repository (format: dirstate or dirstate-tags or knit)
590
shared repository: %s
593
control: Meta directory format 1
601
""" % ('repo', format.repository_format.get_format_description(),
603
self.assertEqual('', err)
605
# Create branch inside shared repository
606
repo.controldir.root_transport.mkdir('branch')
607
branch1 = controldir.ControlDir.create_branch_convenience(
608
'repo/branch', format=format)
609
out, err = self.run_bzr('info -v repo/branch')
610
self.assertEqualDiff(
611
"""Repository branch (format: dirstate or knit)
613
shared repository: repo
614
repository branch: repo/branch
617
control: Meta directory format 1
629
""" % (format.get_branch_format().get_format_description(),
630
format.repository_format.get_format_description(),
632
self.assertEqual('', err)
634
# Create lightweight checkout
635
transport.mkdir('tree')
636
transport.mkdir('tree/lightcheckout')
637
tree2 = branch1.create_checkout('tree/lightcheckout',
639
branch2 = tree2.branch
640
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
641
shared_repo=repo, repo_branch=branch1, verbose=True)
643
# Create normal checkout
644
tree3 = branch1.create_checkout('tree/checkout')
645
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
647
light_checkout=False, repo_branch=branch1)
648
# Update lightweight checkout
649
self.build_tree(['tree/lightcheckout/a'])
651
tree2.commit('commit one')
652
rev = repo.get_revision(branch2.last_revision())
653
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
654
out, err = self.run_bzr('info tree/lightcheckout --verbose')
655
self.assertEqualDiff(
656
"""Lightweight checkout (format: %s)
658
light checkout root: tree/lightcheckout
659
checkout of branch: repo/branch
660
shared repository: repo
663
control: Meta directory format 1
664
working tree: Working tree format 6
679
0 versioned subdirectories
689
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
690
format.repository_format.get_format_description(),
691
datestring_first, datestring_first,
693
self.assertEqual('', err)
695
# Out of date checkout
696
out, err = self.run_bzr('info -v tree/checkout')
697
self.assertEqualDiff(
698
"""Checkout (format: unnamed)
700
checkout root: tree/checkout
701
checkout of branch: repo/branch
704
control: Meta directory format 1
705
working tree: Working tree format 6
712
Branch is out of date: missing 1 revision.
722
0 versioned subdirectories
729
""" % (format.get_branch_format().get_format_description(),
730
format.repository_format.get_format_description(),
732
self.assertEqual('', err)
736
self.build_tree(['tree/checkout/b'])
738
out, err = self.run_bzr('info tree/checkout --verbose')
739
self.assertEqualDiff(
740
"""Checkout (format: unnamed)
742
checkout root: tree/checkout
743
checkout of branch: repo/branch
746
control: Meta directory format 1
747
working tree: Working tree format 6
762
0 versioned subdirectories
772
""" % (format.get_branch_format().get_format_description(),
773
format.repository_format.get_format_description(),
774
datestring_first, datestring_first,
776
self.assertEqual('', err)
777
tree3.commit('commit two')
779
# Out of date lightweight checkout
780
rev = repo.get_revision(branch1.last_revision())
781
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
782
out, err = self.run_bzr('info tree/lightcheckout --verbose')
783
self.assertEqualDiff(
784
"""Lightweight checkout (format: %s)
786
light checkout root: tree/lightcheckout
787
checkout of branch: repo/branch
788
shared repository: repo
791
control: Meta directory format 1
792
working tree: Working tree format 6
799
Working tree is out of date: missing 1 revision.
809
0 versioned subdirectories
819
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
820
format.repository_format.get_format_description(),
821
datestring_first, datestring_last,
823
self.assertEqual('', err)
825
# Show info about shared branch
826
out, err = self.run_bzr('info repo/branch --verbose')
827
self.assertEqualDiff(
828
"""Repository branch (format: dirstate or knit)
830
shared repository: repo
831
repository branch: repo/branch
834
control: Meta directory format 1
849
""" % (format.get_branch_format().get_format_description(),
850
format.repository_format.get_format_description(),
851
datestring_first, datestring_last,
853
self.assertEqual('', err)
855
# Show info about repository with revisions
856
out, err = self.run_bzr('info -v repo')
857
self.assertEqualDiff(
858
"""Shared repository (format: dirstate or dirstate-tags or knit)
860
shared repository: repo
863
control: Meta directory format 1
871
""" % (format.repository_format.get_format_description(),
873
self.assertEqual('', err)
875
def test_info_shared_repository_with_trees(self):
876
format = controldir.format_registry.make_controldir('knit')
877
transport = self.get_transport()
879
# Create shared repository with working trees
880
repo = self.make_repository('repo', shared=True, format=format)
881
repo.set_make_working_trees(True)
882
out, err = self.run_bzr('info -v repo')
883
self.assertEqualDiff(
884
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
886
shared repository: repo
889
control: Meta directory format 1
895
Create working tree for new branches inside the repository.
899
""" % (format.repository_format.get_format_description(),
901
self.assertEqual('', err)
903
# Create two branches
904
repo.controldir.root_transport.mkdir('branch1')
905
branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
907
branch2 = branch1.controldir.sprout('repo/branch2').open_branch()
910
out, err = self.run_bzr('info repo/branch1 --verbose')
911
self.assertEqualDiff(
912
"""Repository tree (format: knit)
914
shared repository: repo
915
repository branch: repo/branch1
918
control: Meta directory format 1
919
working tree: Working tree format 3
934
0 versioned subdirectories
941
""" % (format.get_branch_format().get_format_description(),
942
format.repository_format.get_format_description(),
944
self.assertEqual('', err)
946
# Update first branch
947
self.build_tree(['repo/branch1/a'])
948
tree1 = branch1.controldir.open_workingtree()
950
tree1.commit('commit one')
951
rev = repo.get_revision(branch1.last_revision())
952
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
953
out, err = self.run_bzr('info -v repo/branch1')
954
self.assertEqualDiff(
955
"""Repository tree (format: knit)
957
shared repository: repo
958
repository branch: repo/branch1
961
control: Meta directory format 1
962
working tree: Working tree format 3
977
0 versioned subdirectories
987
""" % (format.get_branch_format().get_format_description(),
988
format.repository_format.get_format_description(),
989
datestring_first, datestring_first,
991
self.assertEqual('', err)
993
# Out of date second branch
994
out, err = self.run_bzr('info repo/branch2 --verbose')
995
self.assertEqualDiff(
996
"""Repository tree (format: knit)
998
shared repository: repo
999
repository branch: repo/branch2
1002
parent branch: repo/branch1
1005
control: Meta directory format 1
1006
working tree: Working tree format 3
1013
In the working tree:
1021
0 versioned subdirectories
1028
""" % (format.get_branch_format().get_format_description(),
1029
format.repository_format.get_format_description(),
1031
self.assertEqual('', err)
1033
# Update second branch
1034
tree2 = branch2.controldir.open_workingtree()
1036
out, err = self.run_bzr('info -v repo/branch2')
1037
self.assertEqualDiff(
1038
"""Repository tree (format: knit)
1040
shared repository: repo
1041
repository branch: repo/branch2
1044
parent branch: repo/branch1
1047
control: Meta directory format 1
1048
working tree: Working tree format 3
1055
In the working tree:
1063
0 versioned subdirectories
1073
""" % (format.get_branch_format().get_format_description(),
1074
format.repository_format.get_format_description(),
1075
datestring_first, datestring_first,
1077
self.assertEqual('', err)
1079
# Show info about repository with revisions
1080
out, err = self.run_bzr('info -v repo')
1081
self.assertEqualDiff(
1082
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1084
shared repository: repo
1087
control: Meta directory format 1
1093
Create working tree for new branches inside the repository.
1097
""" % (format.repository_format.get_format_description(),
1100
self.assertEqual('', err)
1102
def test_info_shared_repository_with_tree_in_root(self):
1103
format = controldir.format_registry.make_controldir('knit')
1104
transport = self.get_transport()
1106
# Create shared repository with working trees
1107
repo = self.make_repository('repo', shared=True, format=format)
1108
repo.set_make_working_trees(True)
1109
out, err = self.run_bzr('info -v repo')
1110
self.assertEqualDiff(
1111
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1113
shared repository: repo
1116
control: Meta directory format 1
1122
Create working tree for new branches inside the repository.
1126
""" % (format.repository_format.get_format_description(),
1128
self.assertEqual('', err)
1130
# Create branch in root of repository
1131
control = repo.controldir
1132
branch = control.create_branch()
1133
control.create_workingtree()
1134
out, err = self.run_bzr('info -v repo')
1135
self.assertEqualDiff(
1136
"""Repository tree (format: knit)
1138
shared repository: repo
1139
repository branch: repo
1142
control: Meta directory format 1
1143
working tree: Working tree format 3
1150
In the working tree:
1158
0 versioned subdirectories
1165
""" % (format.get_branch_format().get_format_description(),
1166
format.repository_format.get_format_description(),
1168
self.assertEqual('', err)
1170
def test_info_repository_hook(self):
1171
format = controldir.format_registry.make_controldir('knit')
1172
def repo_info(repo, stats, outf):
1173
outf.write("more info\n")
1174
info.hooks.install_named_hook('repository', repo_info, None)
1175
# Create shared repository with working trees
1176
repo = self.make_repository('repo', shared=True, format=format)
1177
out, err = self.run_bzr('info -v repo')
1178
self.assertEqualDiff(
1179
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1181
shared repository: repo
1184
control: Meta directory format 1
1190
Create working tree for new branches inside the repository.
1195
""" % (format.repository_format.get_format_description(),
1197
self.assertEqual('', err)
1199
def test_info_unshared_repository_with_colocated_branches(self):
1200
format = controldir.format_registry.make_controldir('development-colo')
1201
transport = self.get_transport()
1203
# Create unshared repository
1204
repo = self.make_repository('repo', shared=False, format=format)
1205
repo.set_make_working_trees(True)
1206
repo.controldir.create_branch(name='foo')
1207
out, err = self.run_bzr('info repo')
1208
self.assertEqualDiff(
1209
"""Unshared repository with trees and colocated branches (format: development-colo)
1213
self.assertEqual('', err)
1215
def assertCheckoutStatusOutput(self,
1216
command_string, lco_tree, shared_repo=None,
1219
branch_locked=False, repo_locked=False,
1221
light_checkout=True,
1222
checkout_root=None):
1223
"""Check the output of info in a checkout.
1225
This is not quite a mirror of the info code: rather than using the
1226
tree being examined to predict output, it uses a bunch of flags which
1227
allow us, the test writers, to document what *should* be present in
1228
the output. Removing this separation would remove the value of the
1231
:param path: the path to the light checkout.
1232
:param lco_tree: the tree object for the light checkout.
1233
:param shared_repo: A shared repository is in use, expect that in
1235
:param repo_branch: A branch in a shared repository for non light
1237
:param tree_locked: If true, expect the tree to be locked.
1238
:param branch_locked: If true, expect the branch to be locked.
1239
:param repo_locked: If true, expect the repository to be locked.
1240
Note that the lco_tree.branch.repository is inspected, and if is not
1241
actually locked then this parameter is overridden. This is because
1242
pack repositories do not have any public API for obtaining an
1243
exclusive repository wide lock.
1244
:param verbose: verbosity level: 2 or higher to show committers
1246
def friendly_location(url):
1247
path = urlutils.unescape_for_display(url, 'ascii')
1249
return osutils.relpath(osutils.getcwd(), path)
1250
except errors.PathNotChild:
1254
# We expect this to fail because of locking errors.
1255
# (A write-locked file cannot be read-locked
1256
# in the different process -- either on win32 or on linux).
1257
# This should be removed when the locking errors are fixed.
1258
self.expectFailure('OS locks are exclusive '
1259
'for different processes (Bug #174055)',
1260
self.run_bzr_subprocess,
1261
'info ' + command_string)
1262
out, err = self.run_bzr('info %s' % command_string)
1264
(True, True): 'Lightweight checkout',
1265
(True, False): 'Repository checkout',
1266
(False, True): 'Lightweight checkout',
1267
(False, False): 'Checkout',
1268
}[(shared_repo is not None, light_checkout)]
1269
format = {True: self._repo_strings,
1270
False: 'unnamed'}[light_checkout]
1272
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1273
if repo_locked or branch_locked or tree_locked:
1274
def locked_message(a_bool):
1279
expected_lock_output = (
1282
" working tree: %s\n"
1284
" repository: %s\n" % (
1285
locked_message(tree_locked),
1286
locked_message(branch_locked),
1287
locked_message(repo_locked)))
1289
expected_lock_output = ''
1293
tree_data = (" light checkout root: %s\n" %
1294
friendly_location(lco_tree.controldir.root_transport.base))
1296
if lco_tree.branch.get_bound_location() is not None:
1297
tree_data += ("%s checkout root: %s\n" % (extra_space,
1298
friendly_location(lco_tree.branch.controldir.root_transport.base)))
1299
if shared_repo is not None:
1301
" checkout of branch: %s\n"
1302
" shared repository: %s\n" %
1303
(friendly_location(repo_branch.controldir.root_transport.base),
1304
friendly_location(shared_repo.controldir.root_transport.base)))
1305
elif repo_branch is not None:
1307
"%s checkout of branch: %s\n" %
1309
friendly_location(repo_branch.controldir.root_transport.base)))
1311
branch_data = (" checkout of branch: %s\n" %
1312
lco_tree.branch.controldir.root_transport.base)
1315
verbose_info = ' 0 committers\n'
1319
self.assertEqualDiff(
1324
control: Meta directory format 1
1332
In the working tree:
1340
0 versioned subdirectories
1351
lco_tree._format.get_format_description(),
1352
lco_tree.branch._format.get_format_description(),
1353
lco_tree.branch.repository._format.get_format_description(),
1354
expected_lock_output,
1357
self.assertEqual('', err)
1359
def test_info_locking(self):
1360
transport = self.get_transport()
1361
# Create shared repository with a branch
1362
repo = self.make_repository('repo', shared=True,
1363
format=bzrdir.BzrDirMetaFormat1())
1364
repo.set_make_working_trees(False)
1365
repo.controldir.root_transport.mkdir('branch')
1366
repo_branch = controldir.ControlDir.create_branch_convenience(
1367
'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1368
# Do a heavy checkout
1369
transport.mkdir('tree')
1370
transport.mkdir('tree/checkout')
1371
co_branch = controldir.ControlDir.create_branch_convenience(
1372
'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1373
co_branch.bind(repo_branch)
1374
# Do a light checkout of the heavy one
1375
transport.mkdir('tree/lightcheckout')
1376
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1377
lco_dir.set_branch_reference(co_branch)
1378
lco_dir.create_workingtree()
1379
lco_tree = lco_dir.open_workingtree()
1381
# Test all permutations of locking the working tree, branch and repository
1385
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1386
repo_branch=repo_branch,
1387
verbose=True, light_checkout=True)
1389
lco_tree.branch.repository.lock_write()
1391
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1392
lco_tree, repo_branch=repo_branch,
1393
repo_locked=True, verbose=True, light_checkout=True)
1395
lco_tree.branch.repository.unlock()
1397
lco_tree.branch.lock_write()
1399
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1403
repo_branch=repo_branch,
1406
lco_tree.branch.unlock()
1408
lco_tree.lock_write()
1410
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1411
lco_tree, repo_branch=repo_branch,
1419
lco_tree.lock_write()
1420
lco_tree.branch.repository.unlock()
1422
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1423
lco_tree, repo_branch=repo_branch,
1428
lco_tree.branch.repository.lock_write()
1431
lco_tree.lock_write()
1432
lco_tree.branch.unlock()
1434
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1435
lco_tree, repo_branch=repo_branch,
1439
lco_tree.branch.lock_write()
1442
lco_tree.lock_write()
1443
lco_tree.branch.unlock()
1444
lco_tree.branch.repository.lock_write()
1446
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1447
lco_tree, repo_branch=repo_branch,
1452
lco_tree.branch.repository.unlock()
1453
lco_tree.branch.lock_write()
1456
lco_tree.branch.lock_write()
1457
lco_tree.branch.repository.unlock()
1459
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1460
lco_tree, repo_branch=repo_branch,
1464
lco_tree.branch.repository.lock_write()
1465
lco_tree.branch.unlock()
1467
if sys.platform == 'win32':
1468
self.knownFailure('Win32 cannot run "brz info"'
1469
' when the tree is locked.')
1471
def test_info_stacked(self):
1472
# We have a mainline
1473
trunk_tree = self.make_branch_and_tree('mainline',
1475
trunk_tree.commit('mainline')
1476
# and a branch from it which is stacked
1477
new_dir = trunk_tree.controldir.sprout('newbranch', stacked=True)
1478
out, err = self.run_bzr('info newbranch')
1480
"""Standalone tree (format: 1.6)
1482
branch root: newbranch
1485
parent branch: mainline
1486
stacked on: mainline
1488
self.assertEqual("", err)
1490
def test_info_revinfo_optional(self):
1491
tree = self.make_branch_and_tree('.')
1492
def last_revision_info(self):
1493
raise errors.UnsupportedOperation(last_revision_info, self)
1495
branch.Branch, "last_revision_info", last_revision_info)
1496
out, err = self.run_bzr('info -v .')
1498
"""Standalone tree (format: 2a)
1503
control: Meta directory format 1
1504
working tree: Working tree format 6
1505
branch: Branch format 7
1506
repository: Repository format 2a - rich roots, group compression and chk inventories
1511
In the working tree:
1519
0 versioned subdirectories
1521
self.assertEqual("", err)
1523
def test_info_shows_colocated_branches(self):
1524
bzrdir = self.make_branch('.', format='development-colo').controldir
1525
bzrdir.create_branch(name="colo1")
1526
bzrdir.create_branch(name="colo2")
1527
bzrdir.create_branch(name="colo3")
1528
out, err = self.run_bzr('info -v .')
1529
self.assertEqualDiff(
1530
"""Standalone branch (format: development-colo)
1535
control: Meta directory format 1 with support for colocated branches
1536
branch: Branch format 7
1537
repository: Repository format 2a - rich roots, group compression and chk inventories
1548
self.assertEqual("", err)
1551
class TestSmartServerInfo(tests.TestCaseWithTransport):
1553
def test_simple_branch_info(self):
1554
self.setup_smart_server_with_call_log()
1555
t = self.make_branch_and_tree('branch')
1556
self.build_tree_contents([('branch/foo', 'thecontents')])
1559
self.reset_smart_call_log()
1560
out, err = self.run_bzr(['info', self.get_url('branch')])
1561
# This figure represent the amount of work to perform this use case. It
1562
# is entirely ok to reduce this number if a test fails due to rpc_count
1563
# being too low. If rpc_count increases, more network roundtrips have
1564
# become necessary for this use case. Please do not adjust this number
1565
# upwards without agreement from bzr's network support maintainers.
1566
self.assertLength(10, self.hpss_calls)
1567
self.assertLength(1, self.hpss_connections)
1568
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
1570
def test_verbose_branch_info(self):
1571
self.setup_smart_server_with_call_log()
1572
t = self.make_branch_and_tree('branch')
1573
self.build_tree_contents([('branch/foo', 'thecontents')])
1576
self.reset_smart_call_log()
1577
out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
1578
# This figure represent the amount of work to perform this use case. It
1579
# is entirely ok to reduce this number if a test fails due to rpc_count
1580
# being too low. If rpc_count increases, more network roundtrips have
1581
# become necessary for this use case. Please do not adjust this number
1582
# upwards without agreement from bzr's network support maintainers.
1583
self.assertLength(14, self.hpss_calls)
1584
self.assertLength(1, self.hpss_connections)
1585
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)