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
113
0 versioned subdirectories
121
self.assertEqual('', err)
123
# Standalone branch - really verbose mode
124
out, err = self.run_bzr('info standalone -vv')
125
self.assertEqualDiff(
126
"""Standalone tree (format: knit)
128
branch root: standalone
131
control: Meta directory format 1
132
working tree: Working tree format 3
133
branch: Branch format 5
134
repository: Knit repository format 1
147
0 versioned subdirectories
156
self.assertEqual('', err)
157
tree1.commit('commit one')
158
rev = branch1.repository.get_revision(branch1.last_revision())
159
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
161
# Branch standalone with push location
162
branch2 = branch1.bzrdir.sprout('branch').open_branch()
163
branch2.set_push_location(branch1.bzrdir.root_transport.base)
165
out, err = self.run_bzr('info branch')
166
self.assertEqualDiff(
167
"""Standalone tree (format: knit)
172
push branch: standalone
173
parent branch: standalone
175
self.assertEqual('', err)
177
out, err = self.run_bzr('info branch --verbose')
178
self.assertEqualDiff(
179
"""Standalone tree (format: knit)
184
push branch: standalone
185
parent branch: standalone
188
control: Meta directory format 1
189
working tree: Working tree format 3
190
branch: Branch format 5
191
repository: Knit repository format 1
204
0 versioned subdirectories
214
""" % (datestring_first, datestring_first,
216
self.assertEqual('', err)
218
# Branch and bind to standalone, needs upgrade to metadir
219
# (creates backup as unknown)
220
branch1.bzrdir.sprout('bound')
221
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
222
upgrade.upgrade('bound', knit1_format)
223
branch3 = controldir.ControlDir.open('bound').open_branch()
224
branch3.bind(branch1)
225
bound_tree = branch3.bzrdir.open_workingtree()
226
out, err = self.run_bzr('info -v bound')
227
self.assertEqualDiff(
228
"""Checkout (format: knit)
231
checkout of branch: standalone
234
parent branch: standalone
237
control: Meta directory format 1
253
0 versioned subdirectories
263
""" % (bound_tree._format.get_format_description(),
264
branch3._format.get_format_description(),
265
branch3.repository._format.get_format_description(),
266
datestring_first, datestring_first,
268
self.assertEqual('', err)
270
# Checkout standalone (same as above, but does not have parent set)
271
branch4 = controldir.ControlDir.create_branch_convenience('checkout',
273
branch4.bind(branch1)
274
branch4.bzrdir.open_workingtree().update()
275
out, err = self.run_bzr('info checkout --verbose')
276
self.assertEqualDiff(
277
"""Checkout (format: knit)
279
checkout root: checkout
280
checkout of branch: standalone
283
control: Meta directory format 1
284
working tree: Working tree format 3
285
branch: Branch format 5
299
0 versioned subdirectories
309
""" % (branch4.repository._format.get_format_description(),
310
datestring_first, datestring_first,
312
self.assertEqual('', err)
314
# Lightweight checkout (same as above, different branch and repository)
315
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
316
branch5 = tree5.branch
317
out, err = self.run_bzr('info -v lightcheckout')
318
if "metaweave" in bzrdir.format_registry:
319
format_description = "knit or metaweave"
321
format_description = "knit"
322
self.assertEqualDiff(
323
"""Lightweight checkout (format: %s)
325
light checkout root: lightcheckout
326
checkout of branch: standalone
329
control: Meta directory format 1
330
working tree: Working tree format 3
331
branch: Branch format 5
332
repository: Knit repository format 1
345
0 versioned subdirectories
355
""" % (format_description, datestring_first, datestring_first,), out)
356
self.assertEqual('', err)
358
# Update initial standalone branch
359
self.build_tree(['standalone/b'])
361
tree1.commit('commit two')
362
rev = branch1.repository.get_revision(branch1.last_revision())
363
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
365
# Out of date branched standalone branch will not be detected
366
out, err = self.run_bzr('info -v branch')
367
self.assertEqualDiff(
368
"""Standalone tree (format: knit)
373
push branch: standalone
374
parent branch: standalone
377
control: Meta directory format 1
378
working tree: Working tree format 3
379
branch: Branch format 5
380
repository: Knit repository format 1
393
0 versioned subdirectories
403
""" % (datestring_first, datestring_first,
405
self.assertEqual('', err)
407
# Out of date bound branch
408
out, err = self.run_bzr('info -v bound')
409
self.assertEqualDiff(
410
"""Checkout (format: knit)
413
checkout of branch: standalone
416
parent branch: standalone
419
control: Meta directory format 1
420
working tree: Working tree format 3
421
branch: Branch format 5
427
Branch is out of date: missing 1 revision.
437
0 versioned subdirectories
447
""" % (branch3.repository._format.get_format_description(),
448
datestring_first, datestring_first,
450
self.assertEqual('', err)
452
# Out of date checkout
453
out, err = self.run_bzr('info -v checkout')
454
self.assertEqualDiff(
455
"""Checkout (format: knit)
457
checkout root: checkout
458
checkout of branch: standalone
461
control: Meta directory format 1
462
working tree: Working tree format 3
463
branch: Branch format 5
469
Branch is out of date: missing 1 revision.
479
0 versioned subdirectories
489
""" % (branch4.repository._format.get_format_description(),
490
datestring_first, datestring_first,
492
self.assertEqual('', err)
494
# Out of date lightweight checkout
495
out, err = self.run_bzr('info lightcheckout --verbose')
496
self.assertEqualDiff(
497
"""Lightweight checkout (format: %s)
499
light checkout root: lightcheckout
500
checkout of branch: standalone
503
control: Meta directory format 1
504
working tree: Working tree format 3
505
branch: Branch format 5
506
repository: Knit repository format 1
511
Working tree is out of date: missing 1 revision.
521
0 versioned subdirectories
531
""" % (format_description, datestring_first, datestring_last,), out)
532
self.assertEqual('', err)
534
def test_info_standalone_no_tree(self):
535
# create standalone branch without a working tree
536
format = bzrdir.format_registry.make_bzrdir('default')
537
branch = self.make_branch('branch')
538
repo = branch.repository
539
out, err = self.run_bzr('info branch -v')
540
self.assertEqualDiff(
541
"""Standalone branch (format: %s)
546
control: Meta directory format 1
558
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
559
format.get_branch_format().get_format_description(),
560
format.repository_format.get_format_description(),
562
self.assertEqual('', err)
564
def test_info_shared_repository(self):
565
format = bzrdir.format_registry.make_bzrdir('knit')
566
transport = self.get_transport()
568
# Create shared repository
569
repo = self.make_repository('repo', shared=True, format=format)
570
repo.set_make_working_trees(False)
571
out, err = self.run_bzr('info -v repo')
572
self.assertEqualDiff(
573
"""Shared repository (format: dirstate or dirstate-tags or knit)
575
shared repository: %s
578
control: Meta directory format 1
586
""" % ('repo', format.repository_format.get_format_description(),
588
self.assertEqual('', err)
590
# Create branch inside shared repository
591
repo.bzrdir.root_transport.mkdir('branch')
592
branch1 = controldir.ControlDir.create_branch_convenience(
593
'repo/branch', format=format)
594
out, err = self.run_bzr('info -v repo/branch')
595
self.assertEqualDiff(
596
"""Repository branch (format: dirstate or knit)
598
shared repository: repo
599
repository branch: repo/branch
602
control: Meta directory format 1
614
""" % (format.get_branch_format().get_format_description(),
615
format.repository_format.get_format_description(),
617
self.assertEqual('', err)
619
# Create lightweight checkout
620
transport.mkdir('tree')
621
transport.mkdir('tree/lightcheckout')
622
tree2 = branch1.create_checkout('tree/lightcheckout',
624
branch2 = tree2.branch
625
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
626
shared_repo=repo, repo_branch=branch1, verbose=True)
628
# Create normal checkout
629
tree3 = branch1.create_checkout('tree/checkout')
630
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
632
light_checkout=False, repo_branch=branch1)
633
# Update lightweight checkout
634
self.build_tree(['tree/lightcheckout/a'])
636
tree2.commit('commit one')
637
rev = repo.get_revision(branch2.last_revision())
638
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
639
out, err = self.run_bzr('info tree/lightcheckout --verbose')
640
self.assertEqualDiff(
641
"""Lightweight checkout (format: %s)
643
light checkout root: tree/lightcheckout
644
checkout of branch: repo/branch
645
shared repository: repo
648
control: Meta directory format 1
649
working tree: Working tree format 6
664
0 versioned subdirectories
674
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
675
format.repository_format.get_format_description(),
676
datestring_first, datestring_first,
678
self.assertEqual('', err)
680
# Out of date checkout
681
out, err = self.run_bzr('info -v tree/checkout')
682
self.assertEqualDiff(
683
"""Checkout (format: unnamed)
685
checkout root: tree/checkout
686
checkout of branch: repo/branch
689
control: Meta directory format 1
690
working tree: Working tree format 6
697
Branch is out of date: missing 1 revision.
707
0 versioned subdirectories
714
""" % (format.get_branch_format().get_format_description(),
715
format.repository_format.get_format_description(),
717
self.assertEqual('', err)
721
self.build_tree(['tree/checkout/b'])
723
out, err = self.run_bzr('info tree/checkout --verbose')
724
self.assertEqualDiff(
725
"""Checkout (format: unnamed)
727
checkout root: tree/checkout
728
checkout of branch: repo/branch
731
control: Meta directory format 1
732
working tree: Working tree format 6
747
0 versioned subdirectories
757
""" % (format.get_branch_format().get_format_description(),
758
format.repository_format.get_format_description(),
759
datestring_first, datestring_first,
761
self.assertEqual('', err)
762
tree3.commit('commit two')
764
# Out of date lightweight checkout
765
rev = repo.get_revision(branch1.last_revision())
766
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
767
out, err = self.run_bzr('info tree/lightcheckout --verbose')
768
self.assertEqualDiff(
769
"""Lightweight checkout (format: %s)
771
light checkout root: tree/lightcheckout
772
checkout of branch: repo/branch
773
shared repository: repo
776
control: Meta directory format 1
777
working tree: Working tree format 6
784
Working tree is out of date: missing 1 revision.
794
0 versioned subdirectories
804
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
805
format.repository_format.get_format_description(),
806
datestring_first, datestring_last,
808
self.assertEqual('', err)
810
# Show info about shared branch
811
out, err = self.run_bzr('info repo/branch --verbose')
812
self.assertEqualDiff(
813
"""Repository branch (format: dirstate or knit)
815
shared repository: repo
816
repository branch: repo/branch
819
control: Meta directory format 1
834
""" % (format.get_branch_format().get_format_description(),
835
format.repository_format.get_format_description(),
836
datestring_first, datestring_last,
838
self.assertEqual('', err)
840
# Show info about repository with revisions
841
out, err = self.run_bzr('info -v repo')
842
self.assertEqualDiff(
843
"""Shared repository (format: dirstate or dirstate-tags or knit)
845
shared repository: repo
848
control: Meta directory format 1
856
""" % (format.repository_format.get_format_description(),
858
self.assertEqual('', err)
860
def test_info_shared_repository_with_trees(self):
861
format = bzrdir.format_registry.make_bzrdir('knit')
862
transport = self.get_transport()
864
# Create shared repository with working trees
865
repo = self.make_repository('repo', shared=True, format=format)
866
repo.set_make_working_trees(True)
867
out, err = self.run_bzr('info -v repo')
868
self.assertEqualDiff(
869
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
871
shared repository: repo
874
control: Meta directory format 1
880
Create working tree for new branches inside the repository.
884
""" % (format.repository_format.get_format_description(),
886
self.assertEqual('', err)
888
# Create two branches
889
repo.bzrdir.root_transport.mkdir('branch1')
890
branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
892
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
895
out, err = self.run_bzr('info repo/branch1 --verbose')
896
self.assertEqualDiff(
897
"""Repository tree (format: knit)
899
shared repository: repo
900
repository branch: repo/branch1
903
control: Meta directory format 1
904
working tree: Working tree format 3
919
0 versioned subdirectories
926
""" % (format.get_branch_format().get_format_description(),
927
format.repository_format.get_format_description(),
929
self.assertEqual('', err)
931
# Update first branch
932
self.build_tree(['repo/branch1/a'])
933
tree1 = branch1.bzrdir.open_workingtree()
935
tree1.commit('commit one')
936
rev = repo.get_revision(branch1.last_revision())
937
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
938
out, err = self.run_bzr('info -v repo/branch1')
939
self.assertEqualDiff(
940
"""Repository tree (format: knit)
942
shared repository: repo
943
repository branch: repo/branch1
946
control: Meta directory format 1
947
working tree: Working tree format 3
962
0 versioned subdirectories
972
""" % (format.get_branch_format().get_format_description(),
973
format.repository_format.get_format_description(),
974
datestring_first, datestring_first,
976
self.assertEqual('', err)
978
# Out of date second branch
979
out, err = self.run_bzr('info repo/branch2 --verbose')
980
self.assertEqualDiff(
981
"""Repository tree (format: knit)
983
shared repository: repo
984
repository branch: repo/branch2
987
parent branch: repo/branch1
990
control: Meta directory format 1
991
working tree: Working tree format 3
1006
0 versioned subdirectories
1013
""" % (format.get_branch_format().get_format_description(),
1014
format.repository_format.get_format_description(),
1016
self.assertEqual('', err)
1018
# Update second branch
1019
tree2 = branch2.bzrdir.open_workingtree()
1021
out, err = self.run_bzr('info -v repo/branch2')
1022
self.assertEqualDiff(
1023
"""Repository tree (format: knit)
1025
shared repository: repo
1026
repository branch: repo/branch2
1029
parent branch: repo/branch1
1032
control: Meta directory format 1
1033
working tree: Working tree format 3
1040
In the working tree:
1048
0 versioned subdirectories
1058
""" % (format.get_branch_format().get_format_description(),
1059
format.repository_format.get_format_description(),
1060
datestring_first, datestring_first,
1062
self.assertEqual('', err)
1064
# Show info about repository with revisions
1065
out, err = self.run_bzr('info -v repo')
1066
self.assertEqualDiff(
1067
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1069
shared repository: repo
1072
control: Meta directory format 1
1078
Create working tree for new branches inside the repository.
1082
""" % (format.repository_format.get_format_description(),
1085
self.assertEqual('', err)
1087
def test_info_shared_repository_with_tree_in_root(self):
1088
format = bzrdir.format_registry.make_bzrdir('knit')
1089
transport = self.get_transport()
1091
# Create shared repository with working trees
1092
repo = self.make_repository('repo', shared=True, format=format)
1093
repo.set_make_working_trees(True)
1094
out, err = self.run_bzr('info -v repo')
1095
self.assertEqualDiff(
1096
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1098
shared repository: repo
1101
control: Meta directory format 1
1107
Create working tree for new branches inside the repository.
1111
""" % (format.repository_format.get_format_description(),
1113
self.assertEqual('', err)
1115
# Create branch in root of repository
1116
control = repo.bzrdir
1117
branch = control.create_branch()
1118
control.create_workingtree()
1119
out, err = self.run_bzr('info -v repo')
1120
self.assertEqualDiff(
1121
"""Repository tree (format: knit)
1123
shared repository: repo
1124
repository branch: repo
1127
control: Meta directory format 1
1128
working tree: Working tree format 3
1135
In the working tree:
1143
0 versioned subdirectories
1150
""" % (format.get_branch_format().get_format_description(),
1151
format.repository_format.get_format_description(),
1153
self.assertEqual('', err)
1155
def test_info_repository_hook(self):
1156
format = bzrdir.format_registry.make_bzrdir('knit')
1157
def repo_info(repo, stats, outf):
1158
outf.write("more info\n")
1159
info.hooks.install_named_hook('repository', repo_info, None)
1160
# Create shared repository with working trees
1161
repo = self.make_repository('repo', shared=True, format=format)
1162
out, err = self.run_bzr('info -v repo')
1163
self.assertEqualDiff(
1164
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1166
shared repository: repo
1169
control: Meta directory format 1
1175
Create working tree for new branches inside the repository.
1180
""" % (format.repository_format.get_format_description(),
1182
self.assertEqual('', err)
1184
def test_info_unshared_repository_with_colocated_branches(self):
1185
format = bzrdir.format_registry.make_bzrdir('development-colo')
1186
transport = self.get_transport()
1188
# Create unshared repository
1189
repo = self.make_repository('repo', shared=False, format=format)
1190
repo.set_make_working_trees(True)
1191
repo.bzrdir.create_branch(name='foo')
1192
out, err = self.run_bzr('info repo')
1193
self.assertEqualDiff(
1194
"""Unshared repository with trees and colocated branches (format: development-colo)
1198
self.assertEqual('', err)
1200
def assertCheckoutStatusOutput(self,
1201
command_string, lco_tree, shared_repo=None,
1204
branch_locked=False, repo_locked=False,
1206
light_checkout=True,
1207
checkout_root=None):
1208
"""Check the output of info in a checkout.
1210
This is not quite a mirror of the info code: rather than using the
1211
tree being examined to predict output, it uses a bunch of flags which
1212
allow us, the test writers, to document what *should* be present in
1213
the output. Removing this separation would remove the value of the
1216
:param path: the path to the light checkout.
1217
:param lco_tree: the tree object for the light checkout.
1218
:param shared_repo: A shared repository is in use, expect that in
1220
:param repo_branch: A branch in a shared repository for non light
1222
:param tree_locked: If true, expect the tree to be locked.
1223
:param branch_locked: If true, expect the branch to be locked.
1224
:param repo_locked: If true, expect the repository to be locked.
1225
Note that the lco_tree.branch.repository is inspected, and if is not
1226
actually locked then this parameter is overridden. This is because
1227
pack repositories do not have any public API for obtaining an
1228
exclusive repository wide lock.
1229
:param verbose: verbosity level: 2 or higher to show committers
1231
def friendly_location(url):
1232
path = urlutils.unescape_for_display(url, 'ascii')
1234
return osutils.relpath(osutils.getcwd(), path)
1235
except errors.PathNotChild:
1239
# We expect this to fail because of locking errors.
1240
# (A write-locked file cannot be read-locked
1241
# in the different process -- either on win32 or on linux).
1242
# This should be removed when the locking errors are fixed.
1243
self.expectFailure('OS locks are exclusive '
1244
'for different processes (Bug #174055)',
1245
self.run_bzr_subprocess,
1246
'info ' + command_string)
1247
out, err = self.run_bzr('info %s' % command_string)
1249
(True, True): 'Lightweight checkout',
1250
(True, False): 'Repository checkout',
1251
(False, True): 'Lightweight checkout',
1252
(False, False): 'Checkout',
1253
}[(shared_repo is not None, light_checkout)]
1254
format = {True: self._repo_strings,
1255
False: 'unnamed'}[light_checkout]
1257
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1258
if repo_locked or branch_locked or tree_locked:
1259
def locked_message(a_bool):
1264
expected_lock_output = (
1267
" working tree: %s\n"
1269
" repository: %s\n" % (
1270
locked_message(tree_locked),
1271
locked_message(branch_locked),
1272
locked_message(repo_locked)))
1274
expected_lock_output = ''
1278
tree_data = (" light checkout root: %s\n" %
1279
friendly_location(lco_tree.bzrdir.root_transport.base))
1281
if lco_tree.branch.get_bound_location() is not None:
1282
tree_data += ("%s checkout root: %s\n" % (extra_space,
1283
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1284
if shared_repo is not None:
1286
" checkout of branch: %s\n"
1287
" shared repository: %s\n" %
1288
(friendly_location(repo_branch.bzrdir.root_transport.base),
1289
friendly_location(shared_repo.bzrdir.root_transport.base)))
1290
elif repo_branch is not None:
1292
"%s checkout of branch: %s\n" %
1294
friendly_location(repo_branch.bzrdir.root_transport.base)))
1296
branch_data = (" checkout of branch: %s\n" %
1297
lco_tree.branch.bzrdir.root_transport.base)
1300
verbose_info = ' 0 committers\n'
1304
self.assertEqualDiff(
1309
control: Meta directory format 1
1317
In the working tree:
1325
0 versioned subdirectories
1336
lco_tree._format.get_format_description(),
1337
lco_tree.branch._format.get_format_description(),
1338
lco_tree.branch.repository._format.get_format_description(),
1339
expected_lock_output,
1342
self.assertEqual('', err)
1344
def test_info_locking(self):
1345
transport = self.get_transport()
1346
# Create shared repository with a branch
1347
repo = self.make_repository('repo', shared=True,
1348
format=bzrdir.BzrDirMetaFormat1())
1349
repo.set_make_working_trees(False)
1350
repo.bzrdir.root_transport.mkdir('branch')
1351
repo_branch = controldir.ControlDir.create_branch_convenience(
1352
'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1353
# Do a heavy checkout
1354
transport.mkdir('tree')
1355
transport.mkdir('tree/checkout')
1356
co_branch = controldir.ControlDir.create_branch_convenience(
1357
'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1358
co_branch.bind(repo_branch)
1359
# Do a light checkout of the heavy one
1360
transport.mkdir('tree/lightcheckout')
1361
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1362
lco_dir.set_branch_reference(co_branch)
1363
lco_dir.create_workingtree()
1364
lco_tree = lco_dir.open_workingtree()
1366
# Test all permutations of locking the working tree, branch and repository
1370
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1371
repo_branch=repo_branch,
1372
verbose=True, light_checkout=True)
1374
lco_tree.branch.repository.lock_write()
1376
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1377
lco_tree, repo_branch=repo_branch,
1378
repo_locked=True, verbose=True, light_checkout=True)
1380
lco_tree.branch.repository.unlock()
1382
lco_tree.branch.lock_write()
1384
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1388
repo_branch=repo_branch,
1391
lco_tree.branch.unlock()
1393
lco_tree.lock_write()
1395
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1396
lco_tree, repo_branch=repo_branch,
1404
lco_tree.lock_write()
1405
lco_tree.branch.repository.unlock()
1407
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1408
lco_tree, repo_branch=repo_branch,
1413
lco_tree.branch.repository.lock_write()
1416
lco_tree.lock_write()
1417
lco_tree.branch.unlock()
1419
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1420
lco_tree, repo_branch=repo_branch,
1424
lco_tree.branch.lock_write()
1427
lco_tree.lock_write()
1428
lco_tree.branch.unlock()
1429
lco_tree.branch.repository.lock_write()
1431
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1432
lco_tree, repo_branch=repo_branch,
1437
lco_tree.branch.repository.unlock()
1438
lco_tree.branch.lock_write()
1441
lco_tree.branch.lock_write()
1442
lco_tree.branch.repository.unlock()
1444
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1445
lco_tree, repo_branch=repo_branch,
1449
lco_tree.branch.repository.lock_write()
1450
lco_tree.branch.unlock()
1452
if sys.platform == 'win32':
1453
self.knownFailure('Win32 cannot run "bzr info"'
1454
' when the tree is locked.')
1456
def test_info_stacked(self):
1457
# We have a mainline
1458
trunk_tree = self.make_branch_and_tree('mainline',
1460
trunk_tree.commit('mainline')
1461
# and a branch from it which is stacked
1462
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1463
out, err = self.run_bzr('info newbranch')
1465
"""Standalone tree (format: 1.6)
1467
branch root: newbranch
1470
parent branch: mainline
1471
stacked on: mainline
1473
self.assertEqual("", err)
1475
def test_info_revinfo_optional(self):
1476
tree = self.make_branch_and_tree('.')
1477
def last_revision_info(self):
1478
raise errors.UnsupportedOperation(last_revision_info, self)
1480
branch.Branch, "last_revision_info", last_revision_info)
1481
out, err = self.run_bzr('info -v .')
1483
"""Standalone tree (format: 2a)
1488
control: Meta directory format 1
1489
working tree: Working tree format 6
1490
branch: Branch format 7
1491
repository: Repository format 2a - rich roots, group compression and chk inventories
1496
In the working tree:
1504
0 versioned subdirectories
1506
self.assertEqual("", err)
1508
def test_info_shows_colocated_branches(self):
1509
bzrdir = self.make_branch('.', format='development-colo').bzrdir
1510
bzrdir.create_branch(name="colo1")
1511
bzrdir.create_branch(name="colo2")
1512
bzrdir.create_branch(name="colo3")
1513
out, err = self.run_bzr('info -v .')
1514
self.assertEqualDiff(
1515
"""Standalone branch (format: development-colo)
1520
control: Meta directory format 1 with support for colocated branches
1521
branch: Branch format 7
1522
repository: Repository format 2a - rich roots, group compression and chk inventories
1533
self.assertEqual("", err)
1536
class TestSmartServerInfo(tests.TestCaseWithTransport):
1538
def test_simple_branch_info(self):
1539
self.setup_smart_server_with_call_log()
1540
t = self.make_branch_and_tree('branch')
1541
self.build_tree_contents([('branch/foo', 'thecontents')])
1544
self.reset_smart_call_log()
1545
out, err = self.run_bzr(['info', self.get_url('branch')])
1546
# This figure represent the amount of work to perform this use case. It
1547
# is entirely ok to reduce this number if a test fails due to rpc_count
1548
# being too low. If rpc_count increases, more network roundtrips have
1549
# become necessary for this use case. Please do not adjust this number
1550
# upwards without agreement from bzr's network support maintainers.
1551
self.assertLength(12, self.hpss_calls)
1552
self.assertLength(1, self.hpss_connections)
1553
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
1555
def test_verbose_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', 'thecontents')])
1561
self.reset_smart_call_log()
1562
out, err = self.run_bzr(['info', '-v', 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(16, self.hpss_calls)
1569
self.assertLength(1, self.hpss_connections)
1570
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)