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)\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)\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)\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')
1173
def repo_info(repo, stats, outf):
1174
outf.write(u"more info\n")
1175
info.hooks.install_named_hook('repository', repo_info, None)
1176
# Create shared repository with working trees
1177
repo = self.make_repository('repo', shared=True, format=format)
1178
out, err = self.run_bzr('info -v repo')
1179
self.assertEqualDiff(
1180
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1182
shared repository: repo
1185
control: Meta directory format 1
1191
Create working tree for new branches inside the repository.
1196
""" % (format.repository_format.get_format_description(),
1198
self.assertEqual('', err)
1200
def test_info_unshared_repository_with_colocated_branches(self):
1201
format = controldir.format_registry.make_controldir('development-colo')
1202
transport = self.get_transport()
1204
# Create unshared repository
1205
repo = self.make_repository('repo', shared=False, format=format)
1206
repo.set_make_working_trees(True)
1207
repo.controldir.create_branch(name='foo')
1208
out, err = self.run_bzr('info repo')
1209
self.assertEqualDiff(
1210
"""Unshared repository with trees and colocated branches (format: development-colo)
1214
self.assertEqual('', err)
1216
def assertCheckoutStatusOutput(self,
1217
command_string, lco_tree, shared_repo=None,
1220
branch_locked=False, repo_locked=False,
1222
light_checkout=True,
1223
checkout_root=None):
1224
"""Check the output of info in a checkout.
1226
This is not quite a mirror of the info code: rather than using the
1227
tree being examined to predict output, it uses a bunch of flags which
1228
allow us, the test writers, to document what *should* be present in
1229
the output. Removing this separation would remove the value of the
1232
:param path: the path to the light checkout.
1233
:param lco_tree: the tree object for the light checkout.
1234
:param shared_repo: A shared repository is in use, expect that in
1236
:param repo_branch: A branch in a shared repository for non light
1238
:param tree_locked: If true, expect the tree to be locked.
1239
:param branch_locked: If true, expect the branch to be locked.
1240
:param repo_locked: If true, expect the repository to be locked.
1241
Note that the lco_tree.branch.repository is inspected, and if is not
1242
actually locked then this parameter is overridden. This is because
1243
pack repositories do not have any public API for obtaining an
1244
exclusive repository wide lock.
1245
:param verbose: verbosity level: 2 or higher to show committers
1247
def friendly_location(url):
1248
path = urlutils.unescape_for_display(url, 'ascii')
1250
return osutils.relpath(osutils.getcwd(), path)
1251
except errors.PathNotChild:
1255
# We expect this to fail because of locking errors.
1256
# (A write-locked file cannot be read-locked
1257
# in the different process -- either on win32 or on linux).
1258
# This should be removed when the locking errors are fixed.
1259
self.expectFailure('OS locks are exclusive '
1260
'for different processes (Bug #174055)',
1261
self.run_bzr_subprocess,
1262
'info ' + command_string)
1263
out, err = self.run_bzr('info %s' % command_string)
1265
(True, True): 'Lightweight checkout',
1266
(True, False): 'Repository checkout',
1267
(False, True): 'Lightweight checkout',
1268
(False, False): 'Checkout',
1269
}[(shared_repo is not None, light_checkout)]
1270
format = {True: self._repo_strings,
1271
False: 'unnamed'}[light_checkout]
1273
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1274
if repo_locked or branch_locked or tree_locked:
1275
def locked_message(a_bool):
1280
expected_lock_output = (
1283
" working tree: %s\n"
1285
" repository: %s\n" % (
1286
locked_message(tree_locked),
1287
locked_message(branch_locked),
1288
locked_message(repo_locked)))
1290
expected_lock_output = ''
1294
tree_data = (" light checkout root: %s\n" %
1295
friendly_location(lco_tree.controldir.root_transport.base))
1297
if lco_tree.branch.get_bound_location() is not None:
1298
tree_data += ("%s checkout root: %s\n" % (extra_space,
1299
friendly_location(lco_tree.branch.controldir.root_transport.base)))
1300
if shared_repo is not None:
1302
" checkout of branch: %s\n"
1303
" shared repository: %s\n" %
1304
(friendly_location(repo_branch.controldir.root_transport.base),
1305
friendly_location(shared_repo.controldir.root_transport.base)))
1306
elif repo_branch is not None:
1308
"%s checkout of branch: %s\n" %
1310
friendly_location(repo_branch.controldir.root_transport.base)))
1312
branch_data = (" checkout of branch: %s\n" %
1313
lco_tree.branch.controldir.root_transport.base)
1316
verbose_info = ' 0 committers\n'
1320
self.assertEqualDiff(
1325
control: Meta directory format 1
1333
In the working tree:
1341
0 versioned subdirectories
1352
lco_tree._format.get_format_description(),
1353
lco_tree.branch._format.get_format_description(),
1354
lco_tree.branch.repository._format.get_format_description(),
1355
expected_lock_output,
1358
self.assertEqual('', err)
1360
def test_info_locking(self):
1361
transport = self.get_transport()
1362
# Create shared repository with a branch
1363
repo = self.make_repository('repo', shared=True,
1364
format=bzrdir.BzrDirMetaFormat1())
1365
repo.set_make_working_trees(False)
1366
repo.controldir.root_transport.mkdir('branch')
1367
repo_branch = controldir.ControlDir.create_branch_convenience(
1368
'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1369
# Do a heavy checkout
1370
transport.mkdir('tree')
1371
transport.mkdir('tree/checkout')
1372
co_branch = controldir.ControlDir.create_branch_convenience(
1373
'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1374
co_branch.bind(repo_branch)
1375
# Do a light checkout of the heavy one
1376
transport.mkdir('tree/lightcheckout')
1377
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1378
lco_dir.set_branch_reference(co_branch)
1379
lco_dir.create_workingtree()
1380
lco_tree = lco_dir.open_workingtree()
1382
# Test all permutations of locking the working tree, branch and repository
1386
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1387
repo_branch=repo_branch,
1388
verbose=True, light_checkout=True)
1390
lco_tree.branch.repository.lock_write()
1392
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1393
lco_tree, repo_branch=repo_branch,
1394
repo_locked=True, verbose=True, light_checkout=True)
1396
lco_tree.branch.repository.unlock()
1398
lco_tree.branch.lock_write()
1400
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1404
repo_branch=repo_branch,
1407
lco_tree.branch.unlock()
1409
lco_tree.lock_write()
1411
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1412
lco_tree, repo_branch=repo_branch,
1420
lco_tree.lock_write()
1421
lco_tree.branch.repository.unlock()
1423
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1424
lco_tree, repo_branch=repo_branch,
1429
lco_tree.branch.repository.lock_write()
1432
lco_tree.lock_write()
1433
lco_tree.branch.unlock()
1435
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1436
lco_tree, repo_branch=repo_branch,
1440
lco_tree.branch.lock_write()
1443
lco_tree.lock_write()
1444
lco_tree.branch.unlock()
1445
lco_tree.branch.repository.lock_write()
1447
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1448
lco_tree, repo_branch=repo_branch,
1453
lco_tree.branch.repository.unlock()
1454
lco_tree.branch.lock_write()
1457
lco_tree.branch.lock_write()
1458
lco_tree.branch.repository.unlock()
1460
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1461
lco_tree, repo_branch=repo_branch,
1465
lco_tree.branch.repository.lock_write()
1466
lco_tree.branch.unlock()
1468
if sys.platform == 'win32':
1469
self.knownFailure('Win32 cannot run "brz info"'
1470
' when the tree is locked.')
1472
def test_info_stacked(self):
1473
# We have a mainline
1474
trunk_tree = self.make_branch_and_tree('mainline',
1476
trunk_tree.commit('mainline')
1477
# and a branch from it which is stacked
1478
new_dir = trunk_tree.controldir.sprout('newbranch', stacked=True)
1479
out, err = self.run_bzr('info newbranch')
1481
"""Standalone tree (format: 1.6)
1483
branch root: newbranch
1486
parent branch: mainline
1487
stacked on: mainline
1489
self.assertEqual("", err)
1491
def test_info_revinfo_optional(self):
1492
tree = self.make_branch_and_tree('.')
1494
def last_revision_info(self):
1495
raise errors.UnsupportedOperation(last_revision_info, self)
1497
branch.Branch, "last_revision_info", last_revision_info)
1498
out, err = self.run_bzr('info -v .')
1500
"""Standalone tree (format: 2a)
1505
control: Meta directory format 1
1506
working tree: Working tree format 6
1507
branch: Branch format 7
1508
repository: Repository format 2a - rich roots, group compression and chk inventories
1513
In the working tree:
1521
0 versioned subdirectories
1523
self.assertEqual("", err)
1525
def test_info_shows_colocated_branches(self):
1526
bzrdir = self.make_branch('.', format='development-colo').controldir
1527
bzrdir.create_branch(name="colo1")
1528
bzrdir.create_branch(name="colo2")
1529
bzrdir.create_branch(name="colo3")
1530
out, err = self.run_bzr('info -v .')
1531
self.assertEqualDiff(
1532
"""Standalone branch (format: development-colo)
1537
control: Meta directory format 1 with support for colocated branches
1538
branch: Branch format 7
1539
repository: Repository format 2a - rich roots, group compression and chk inventories
1550
self.assertEqual("", err)
1553
class TestSmartServerInfo(tests.TestCaseWithTransport):
1555
def test_simple_branch_info(self):
1556
self.setup_smart_server_with_call_log()
1557
t = self.make_branch_and_tree('branch')
1558
self.build_tree_contents([('branch/foo', b'thecontents')])
1561
self.reset_smart_call_log()
1562
out, err = self.run_bzr(['info', self.get_url('branch')])
1563
# This figure represent the amount of work to perform this use case. It
1564
# is entirely ok to reduce this number if a test fails due to rpc_count
1565
# being too low. If rpc_count increases, more network roundtrips have
1566
# become necessary for this use case. Please do not adjust this number
1567
# upwards without agreement from bzr's network support maintainers.
1568
self.assertLength(10, self.hpss_calls)
1569
self.assertLength(1, self.hpss_connections)
1570
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
1572
def test_verbose_branch_info(self):
1573
self.setup_smart_server_with_call_log()
1574
t = self.make_branch_and_tree('branch')
1575
self.build_tree_contents([('branch/foo', b'thecontents')])
1578
self.reset_smart_call_log()
1579
out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
1580
# This figure represent the amount of work to perform this use case. It
1581
# is entirely ok to reduce this number if a test fails due to rpc_count
1582
# being too low. If rpc_count increases, more network roundtrips have
1583
# become necessary for this use case. Please do not adjust this number
1584
# upwards without agreement from bzr's network support maintainers.
1585
self.assertLength(14, self.hpss_calls)
1586
self.assertLength(1, self.hpss_connections)
1587
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)