1
# Copyright (C) 2006-2010 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."""
34
from bzrlib.tests.matchers import ContainsNoVfsCalls
35
from bzrlib.transport import memory
38
class TestInfo(tests.TestCaseWithTransport):
41
super(TestInfo, self).setUp()
42
self._repo_strings = "2a"
44
def test_info_non_existing(self):
45
self.vfs_transport_factory = memory.MemoryServer
46
location = self.get_url()
47
out, err = self.run_bzr('info '+location, retcode=3)
48
self.assertEqual(out, '')
49
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
51
def test_info_empty_controldir(self):
52
self.make_bzrdir('ctrl')
53
out, err = self.run_bzr('info ctrl')
54
self.assertEquals(out,
55
'Empty control directory (format: 2a or pack-0.92)\n'
57
' control directory: ctrl\n')
58
self.assertEquals(err, '')
60
def test_info_dangling_branch_reference(self):
61
br = self.make_branch('target')
62
br.create_checkout('from', lightweight=True)
63
shutil.rmtree('target')
64
out, err = self.run_bzr('info from')
65
self.assertEquals(out,
66
'Dangling branch reference (format: 2a or pack-0.92)\n'
68
' control directory: from\n'
69
' checkout of branch: target\n')
70
self.assertEquals(err, '')
72
def test_info_standalone(self):
73
transport = self.get_transport()
75
# Create initial standalone branch
76
tree1 = self.make_branch_and_tree('standalone', 'knit')
77
self.build_tree(['standalone/a'])
79
branch1 = tree1.branch
81
out, err = self.run_bzr('info standalone')
83
"""Standalone tree (format: knit)
85
branch root: standalone
87
self.assertEqual('', err)
89
# Standalone branch - verbose mode
90
out, err = self.run_bzr('info standalone -v')
92
"""Standalone tree (format: knit)
94
branch root: standalone
97
control: Meta directory format 1
98
working tree: Working tree format 3
99
branch: Branch format 5
100
repository: Knit repository format 1
110
0 versioned subdirectories
118
self.assertEqual('', err)
120
# Standalone branch - really verbose mode
121
out, err = self.run_bzr('info standalone -vv')
122
self.assertEqualDiff(
123
"""Standalone tree (format: knit)
125
branch root: standalone
128
control: Meta directory format 1
129
working tree: Working tree format 3
130
branch: Branch format 5
131
repository: Knit repository format 1
141
0 versioned subdirectories
150
self.assertEqual('', err)
151
tree1.commit('commit one')
152
rev = branch1.repository.get_revision(branch1.last_revision())
153
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
155
# Branch standalone with push location
156
branch2 = branch1.bzrdir.sprout('branch').open_branch()
157
branch2.set_push_location(branch1.bzrdir.root_transport.base)
159
out, err = self.run_bzr('info branch')
160
self.assertEqualDiff(
161
"""Standalone tree (format: knit)
166
push branch: standalone
167
parent branch: standalone
169
self.assertEqual('', err)
171
out, err = self.run_bzr('info branch --verbose')
172
self.assertEqualDiff(
173
"""Standalone tree (format: knit)
178
push branch: standalone
179
parent branch: standalone
182
control: Meta directory format 1
183
working tree: Working tree format 3
184
branch: Branch format 5
185
repository: Knit repository format 1
195
0 versioned subdirectories
205
""" % (datestring_first, datestring_first,
207
self.assertEqual('', err)
209
# Branch and bind to standalone, needs upgrade to metadir
210
# (creates backup as unknown)
211
branch1.bzrdir.sprout('bound')
212
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
213
upgrade.upgrade('bound', knit1_format)
214
branch3 = controldir.ControlDir.open('bound').open_branch()
215
branch3.bind(branch1)
216
bound_tree = branch3.bzrdir.open_workingtree()
217
out, err = self.run_bzr('info -v bound')
218
self.assertEqualDiff(
219
"""Checkout (format: knit)
222
checkout of branch: standalone
225
parent branch: standalone
228
control: Meta directory format 1
241
0 versioned subdirectories
251
""" % (bound_tree._format.get_format_description(),
252
branch3._format.get_format_description(),
253
branch3.repository._format.get_format_description(),
254
datestring_first, datestring_first,
256
self.assertEqual('', err)
258
# Checkout standalone (same as above, but does not have parent set)
259
branch4 = controldir.ControlDir.create_branch_convenience('checkout',
261
branch4.bind(branch1)
262
branch4.bzrdir.open_workingtree().update()
263
out, err = self.run_bzr('info checkout --verbose')
264
self.assertEqualDiff(
265
"""Checkout (format: knit)
267
checkout root: checkout
268
checkout of branch: standalone
271
control: Meta directory format 1
272
working tree: Working tree format 3
273
branch: Branch format 5
284
0 versioned subdirectories
294
""" % (branch4.repository._format.get_format_description(),
295
datestring_first, datestring_first,
297
self.assertEqual('', err)
299
# Lightweight checkout (same as above, different branch and repository)
300
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
301
branch5 = tree5.branch
302
out, err = self.run_bzr('info -v lightcheckout')
303
if "metaweave" in bzrdir.format_registry:
304
format_description = "knit or metaweave"
306
format_description = "knit"
307
self.assertEqualDiff(
308
"""Lightweight checkout (format: %s)
310
light checkout root: lightcheckout
311
checkout of branch: standalone
314
control: Meta directory format 1
315
working tree: Working tree format 3
316
branch: Branch format 5
317
repository: Knit repository format 1
327
0 versioned subdirectories
337
""" % (format_description, datestring_first, datestring_first,), out)
338
self.assertEqual('', err)
340
# Update initial standalone branch
341
self.build_tree(['standalone/b'])
343
tree1.commit('commit two')
344
rev = branch1.repository.get_revision(branch1.last_revision())
345
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
347
# Out of date branched standalone branch will not be detected
348
out, err = self.run_bzr('info -v branch')
349
self.assertEqualDiff(
350
"""Standalone tree (format: knit)
355
push branch: standalone
356
parent branch: standalone
359
control: Meta directory format 1
360
working tree: Working tree format 3
361
branch: Branch format 5
362
repository: Knit repository format 1
372
0 versioned subdirectories
382
""" % (datestring_first, datestring_first,
384
self.assertEqual('', err)
386
# Out of date bound branch
387
out, err = self.run_bzr('info -v bound')
388
self.assertEqualDiff(
389
"""Checkout (format: knit)
392
checkout of branch: standalone
395
parent branch: standalone
398
control: Meta directory format 1
399
working tree: Working tree format 3
400
branch: Branch format 5
403
Branch is out of date: missing 1 revision.
413
0 versioned subdirectories
423
""" % (branch3.repository._format.get_format_description(),
424
datestring_first, datestring_first,
426
self.assertEqual('', err)
428
# Out of date checkout
429
out, err = self.run_bzr('info -v checkout')
430
self.assertEqualDiff(
431
"""Checkout (format: knit)
433
checkout root: checkout
434
checkout of branch: standalone
437
control: Meta directory format 1
438
working tree: Working tree format 3
439
branch: Branch format 5
442
Branch is out of date: missing 1 revision.
452
0 versioned subdirectories
462
""" % (branch4.repository._format.get_format_description(),
463
datestring_first, datestring_first,
465
self.assertEqual('', err)
467
# Out of date lightweight checkout
468
out, err = self.run_bzr('info lightcheckout --verbose')
469
self.assertEqualDiff(
470
"""Lightweight checkout (format: %s)
472
light checkout root: lightcheckout
473
checkout of branch: standalone
476
control: Meta directory format 1
477
working tree: Working tree format 3
478
branch: Branch format 5
479
repository: Knit repository format 1
481
Working tree is out of date: missing 1 revision.
491
0 versioned subdirectories
501
""" % (format_description, datestring_first, datestring_last,), out)
502
self.assertEqual('', err)
504
def test_info_standalone_no_tree(self):
505
# create standalone branch without a working tree
506
format = bzrdir.format_registry.make_bzrdir('default')
507
branch = self.make_branch('branch')
508
repo = branch.repository
509
out, err = self.run_bzr('info branch -v')
510
self.assertEqualDiff(
511
"""Standalone branch (format: %s)
516
control: Meta directory format 1
525
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
526
format.get_branch_format().get_format_description(),
527
format.repository_format.get_format_description(),
529
self.assertEqual('', err)
531
def test_info_shared_repository(self):
532
format = bzrdir.format_registry.make_bzrdir('knit')
533
transport = self.get_transport()
535
# Create shared repository
536
repo = self.make_repository('repo', shared=True, format=format)
537
repo.set_make_working_trees(False)
538
out, err = self.run_bzr('info -v repo')
539
self.assertEqualDiff(
540
"""Shared repository (format: dirstate or dirstate-tags or knit)
542
shared repository: %s
545
control: Meta directory format 1
550
""" % ('repo', format.repository_format.get_format_description(),
552
self.assertEqual('', err)
554
# Create branch inside shared repository
555
repo.bzrdir.root_transport.mkdir('branch')
556
branch1 = controldir.ControlDir.create_branch_convenience(
557
'repo/branch', format=format)
558
out, err = self.run_bzr('info -v repo/branch')
559
self.assertEqualDiff(
560
"""Repository branch (format: dirstate or knit)
562
shared repository: repo
563
repository branch: repo/branch
566
control: Meta directory format 1
575
""" % (format.get_branch_format().get_format_description(),
576
format.repository_format.get_format_description(),
578
self.assertEqual('', err)
580
# Create lightweight checkout
581
transport.mkdir('tree')
582
transport.mkdir('tree/lightcheckout')
583
tree2 = branch1.create_checkout('tree/lightcheckout',
585
branch2 = tree2.branch
586
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
587
shared_repo=repo, repo_branch=branch1, verbose=True)
589
# Create normal checkout
590
tree3 = branch1.create_checkout('tree/checkout')
591
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
593
light_checkout=False, repo_branch=branch1)
594
# Update lightweight checkout
595
self.build_tree(['tree/lightcheckout/a'])
597
tree2.commit('commit one')
598
rev = repo.get_revision(branch2.last_revision())
599
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
600
out, err = self.run_bzr('info tree/lightcheckout --verbose')
601
self.assertEqualDiff(
602
"""Lightweight checkout (format: %s)
604
light checkout root: tree/lightcheckout
605
checkout of branch: repo/branch
606
shared repository: repo
609
control: Meta directory format 1
610
working tree: Working tree format 6
622
0 versioned subdirectories
632
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
633
format.repository_format.get_format_description(),
634
datestring_first, datestring_first,
636
self.assertEqual('', err)
638
# Out of date checkout
639
out, err = self.run_bzr('info -v tree/checkout')
640
self.assertEqualDiff(
641
"""Checkout (format: unnamed)
643
checkout root: tree/checkout
644
checkout of branch: repo/branch
647
control: Meta directory format 1
648
working tree: Working tree format 6
652
Branch is out of date: missing 1 revision.
662
0 versioned subdirectories
669
""" % (format.get_branch_format().get_format_description(),
670
format.repository_format.get_format_description(),
672
self.assertEqual('', err)
676
self.build_tree(['tree/checkout/b'])
678
out, err = self.run_bzr('info tree/checkout --verbose')
679
self.assertEqualDiff(
680
"""Checkout (format: unnamed)
682
checkout root: tree/checkout
683
checkout of branch: repo/branch
686
control: Meta directory format 1
687
working tree: Working tree format 6
699
0 versioned subdirectories
709
""" % (format.get_branch_format().get_format_description(),
710
format.repository_format.get_format_description(),
711
datestring_first, datestring_first,
713
self.assertEqual('', err)
714
tree3.commit('commit two')
716
# Out of date lightweight checkout
717
rev = repo.get_revision(branch1.last_revision())
718
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
719
out, err = self.run_bzr('info tree/lightcheckout --verbose')
720
self.assertEqualDiff(
721
"""Lightweight checkout (format: %s)
723
light checkout root: tree/lightcheckout
724
checkout of branch: repo/branch
725
shared repository: repo
728
control: Meta directory format 1
729
working tree: Working tree format 6
733
Working tree is out of date: missing 1 revision.
743
0 versioned subdirectories
753
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
754
format.repository_format.get_format_description(),
755
datestring_first, datestring_last,
757
self.assertEqual('', err)
759
# Show info about shared branch
760
out, err = self.run_bzr('info repo/branch --verbose')
761
self.assertEqualDiff(
762
"""Repository branch (format: dirstate or knit)
764
shared repository: repo
765
repository branch: repo/branch
768
control: Meta directory format 1
780
""" % (format.get_branch_format().get_format_description(),
781
format.repository_format.get_format_description(),
782
datestring_first, datestring_last,
784
self.assertEqual('', err)
786
# Show info about repository with revisions
787
out, err = self.run_bzr('info -v repo')
788
self.assertEqualDiff(
789
"""Shared repository (format: dirstate or dirstate-tags or knit)
791
shared repository: repo
794
control: Meta directory format 1
799
""" % (format.repository_format.get_format_description(),
801
self.assertEqual('', err)
803
def test_info_shared_repository_with_trees(self):
804
format = bzrdir.format_registry.make_bzrdir('knit')
805
transport = self.get_transport()
807
# Create shared repository with working trees
808
repo = self.make_repository('repo', shared=True, format=format)
809
repo.set_make_working_trees(True)
810
out, err = self.run_bzr('info -v repo')
811
self.assertEqualDiff(
812
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
814
shared repository: repo
817
control: Meta directory format 1
820
Create working tree for new branches inside the repository.
824
""" % (format.repository_format.get_format_description(),
826
self.assertEqual('', err)
828
# Create two branches
829
repo.bzrdir.root_transport.mkdir('branch1')
830
branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
832
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
835
out, err = self.run_bzr('info repo/branch1 --verbose')
836
self.assertEqualDiff(
837
"""Repository tree (format: knit)
839
shared repository: repo
840
repository branch: repo/branch1
843
control: Meta directory format 1
844
working tree: Working tree format 3
856
0 versioned subdirectories
863
""" % (format.get_branch_format().get_format_description(),
864
format.repository_format.get_format_description(),
866
self.assertEqual('', err)
868
# Update first branch
869
self.build_tree(['repo/branch1/a'])
870
tree1 = branch1.bzrdir.open_workingtree()
872
tree1.commit('commit one')
873
rev = repo.get_revision(branch1.last_revision())
874
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
875
out, err = self.run_bzr('info -v repo/branch1')
876
self.assertEqualDiff(
877
"""Repository tree (format: knit)
879
shared repository: repo
880
repository branch: repo/branch1
883
control: Meta directory format 1
884
working tree: Working tree format 3
896
0 versioned subdirectories
906
""" % (format.get_branch_format().get_format_description(),
907
format.repository_format.get_format_description(),
908
datestring_first, datestring_first,
910
self.assertEqual('', err)
912
# Out of date second branch
913
out, err = self.run_bzr('info repo/branch2 --verbose')
914
self.assertEqualDiff(
915
"""Repository tree (format: knit)
917
shared repository: repo
918
repository branch: repo/branch2
921
parent branch: repo/branch1
924
control: Meta directory format 1
925
working tree: Working tree format 3
937
0 versioned subdirectories
944
""" % (format.get_branch_format().get_format_description(),
945
format.repository_format.get_format_description(),
947
self.assertEqual('', err)
949
# Update second branch
950
tree2 = branch2.bzrdir.open_workingtree()
952
out, err = self.run_bzr('info -v repo/branch2')
953
self.assertEqualDiff(
954
"""Repository tree (format: knit)
956
shared repository: repo
957
repository branch: repo/branch2
960
parent branch: repo/branch1
963
control: Meta directory format 1
964
working tree: Working tree format 3
976
0 versioned subdirectories
986
""" % (format.get_branch_format().get_format_description(),
987
format.repository_format.get_format_description(),
988
datestring_first, datestring_first,
990
self.assertEqual('', err)
992
# Show info about repository with revisions
993
out, err = self.run_bzr('info -v repo')
994
self.assertEqualDiff(
995
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
997
shared repository: repo
1000
control: Meta directory format 1
1003
Create working tree for new branches inside the repository.
1007
""" % (format.repository_format.get_format_description(),
1010
self.assertEqual('', err)
1012
def test_info_shared_repository_with_tree_in_root(self):
1013
format = bzrdir.format_registry.make_bzrdir('knit')
1014
transport = self.get_transport()
1016
# Create shared repository with working trees
1017
repo = self.make_repository('repo', shared=True, format=format)
1018
repo.set_make_working_trees(True)
1019
out, err = self.run_bzr('info -v repo')
1020
self.assertEqualDiff(
1021
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1023
shared repository: repo
1026
control: Meta directory format 1
1029
Create working tree for new branches inside the repository.
1033
""" % (format.repository_format.get_format_description(),
1035
self.assertEqual('', err)
1037
# Create branch in root of repository
1038
control = repo.bzrdir
1039
branch = control.create_branch()
1040
control.create_workingtree()
1041
out, err = self.run_bzr('info -v repo')
1042
self.assertEqualDiff(
1043
"""Repository tree (format: knit)
1045
shared repository: repo
1046
repository branch: repo
1049
control: Meta directory format 1
1050
working tree: Working tree format 3
1054
In the working tree:
1062
0 versioned subdirectories
1069
""" % (format.get_branch_format().get_format_description(),
1070
format.repository_format.get_format_description(),
1072
self.assertEqual('', err)
1074
def test_info_repository_hook(self):
1075
format = bzrdir.format_registry.make_bzrdir('knit')
1076
def repo_info(repo, stats, outf):
1077
outf.write("more info\n")
1078
info.hooks.install_named_hook('repository', repo_info, None)
1079
# Create shared repository with working trees
1080
repo = self.make_repository('repo', shared=True, format=format)
1081
out, err = self.run_bzr('info -v repo')
1082
self.assertEqualDiff(
1083
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1085
shared repository: repo
1088
control: Meta directory format 1
1091
Create working tree for new branches inside the repository.
1096
""" % (format.repository_format.get_format_description(),
1098
self.assertEqual('', err)
1100
def assertCheckoutStatusOutput(self,
1101
command_string, lco_tree, shared_repo=None,
1104
branch_locked=False, repo_locked=False,
1106
light_checkout=True,
1107
checkout_root=None):
1108
"""Check the output of info in a checkout.
1110
This is not quite a mirror of the info code: rather than using the
1111
tree being examined to predict output, it uses a bunch of flags which
1112
allow us, the test writers, to document what *should* be present in
1113
the output. Removing this separation would remove the value of the
1116
:param path: the path to the light checkout.
1117
:param lco_tree: the tree object for the light checkout.
1118
:param shared_repo: A shared repository is in use, expect that in
1120
:param repo_branch: A branch in a shared repository for non light
1122
:param tree_locked: If true, expect the tree to be locked.
1123
:param branch_locked: If true, expect the branch to be locked.
1124
:param repo_locked: If true, expect the repository to be locked.
1125
Note that the lco_tree.branch.repository is inspected, and if is not
1126
actually locked then this parameter is overridden. This is because
1127
pack repositories do not have any public API for obtaining an
1128
exclusive repository wide lock.
1129
:param verbose: verbosity level: 2 or higher to show committers
1131
def friendly_location(url):
1132
path = urlutils.unescape_for_display(url, 'ascii')
1134
return osutils.relpath(osutils.getcwd(), path)
1135
except errors.PathNotChild:
1139
# We expect this to fail because of locking errors.
1140
# (A write-locked file cannot be read-locked
1141
# in the different process -- either on win32 or on linux).
1142
# This should be removed when the locking errors are fixed.
1143
self.expectFailure('OS locks are exclusive '
1144
'for different processes (Bug #174055)',
1145
self.run_bzr_subprocess,
1146
'info ' + command_string)
1147
out, err = self.run_bzr('info %s' % command_string)
1149
(True, True): 'Lightweight checkout',
1150
(True, False): 'Repository checkout',
1151
(False, True): 'Lightweight checkout',
1152
(False, False): 'Checkout',
1153
}[(shared_repo is not None, light_checkout)]
1154
format = {True: self._repo_strings,
1155
False: 'unnamed'}[light_checkout]
1157
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1158
if repo_locked or branch_locked or tree_locked:
1159
def locked_message(a_bool):
1164
expected_lock_output = (
1167
" working tree: %s\n"
1169
" repository: %s\n" % (
1170
locked_message(tree_locked),
1171
locked_message(branch_locked),
1172
locked_message(repo_locked)))
1174
expected_lock_output = ''
1178
tree_data = (" light checkout root: %s\n" %
1179
friendly_location(lco_tree.bzrdir.root_transport.base))
1181
if lco_tree.branch.get_bound_location() is not None:
1182
tree_data += ("%s checkout root: %s\n" % (extra_space,
1183
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1184
if shared_repo is not None:
1186
" checkout of branch: %s\n"
1187
" shared repository: %s\n" %
1188
(friendly_location(repo_branch.bzrdir.root_transport.base),
1189
friendly_location(shared_repo.bzrdir.root_transport.base)))
1190
elif repo_branch is not None:
1192
"%s checkout of branch: %s\n" %
1194
friendly_location(repo_branch.bzrdir.root_transport.base)))
1196
branch_data = (" checkout of branch: %s\n" %
1197
lco_tree.branch.bzrdir.root_transport.base)
1200
verbose_info = ' 0 committers\n'
1204
self.assertEqualDiff(
1209
control: Meta directory format 1
1214
In the working tree:
1222
0 versioned subdirectories
1233
lco_tree._format.get_format_description(),
1234
lco_tree.branch._format.get_format_description(),
1235
lco_tree.branch.repository._format.get_format_description(),
1236
expected_lock_output,
1239
self.assertEqual('', err)
1241
def test_info_locking(self):
1242
transport = self.get_transport()
1243
# Create shared repository with a branch
1244
repo = self.make_repository('repo', shared=True,
1245
format=bzrdir.BzrDirMetaFormat1())
1246
repo.set_make_working_trees(False)
1247
repo.bzrdir.root_transport.mkdir('branch')
1248
repo_branch = controldir.ControlDir.create_branch_convenience(
1249
'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1250
# Do a heavy checkout
1251
transport.mkdir('tree')
1252
transport.mkdir('tree/checkout')
1253
co_branch = controldir.ControlDir.create_branch_convenience(
1254
'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1255
co_branch.bind(repo_branch)
1256
# Do a light checkout of the heavy one
1257
transport.mkdir('tree/lightcheckout')
1258
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1259
branch.BranchReferenceFormat().initialize(lco_dir,
1260
target_branch=co_branch)
1261
lco_dir.create_workingtree()
1262
lco_tree = lco_dir.open_workingtree()
1264
# Test all permutations of locking the working tree, branch and repository
1268
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1269
repo_branch=repo_branch,
1270
verbose=True, light_checkout=True)
1272
lco_tree.branch.repository.lock_write()
1274
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1275
lco_tree, repo_branch=repo_branch,
1276
repo_locked=True, verbose=True, light_checkout=True)
1278
lco_tree.branch.repository.unlock()
1280
lco_tree.branch.lock_write()
1282
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1286
repo_branch=repo_branch,
1289
lco_tree.branch.unlock()
1291
lco_tree.lock_write()
1293
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1294
lco_tree, repo_branch=repo_branch,
1302
lco_tree.lock_write()
1303
lco_tree.branch.repository.unlock()
1305
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1306
lco_tree, repo_branch=repo_branch,
1311
lco_tree.branch.repository.lock_write()
1314
lco_tree.lock_write()
1315
lco_tree.branch.unlock()
1317
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1318
lco_tree, repo_branch=repo_branch,
1322
lco_tree.branch.lock_write()
1325
lco_tree.lock_write()
1326
lco_tree.branch.unlock()
1327
lco_tree.branch.repository.lock_write()
1329
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1330
lco_tree, repo_branch=repo_branch,
1335
lco_tree.branch.repository.unlock()
1336
lco_tree.branch.lock_write()
1339
lco_tree.branch.lock_write()
1340
lco_tree.branch.repository.unlock()
1342
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1343
lco_tree, repo_branch=repo_branch,
1347
lco_tree.branch.repository.lock_write()
1348
lco_tree.branch.unlock()
1350
if sys.platform == 'win32':
1351
self.knownFailure('Win32 cannot run "bzr info"'
1352
' when the tree is locked.')
1354
def test_info_stacked(self):
1355
# We have a mainline
1356
trunk_tree = self.make_branch_and_tree('mainline',
1358
trunk_tree.commit('mainline')
1359
# and a branch from it which is stacked
1360
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1361
out, err = self.run_bzr('info newbranch')
1363
"""Standalone tree (format: 1.6)
1365
branch root: newbranch
1368
parent branch: mainline
1369
stacked on: mainline
1371
self.assertEqual("", err)
1373
def test_info_revinfo_optional(self):
1374
tree = self.make_branch_and_tree('.')
1375
def last_revision_info(self):
1376
raise errors.UnsupportedOperation(last_revision_info, self)
1378
branch.Branch, "last_revision_info", last_revision_info)
1379
out, err = self.run_bzr('info -v .')
1381
"""Standalone tree (format: 2a)
1386
control: Meta directory format 1
1387
working tree: Working tree format 6
1388
branch: Branch format 7
1389
repository: Repository format 2a - rich roots, group compression and chk inventories
1391
In the working tree:
1399
0 versioned subdirectories
1401
self.assertEqual("", err)
1403
def test_info_shows_colocated_branches(self):
1404
bzrdir = self.make_branch('.', format='development-colo').bzrdir
1405
bzrdir.create_branch(name="colo1")
1406
bzrdir.create_branch(name="colo2")
1407
bzrdir.create_branch(name="colo3")
1408
out, err = self.run_bzr('info -v .')
1409
self.assertEqualDiff(
1410
"""Standalone branch (format: development-colo)
1415
control: Meta directory format 1 with support for colocated branches
1416
branch: Branch format 7
1417
repository: Repository format 2a - rich roots, group compression and chk inventories
1428
self.assertEqual("", err)
1431
class TestSmartServerInfo(tests.TestCaseWithTransport):
1433
def test_simple_branch_info(self):
1434
self.setup_smart_server_with_call_log()
1435
t = self.make_branch_and_tree('branch')
1436
self.build_tree_contents([('branch/foo', 'thecontents')])
1439
self.reset_smart_call_log()
1440
out, err = self.run_bzr(['info', self.get_url('branch')])
1441
# This figure represent the amount of work to perform this use case. It
1442
# is entirely ok to reduce this number if a test fails due to rpc_count
1443
# being too low. If rpc_count increases, more network roundtrips have
1444
# become necessary for this use case. Please do not adjust this number
1445
# upwards without agreement from bzr's network support maintainers.
1446
self.assertLength(12, self.hpss_calls)
1447
self.assertLength(1, self.hpss_connections)
1448
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
1450
def test_verbose_branch_info(self):
1451
self.setup_smart_server_with_call_log()
1452
t = self.make_branch_and_tree('branch')
1453
self.build_tree_contents([('branch/foo', 'thecontents')])
1456
self.reset_smart_call_log()
1457
out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
1458
# This figure represent the amount of work to perform this use case. It
1459
# is entirely ok to reduce this number if a test fails due to rpc_count
1460
# being too low. If rpc_count increases, more network roundtrips have
1461
# become necessary for this use case. Please do not adjust this number
1462
# upwards without agreement from bzr's network support maintainers.
1463
self.assertLength(16, self.hpss_calls)
1464
self.assertLength(1, self.hpss_connections)
1465
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)