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_colocated(self):
88
br = self.make_branch_and_tree('target', format='development-colo')
89
target = br.controldir.create_branch(name='dichtbij')
90
br.controldir.set_branch_reference(target)
91
out, err = self.run_bzr('info target')
93
'Standalone tree (format: development-colo)\n'
95
' light checkout root: target\n'
96
' checkout of co-located branch: dichtbij\n')
97
self.assertEqual(err, '')
99
def test_info_standalone(self):
100
transport = self.get_transport()
102
# Create initial standalone branch
103
tree1 = self.make_branch_and_tree('standalone', 'knit')
104
self.build_tree(['standalone/a'])
106
branch1 = tree1.branch
108
out, err = self.run_bzr('info standalone')
109
self.assertEqualDiff(
110
"""Standalone tree (format: knit)
112
branch root: standalone
114
self.assertEqual('', err)
116
# Standalone branch - verbose mode
117
out, err = self.run_bzr('info standalone -v')
118
self.assertEqualDiff(
119
"""Standalone tree (format: knit)
121
branch root: standalone
124
control: Meta directory format 1
125
working tree: Working tree format 3
126
branch: Branch format 5
127
repository: Knit repository format 1
141
0 versioned subdirectories
149
self.assertEqual('', err)
151
# Standalone branch - really verbose mode
152
out, err = self.run_bzr('info standalone -vv')
153
self.assertEqualDiff(
154
"""Standalone tree (format: knit)
156
branch root: standalone
159
control: Meta directory format 1
160
working tree: Working tree format 3
161
branch: Branch format 5
162
repository: Knit repository format 1
176
0 versioned subdirectories
185
self.assertEqual('', err)
186
tree1.commit('commit one')
187
rev = branch1.repository.get_revision(branch1.last_revision())
188
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
190
# Branch standalone with push location
191
branch2 = branch1.controldir.sprout('branch').open_branch()
192
branch2.set_push_location(branch1.controldir.root_transport.base)
194
out, err = self.run_bzr('info branch')
195
self.assertEqualDiff(
196
"""Standalone tree (format: knit)
201
push branch: standalone
202
parent branch: standalone
204
self.assertEqual('', err)
206
out, err = self.run_bzr('info branch --verbose')
207
self.assertEqualDiff(
208
"""Standalone tree (format: knit)
213
push branch: standalone
214
parent branch: standalone
217
control: Meta directory format 1
218
working tree: Working tree format 3
219
branch: Branch format 5
220
repository: Knit repository format 1
234
0 versioned subdirectories
244
""" % (datestring_first, datestring_first,
246
self.assertEqual('', err)
248
# Branch and bind to standalone, needs upgrade to metadir
249
# (creates backup as unknown)
250
branch1.controldir.sprout('bound')
251
knit1_format = controldir.format_registry.make_controldir('knit')
252
upgrade.upgrade('bound', knit1_format)
253
branch3 = controldir.ControlDir.open('bound').open_branch()
254
branch3.bind(branch1)
255
bound_tree = branch3.controldir.open_workingtree()
256
out, err = self.run_bzr('info -v bound')
257
self.assertEqualDiff(
258
"""Checkout (format: knit)
261
checkout of branch: standalone
264
parent branch: standalone
267
control: Meta directory format 1
284
0 versioned subdirectories
294
""" % (bound_tree._format.get_format_description(),
295
branch3._format.get_format_description(),
296
branch3.repository._format.get_format_description(),
297
datestring_first, datestring_first,
299
self.assertEqual('', err)
301
# Checkout standalone (same as above, but does not have parent set)
302
branch4 = controldir.ControlDir.create_branch_convenience('checkout',
304
branch4.bind(branch1)
305
branch4.controldir.open_workingtree().update()
306
out, err = self.run_bzr('info checkout --verbose')
307
self.assertEqualDiff(
308
"""Checkout (format: knit)
310
checkout root: checkout
311
checkout of branch: standalone
314
control: Meta directory format 1
315
working tree: Working tree format 3
316
branch: Branch format 5
331
0 versioned subdirectories
341
""" % (branch4.repository._format.get_format_description(),
342
datestring_first, datestring_first,
344
self.assertEqual('', err)
346
# Lightweight checkout (same as above, different branch and repository)
347
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
348
branch5 = tree5.branch
349
out, err = self.run_bzr('info -v lightcheckout')
350
if "metaweave" in controldir.format_registry:
351
format_description = "knit or metaweave"
353
format_description = "knit"
354
self.assertEqualDiff(
355
"""Lightweight checkout (format: %s)
357
light checkout root: lightcheckout
358
checkout of branch: standalone
361
control: Meta directory format 1
362
working tree: Working tree format 3
363
branch: Branch format 5
364
repository: Knit repository format 1
378
0 versioned subdirectories
388
""" % (format_description, datestring_first, datestring_first,), out)
389
self.assertEqual('', err)
391
# Update initial standalone branch
392
self.build_tree(['standalone/b'])
394
tree1.commit('commit two')
395
rev = branch1.repository.get_revision(branch1.last_revision())
396
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
398
# Out of date branched standalone branch will not be detected
399
out, err = self.run_bzr('info -v branch')
400
self.assertEqualDiff(
401
"""Standalone tree (format: knit)
406
push branch: standalone
407
parent branch: standalone
410
control: Meta directory format 1
411
working tree: Working tree format 3
412
branch: Branch format 5
413
repository: Knit repository format 1
427
0 versioned subdirectories
437
""" % (datestring_first, datestring_first,
439
self.assertEqual('', err)
441
# Out of date bound branch
442
out, err = self.run_bzr('info -v bound')
443
self.assertEqualDiff(
444
"""Checkout (format: knit)
447
checkout of branch: standalone
450
parent branch: standalone
453
control: Meta directory format 1
454
working tree: Working tree format 3
455
branch: Branch format 5
461
Branch is out of date: missing 1 revision.
472
0 versioned subdirectories
482
""" % (branch3.repository._format.get_format_description(),
483
datestring_first, datestring_first,
485
self.assertEqual('', err)
487
# Out of date checkout
488
out, err = self.run_bzr('info -v checkout')
489
self.assertEqualDiff(
490
"""Checkout (format: knit)
492
checkout root: checkout
493
checkout of branch: standalone
496
control: Meta directory format 1
497
working tree: Working tree format 3
498
branch: Branch format 5
504
Branch is out of date: missing 1 revision.
515
0 versioned subdirectories
525
""" % (branch4.repository._format.get_format_description(),
526
datestring_first, datestring_first,
528
self.assertEqual('', err)
530
# Out of date lightweight checkout
531
out, err = self.run_bzr('info lightcheckout --verbose')
532
self.assertEqualDiff(
533
"""Lightweight checkout (format: %s)
535
light checkout root: lightcheckout
536
checkout of branch: standalone
539
control: Meta directory format 1
540
working tree: Working tree format 3
541
branch: Branch format 5
542
repository: Knit repository format 1
547
Working tree is out of date: missing 1 revision.
558
0 versioned subdirectories
568
""" % (format_description, datestring_first, datestring_last,), out)
569
self.assertEqual('', err)
571
def test_info_standalone_no_tree(self):
572
# create standalone branch without a working tree
573
format = controldir.format_registry.make_controldir('default')
574
branch = self.make_branch('branch')
575
repo = branch.repository
576
out, err = self.run_bzr('info branch -v')
577
self.assertEqualDiff(
578
"""Standalone branch (format: %s)
583
control: Meta directory format 1
595
""" % (info.describe_format(repo.controldir, repo, branch, None),
596
format.get_branch_format().get_format_description(),
597
format.repository_format.get_format_description(),
599
self.assertEqual('', err)
601
def test_info_shared_repository(self):
602
format = controldir.format_registry.make_controldir('knit')
603
transport = self.get_transport()
605
# Create shared repository
606
repo = self.make_repository('repo', shared=True, format=format)
607
repo.set_make_working_trees(False)
608
out, err = self.run_bzr('info -v repo')
609
self.assertEqualDiff(
610
"""Shared repository (format: dirstate or dirstate-tags or knit)
612
shared repository: %s
615
control: Meta directory format 1
623
""" % ('repo', format.repository_format.get_format_description(),
625
self.assertEqual('', err)
627
# Create branch inside shared repository
628
repo.controldir.root_transport.mkdir('branch')
629
branch1 = controldir.ControlDir.create_branch_convenience(
630
'repo/branch', format=format)
631
out, err = self.run_bzr('info -v repo/branch')
632
self.assertEqualDiff(
633
"""Repository branch (format: dirstate or knit)
635
shared repository: repo
636
repository branch: repo/branch
639
control: Meta directory format 1
651
""" % (format.get_branch_format().get_format_description(),
652
format.repository_format.get_format_description(),
654
self.assertEqual('', err)
656
# Create lightweight checkout
657
transport.mkdir('tree')
658
transport.mkdir('tree/lightcheckout')
659
tree2 = branch1.create_checkout('tree/lightcheckout',
661
branch2 = tree2.branch
662
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
663
shared_repo=repo, repo_branch=branch1, verbose=True)
665
# Create normal checkout
666
tree3 = branch1.create_checkout('tree/checkout')
667
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
669
light_checkout=False, repo_branch=branch1)
670
# Update lightweight checkout
671
self.build_tree(['tree/lightcheckout/a'])
673
tree2.commit('commit one')
674
rev = repo.get_revision(branch2.last_revision())
675
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
676
out, err = self.run_bzr('info tree/lightcheckout --verbose')
677
self.assertEqualDiff(
678
"""Lightweight checkout (format: %s)
680
light checkout root: tree/lightcheckout
681
checkout of branch: repo/branch
682
shared repository: repo
685
control: Meta directory format 1
686
working tree: Working tree format 6
702
0 versioned subdirectories
712
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
713
format.repository_format.get_format_description(),
714
datestring_first, datestring_first,
716
self.assertEqual('', err)
718
# Out of date checkout
719
out, err = self.run_bzr('info -v tree/checkout')
720
self.assertEqualDiff(
721
"""Checkout (format: unnamed)
723
checkout root: tree/checkout
724
checkout of branch: repo/branch
727
control: Meta directory format 1
728
working tree: Working tree format 6
735
Branch is out of date: missing 1 revision.
746
0 versioned subdirectories
753
""" % (format.get_branch_format().get_format_description(),
754
format.repository_format.get_format_description(),
756
self.assertEqual('', err)
760
self.build_tree(['tree/checkout/b'])
762
out, err = self.run_bzr('info tree/checkout --verbose')
763
self.assertEqualDiff(
764
"""Checkout (format: unnamed)
766
checkout root: tree/checkout
767
checkout of branch: repo/branch
770
control: Meta directory format 1
771
working tree: Working tree format 6
787
0 versioned subdirectories
797
""" % (format.get_branch_format().get_format_description(),
798
format.repository_format.get_format_description(),
799
datestring_first, datestring_first,
801
self.assertEqual('', err)
802
tree3.commit('commit two')
804
# Out of date lightweight checkout
805
rev = repo.get_revision(branch1.last_revision())
806
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
807
out, err = self.run_bzr('info tree/lightcheckout --verbose')
808
self.assertEqualDiff(
809
"""Lightweight checkout (format: %s)
811
light checkout root: tree/lightcheckout
812
checkout of branch: repo/branch
813
shared repository: repo
816
control: Meta directory format 1
817
working tree: Working tree format 6
824
Working tree is out of date: missing 1 revision.
835
0 versioned subdirectories
845
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
846
format.repository_format.get_format_description(),
847
datestring_first, datestring_last,
849
self.assertEqual('', err)
851
# Show info about shared branch
852
out, err = self.run_bzr('info repo/branch --verbose')
853
self.assertEqualDiff(
854
"""Repository branch (format: dirstate or knit)
856
shared repository: repo
857
repository branch: repo/branch
860
control: Meta directory format 1
875
""" % (format.get_branch_format().get_format_description(),
876
format.repository_format.get_format_description(),
877
datestring_first, datestring_last,
879
self.assertEqual('', err)
881
# Show info about repository with revisions
882
out, err = self.run_bzr('info -v repo')
883
self.assertEqualDiff(
884
"""Shared repository (format: dirstate or dirstate-tags or knit)
886
shared repository: repo
889
control: Meta directory format 1
897
""" % (format.repository_format.get_format_description(),
899
self.assertEqual('', err)
901
def test_info_shared_repository_with_trees(self):
902
format = controldir.format_registry.make_controldir('knit')
903
transport = self.get_transport()
905
# Create shared repository with working trees
906
repo = self.make_repository('repo', shared=True, format=format)
907
repo.set_make_working_trees(True)
908
out, err = self.run_bzr('info -v repo')
909
self.assertEqualDiff(
910
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
912
shared repository: repo
915
control: Meta directory format 1
921
Create working tree for new branches inside the repository.
925
""" % (format.repository_format.get_format_description(),
927
self.assertEqual('', err)
929
# Create two branches
930
repo.controldir.root_transport.mkdir('branch1')
931
branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
933
branch2 = branch1.controldir.sprout('repo/branch2').open_branch()
936
out, err = self.run_bzr('info repo/branch1 --verbose')
937
self.assertEqualDiff(
938
"""Repository tree (format: knit)
940
shared repository: repo
941
repository branch: repo/branch1
944
control: Meta directory format 1
945
working tree: Working tree format 3
961
0 versioned subdirectories
968
""" % (format.get_branch_format().get_format_description(),
969
format.repository_format.get_format_description(),
971
self.assertEqual('', err)
973
# Update first branch
974
self.build_tree(['repo/branch1/a'])
975
tree1 = branch1.controldir.open_workingtree()
977
tree1.commit('commit one')
978
rev = repo.get_revision(branch1.last_revision())
979
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
980
out, err = self.run_bzr('info -v repo/branch1')
981
self.assertEqualDiff(
982
"""Repository tree (format: knit)
984
shared repository: repo
985
repository branch: repo/branch1
988
control: Meta directory format 1
989
working tree: Working tree format 3
1005
0 versioned subdirectories
1015
""" % (format.get_branch_format().get_format_description(),
1016
format.repository_format.get_format_description(),
1017
datestring_first, datestring_first,
1019
self.assertEqual('', err)
1021
# Out of date second branch
1022
out, err = self.run_bzr('info repo/branch2 --verbose')
1023
self.assertEqualDiff(
1024
"""Repository tree (format: knit)
1026
shared repository: repo
1027
repository branch: repo/branch2
1030
parent branch: repo/branch1
1033
control: Meta directory format 1
1034
working tree: Working tree format 3
1041
In the working tree:
1050
0 versioned subdirectories
1057
""" % (format.get_branch_format().get_format_description(),
1058
format.repository_format.get_format_description(),
1060
self.assertEqual('', err)
1062
# Update second branch
1063
tree2 = branch2.controldir.open_workingtree()
1065
out, err = self.run_bzr('info -v repo/branch2')
1066
self.assertEqualDiff(
1067
"""Repository tree (format: knit)
1069
shared repository: repo
1070
repository branch: repo/branch2
1073
parent branch: repo/branch1
1076
control: Meta directory format 1
1077
working tree: Working tree format 3
1084
In the working tree:
1093
0 versioned subdirectories
1103
""" % (format.get_branch_format().get_format_description(),
1104
format.repository_format.get_format_description(),
1105
datestring_first, datestring_first,
1107
self.assertEqual('', err)
1109
# Show info about repository with revisions
1110
out, err = self.run_bzr('info -v repo')
1111
self.assertEqualDiff(
1112
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1114
shared repository: repo
1117
control: Meta directory format 1
1123
Create working tree for new branches inside the repository.
1127
""" % (format.repository_format.get_format_description(),
1130
self.assertEqual('', err)
1132
def test_info_shared_repository_with_tree_in_root(self):
1133
format = controldir.format_registry.make_controldir('knit')
1134
transport = self.get_transport()
1136
# Create shared repository with working trees
1137
repo = self.make_repository('repo', shared=True, format=format)
1138
repo.set_make_working_trees(True)
1139
out, err = self.run_bzr('info -v repo')
1140
self.assertEqualDiff(
1141
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1143
shared repository: repo
1146
control: Meta directory format 1
1152
Create working tree for new branches inside the repository.
1156
""" % (format.repository_format.get_format_description(),
1158
self.assertEqual('', err)
1160
# Create branch in root of repository
1161
control = repo.controldir
1162
branch = control.create_branch()
1163
control.create_workingtree()
1164
out, err = self.run_bzr('info -v repo')
1165
self.assertEqualDiff(
1166
"""Repository tree (format: knit)
1168
shared repository: repo
1169
repository branch: repo
1172
control: Meta directory format 1
1173
working tree: Working tree format 3
1180
In the working tree:
1189
0 versioned subdirectories
1196
""" % (format.get_branch_format().get_format_description(),
1197
format.repository_format.get_format_description(),
1199
self.assertEqual('', err)
1201
def test_info_repository_hook(self):
1202
format = controldir.format_registry.make_controldir('knit')
1204
def repo_info(repo, stats, outf):
1205
outf.write(u"more info\n")
1206
info.hooks.install_named_hook('repository', repo_info, None)
1207
# Create shared repository with working trees
1208
repo = self.make_repository('repo', shared=True, format=format)
1209
out, err = self.run_bzr('info -v repo')
1210
self.assertEqualDiff(
1211
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1213
shared repository: repo
1216
control: Meta directory format 1
1222
Create working tree for new branches inside the repository.
1227
""" % (format.repository_format.get_format_description(),
1229
self.assertEqual('', err)
1231
def test_info_unshared_repository_with_colocated_branches(self):
1232
format = controldir.format_registry.make_controldir('development-colo')
1233
transport = self.get_transport()
1235
# Create unshared repository
1236
repo = self.make_repository('repo', shared=False, format=format)
1237
repo.set_make_working_trees(True)
1238
repo.controldir.create_branch(name='foo')
1239
out, err = self.run_bzr('info repo')
1240
self.assertEqualDiff(
1241
"""Unshared repository with trees and colocated branches (format: development-colo)
1245
self.assertEqual('', err)
1247
def assertCheckoutStatusOutput(self,
1248
command_string, lco_tree, shared_repo=None,
1251
branch_locked=False, repo_locked=False,
1253
light_checkout=True,
1254
checkout_root=None):
1255
"""Check the output of info in a checkout.
1257
This is not quite a mirror of the info code: rather than using the
1258
tree being examined to predict output, it uses a bunch of flags which
1259
allow us, the test writers, to document what *should* be present in
1260
the output. Removing this separation would remove the value of the
1263
:param path: the path to the light checkout.
1264
:param lco_tree: the tree object for the light checkout.
1265
:param shared_repo: A shared repository is in use, expect that in
1267
:param repo_branch: A branch in a shared repository for non light
1269
:param tree_locked: If true, expect the tree to be locked.
1270
:param branch_locked: If true, expect the branch to be locked.
1271
:param repo_locked: If true, expect the repository to be locked.
1272
Note that the lco_tree.branch.repository is inspected, and if is not
1273
actually locked then this parameter is overridden. This is because
1274
pack repositories do not have any public API for obtaining an
1275
exclusive repository wide lock.
1276
:param verbose: verbosity level: 2 or higher to show committers
1278
def friendly_location(url):
1279
path = urlutils.unescape_for_display(url, 'ascii')
1281
return osutils.relpath(osutils.getcwd(), path)
1282
except errors.PathNotChild:
1286
# We expect this to fail because of locking errors.
1287
# (A write-locked file cannot be read-locked
1288
# in the different process -- either on win32 or on linux).
1289
# This should be removed when the locking errors are fixed.
1290
self.expectFailure('OS locks are exclusive '
1291
'for different processes (Bug #174055)',
1292
self.run_bzr_subprocess,
1293
'info ' + command_string)
1294
out, err = self.run_bzr('info %s' % command_string)
1296
(True, True): 'Lightweight checkout',
1297
(True, False): 'Repository checkout',
1298
(False, True): 'Lightweight checkout',
1299
(False, False): 'Checkout',
1300
}[(shared_repo is not None, light_checkout)]
1301
format = {True: self._repo_strings,
1302
False: 'unnamed'}[light_checkout]
1304
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1305
if repo_locked or branch_locked or tree_locked:
1306
def locked_message(a_bool):
1311
expected_lock_output = (
1314
" working tree: %s\n"
1316
" repository: %s\n" % (
1317
locked_message(tree_locked),
1318
locked_message(branch_locked),
1319
locked_message(repo_locked)))
1321
expected_lock_output = ''
1325
tree_data = (" light checkout root: %s\n" %
1326
friendly_location(lco_tree.controldir.root_transport.base))
1328
if lco_tree.branch.get_bound_location() is not None:
1329
tree_data += ("%s checkout root: %s\n" % (extra_space,
1330
friendly_location(lco_tree.branch.controldir.root_transport.base)))
1331
if shared_repo is not None:
1333
" checkout of branch: %s\n"
1334
" shared repository: %s\n" %
1335
(friendly_location(repo_branch.controldir.root_transport.base),
1336
friendly_location(shared_repo.controldir.root_transport.base)))
1337
elif repo_branch is not None:
1339
"%s checkout of branch: %s\n" %
1341
friendly_location(repo_branch.controldir.root_transport.base)))
1343
branch_data = (" checkout of branch: %s\n" %
1344
lco_tree.branch.controldir.root_transport.base)
1347
verbose_info = ' 0 committers\n'
1351
self.assertEqualDiff(
1356
control: Meta directory format 1
1364
In the working tree:
1373
0 versioned subdirectories
1384
lco_tree._format.get_format_description(),
1385
lco_tree.branch._format.get_format_description(),
1386
lco_tree.branch.repository._format.get_format_description(),
1387
expected_lock_output,
1390
self.assertEqual('', err)
1392
def test_info_locking(self):
1393
transport = self.get_transport()
1394
# Create shared repository with a branch
1395
repo = self.make_repository('repo', shared=True,
1396
format=bzrdir.BzrDirMetaFormat1())
1397
repo.set_make_working_trees(False)
1398
repo.controldir.root_transport.mkdir('branch')
1399
repo_branch = controldir.ControlDir.create_branch_convenience(
1400
'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1401
# Do a heavy checkout
1402
transport.mkdir('tree')
1403
transport.mkdir('tree/checkout')
1404
co_branch = controldir.ControlDir.create_branch_convenience(
1405
'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1406
co_branch.bind(repo_branch)
1407
# Do a light checkout of the heavy one
1408
transport.mkdir('tree/lightcheckout')
1409
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1410
lco_dir.set_branch_reference(co_branch)
1411
lco_dir.create_workingtree()
1412
lco_tree = lco_dir.open_workingtree()
1414
# Test all permutations of locking the working tree, branch and repository
1418
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1419
repo_branch=repo_branch,
1420
verbose=True, light_checkout=True)
1422
with lco_tree.branch.repository.lock_write():
1423
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1424
lco_tree, repo_branch=repo_branch,
1425
repo_locked=True, verbose=True, light_checkout=True)
1427
with lco_tree.branch.lock_write():
1428
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1432
repo_branch=repo_branch,
1435
with lco_tree.lock_write():
1436
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1437
lco_tree, repo_branch=repo_branch,
1443
with lco_tree.lock_write(), lco_tree.branch.repository.unlock():
1444
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1445
lco_tree, repo_branch=repo_branch,
1450
with lco_tree.lock_write(), lco_tree.branch.unlock():
1451
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1452
lco_tree, repo_branch=repo_branch,
1456
with lco_tree.lock_write(), lco_tree.branch.unlock(), \
1457
lco_tree.branch.repository.lock_write():
1458
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1459
lco_tree, repo_branch=repo_branch,
1464
with lco_tree.branch.lock_write(), lco_tree.branch.repository.unlock():
1465
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1466
lco_tree, repo_branch=repo_branch,
1470
if sys.platform == 'win32':
1471
self.knownFailure('Win32 cannot run "brz info"'
1472
' when the tree is locked.')
1474
def test_info_stacked(self):
1475
# We have a mainline
1476
trunk_tree = self.make_branch_and_tree('mainline',
1478
trunk_tree.commit('mainline')
1479
# and a branch from it which is stacked
1480
new_dir = trunk_tree.controldir.sprout('newbranch', stacked=True)
1481
out, err = self.run_bzr('info newbranch')
1483
"""Standalone tree (format: 1.6)
1485
branch root: newbranch
1488
parent branch: mainline
1489
stacked on: mainline
1491
self.assertEqual("", err)
1493
def test_info_revinfo_optional(self):
1494
tree = self.make_branch_and_tree('.')
1496
def last_revision_info(self):
1497
raise errors.UnsupportedOperation(last_revision_info, self)
1499
branch.Branch, "last_revision_info", last_revision_info)
1500
out, err = self.run_bzr('info -v .')
1502
"""Standalone tree (format: 2a)
1507
control: Meta directory format 1
1508
working tree: Working tree format 6
1509
branch: Branch format 7
1510
repository: Repository format 2a - rich roots, group compression and chk inventories
1515
In the working tree:
1524
0 versioned subdirectories
1526
self.assertEqual("", err)
1528
def test_info_shows_colocated_branches(self):
1529
bzrdir = self.make_branch('.', format='development-colo').controldir
1530
bzrdir.create_branch(name="colo1")
1531
bzrdir.create_branch(name="colo2")
1532
bzrdir.create_branch(name="colo3")
1533
out, err = self.run_bzr('info -v .')
1534
self.assertEqualDiff(
1535
"""Standalone branch (format: development-colo)
1540
control: Meta directory format 1 with support for colocated branches
1541
branch: Branch format 7
1542
repository: Repository format 2a - rich roots, group compression and chk inventories
1553
self.assertEqual("", err)
1556
class TestSmartServerInfo(tests.TestCaseWithTransport):
1558
def test_simple_branch_info(self):
1559
self.setup_smart_server_with_call_log()
1560
t = self.make_branch_and_tree('branch')
1561
self.build_tree_contents([('branch/foo', b'thecontents')])
1564
self.reset_smart_call_log()
1565
out, err = self.run_bzr(['info', self.get_url('branch')])
1566
# This figure represent the amount of work to perform this use case. It
1567
# is entirely ok to reduce this number if a test fails due to rpc_count
1568
# being too low. If rpc_count increases, more network roundtrips have
1569
# become necessary for this use case. Please do not adjust this number
1570
# upwards without agreement from bzr's network support maintainers.
1571
self.assertLength(10, self.hpss_calls)
1572
self.assertLength(1, self.hpss_connections)
1573
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
1575
def test_verbose_branch_info(self):
1576
self.setup_smart_server_with_call_log()
1577
t = self.make_branch_and_tree('branch')
1578
self.build_tree_contents([('branch/foo', b'thecontents')])
1581
self.reset_smart_call_log()
1582
out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
1583
# This figure represent the amount of work to perform this use case. It
1584
# is entirely ok to reduce this number if a test fails due to rpc_count
1585
# being too low. If rpc_count increases, more network roundtrips have
1586
# become necessary for this use case. Please do not adjust this number
1587
# upwards without agreement from bzr's network support maintainers.
1588
self.assertLength(14, self.hpss_calls)
1589
self.assertLength(1, self.hpss_connections)
1590
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)