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.transport import memory
37
class TestInfo(tests.TestCaseWithTransport):
40
super(TestInfo, self).setUp()
41
self._repo_strings = "2a"
43
def test_info_non_existing(self):
44
self.vfs_transport_factory = memory.MemoryServer
45
location = self.get_url()
46
out, err = self.run_bzr('info '+location, retcode=3)
47
self.assertEqual(out, '')
48
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
50
def test_info_empty_controldir(self):
51
self.make_bzrdir('ctrl')
52
out, err = self.run_bzr('info ctrl')
53
self.assertEquals(out,
54
'Empty control directory (format: 2a or pack-0.92)\n'
56
' control directory: ctrl\n')
57
self.assertEquals(err, '')
59
def test_info_dangling_branch_reference(self):
60
br = self.make_branch('target')
61
br.create_checkout('from', lightweight=True)
62
shutil.rmtree('target')
63
out, err = self.run_bzr('info from')
64
self.assertEquals(out,
65
'Dangling branch reference (format: 2a or pack-0.92)\n'
67
' control directory: from\n'
68
' checkout of branch: target\n')
69
self.assertEquals(err, '')
71
def test_info_standalone(self):
72
transport = self.get_transport()
74
# Create initial standalone branch
75
tree1 = self.make_branch_and_tree('standalone', 'knit')
76
self.build_tree(['standalone/a'])
78
branch1 = tree1.branch
80
out, err = self.run_bzr('info standalone')
82
"""Standalone tree (format: knit)
84
branch root: standalone
86
self.assertEqual('', err)
88
# Standalone branch - verbose mode
89
out, err = self.run_bzr('info standalone -v')
91
"""Standalone tree (format: knit)
93
branch root: standalone
96
control: Meta directory format 1
97
working tree: Working tree format 3
98
branch: Branch format 5
99
repository: Knit repository format 1
109
0 versioned subdirectories
117
self.assertEqual('', err)
119
# Standalone branch - really verbose mode
120
out, err = self.run_bzr('info standalone -vv')
121
self.assertEqualDiff(
122
"""Standalone tree (format: knit)
124
branch root: standalone
127
control: Meta directory format 1
128
working tree: Working tree format 3
129
branch: Branch format 5
130
repository: Knit repository format 1
140
0 versioned subdirectories
149
self.assertEqual('', err)
150
tree1.commit('commit one')
151
rev = branch1.repository.get_revision(branch1.last_revision())
152
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
154
# Branch standalone with push location
155
branch2 = branch1.bzrdir.sprout('branch').open_branch()
156
branch2.set_push_location(branch1.bzrdir.root_transport.base)
158
out, err = self.run_bzr('info branch')
159
self.assertEqualDiff(
160
"""Standalone tree (format: knit)
165
push branch: standalone
166
parent branch: standalone
168
self.assertEqual('', err)
170
out, err = self.run_bzr('info branch --verbose')
171
self.assertEqualDiff(
172
"""Standalone tree (format: knit)
177
push branch: standalone
178
parent branch: standalone
181
control: Meta directory format 1
182
working tree: Working tree format 3
183
branch: Branch format 5
184
repository: Knit repository format 1
194
0 versioned subdirectories
204
""" % (datestring_first, datestring_first,
206
self.assertEqual('', err)
208
# Branch and bind to standalone, needs upgrade to metadir
209
# (creates backup as unknown)
210
branch1.bzrdir.sprout('bound')
211
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
212
upgrade.upgrade('bound', knit1_format)
213
branch3 = controldir.ControlDir.open('bound').open_branch()
214
branch3.bind(branch1)
215
bound_tree = branch3.bzrdir.open_workingtree()
216
out, err = self.run_bzr('info -v bound')
217
self.assertEqualDiff(
218
"""Checkout (format: knit)
221
checkout of branch: standalone
224
parent branch: standalone
227
control: Meta directory format 1
240
0 versioned subdirectories
250
""" % (bound_tree._format.get_format_description(),
251
branch3._format.get_format_description(),
252
branch3.repository._format.get_format_description(),
253
datestring_first, datestring_first,
255
self.assertEqual('', err)
257
# Checkout standalone (same as above, but does not have parent set)
258
branch4 = controldir.ControlDir.create_branch_convenience('checkout',
260
branch4.bind(branch1)
261
branch4.bzrdir.open_workingtree().update()
262
out, err = self.run_bzr('info checkout --verbose')
263
self.assertEqualDiff(
264
"""Checkout (format: knit)
266
checkout root: checkout
267
checkout of branch: standalone
270
control: Meta directory format 1
271
working tree: Working tree format 3
272
branch: Branch format 5
283
0 versioned subdirectories
293
""" % (branch4.repository._format.get_format_description(),
294
datestring_first, datestring_first,
296
self.assertEqual('', err)
298
# Lightweight checkout (same as above, different branch and repository)
299
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
300
branch5 = tree5.branch
301
out, err = self.run_bzr('info -v lightcheckout')
302
if "metaweave" in bzrdir.format_registry:
303
format_description = "knit or metaweave"
305
format_description = "knit"
306
self.assertEqualDiff(
307
"""Lightweight checkout (format: %s)
309
light checkout root: lightcheckout
310
checkout of branch: standalone
313
control: Meta directory format 1
314
working tree: Working tree format 3
315
branch: Branch format 5
316
repository: Knit repository format 1
326
0 versioned subdirectories
336
""" % (format_description, datestring_first, datestring_first,), out)
337
self.assertEqual('', err)
339
# Update initial standalone branch
340
self.build_tree(['standalone/b'])
342
tree1.commit('commit two')
343
rev = branch1.repository.get_revision(branch1.last_revision())
344
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
346
# Out of date branched standalone branch will not be detected
347
out, err = self.run_bzr('info -v branch')
348
self.assertEqualDiff(
349
"""Standalone tree (format: knit)
354
push branch: standalone
355
parent branch: standalone
358
control: Meta directory format 1
359
working tree: Working tree format 3
360
branch: Branch format 5
361
repository: Knit repository format 1
371
0 versioned subdirectories
381
""" % (datestring_first, datestring_first,
383
self.assertEqual('', err)
385
# Out of date bound branch
386
out, err = self.run_bzr('info -v bound')
387
self.assertEqualDiff(
388
"""Checkout (format: knit)
391
checkout of branch: standalone
394
parent branch: standalone
397
control: Meta directory format 1
398
working tree: Working tree format 3
399
branch: Branch format 5
402
Branch is out of date: missing 1 revision.
412
0 versioned subdirectories
422
""" % (branch3.repository._format.get_format_description(),
423
datestring_first, datestring_first,
425
self.assertEqual('', err)
427
# Out of date checkout
428
out, err = self.run_bzr('info -v checkout')
429
self.assertEqualDiff(
430
"""Checkout (format: knit)
432
checkout root: checkout
433
checkout of branch: standalone
436
control: Meta directory format 1
437
working tree: Working tree format 3
438
branch: Branch format 5
441
Branch is out of date: missing 1 revision.
451
0 versioned subdirectories
461
""" % (branch4.repository._format.get_format_description(),
462
datestring_first, datestring_first,
464
self.assertEqual('', err)
466
# Out of date lightweight checkout
467
out, err = self.run_bzr('info lightcheckout --verbose')
468
self.assertEqualDiff(
469
"""Lightweight checkout (format: %s)
471
light checkout root: lightcheckout
472
checkout of branch: standalone
475
control: Meta directory format 1
476
working tree: Working tree format 3
477
branch: Branch format 5
478
repository: Knit repository format 1
480
Working tree is out of date: missing 1 revision.
490
0 versioned subdirectories
500
""" % (format_description, datestring_first, datestring_last,), out)
501
self.assertEqual('', err)
503
def test_info_standalone_no_tree(self):
504
# create standalone branch without a working tree
505
format = bzrdir.format_registry.make_bzrdir('default')
506
branch = self.make_branch('branch')
507
repo = branch.repository
508
out, err = self.run_bzr('info branch -v')
509
self.assertEqualDiff(
510
"""Standalone branch (format: %s)
515
control: Meta directory format 1
524
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
525
format.get_branch_format().get_format_description(),
526
format.repository_format.get_format_description(),
528
self.assertEqual('', err)
530
def test_info_shared_repository(self):
531
format = bzrdir.format_registry.make_bzrdir('knit')
532
transport = self.get_transport()
534
# Create shared repository
535
repo = self.make_repository('repo', shared=True, format=format)
536
repo.set_make_working_trees(False)
537
out, err = self.run_bzr('info -v repo')
538
self.assertEqualDiff(
539
"""Shared repository (format: dirstate or dirstate-tags or knit)
541
shared repository: %s
544
control: Meta directory format 1
549
""" % ('repo', format.repository_format.get_format_description(),
551
self.assertEqual('', err)
553
# Create branch inside shared repository
554
repo.bzrdir.root_transport.mkdir('branch')
555
branch1 = controldir.ControlDir.create_branch_convenience(
556
'repo/branch', format=format)
557
out, err = self.run_bzr('info -v repo/branch')
558
self.assertEqualDiff(
559
"""Repository branch (format: dirstate or knit)
561
shared repository: repo
562
repository branch: repo/branch
565
control: Meta directory format 1
574
""" % (format.get_branch_format().get_format_description(),
575
format.repository_format.get_format_description(),
577
self.assertEqual('', err)
579
# Create lightweight checkout
580
transport.mkdir('tree')
581
transport.mkdir('tree/lightcheckout')
582
tree2 = branch1.create_checkout('tree/lightcheckout',
584
branch2 = tree2.branch
585
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
586
shared_repo=repo, repo_branch=branch1, verbose=True)
588
# Create normal checkout
589
tree3 = branch1.create_checkout('tree/checkout')
590
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
592
light_checkout=False, repo_branch=branch1)
593
# Update lightweight checkout
594
self.build_tree(['tree/lightcheckout/a'])
596
tree2.commit('commit one')
597
rev = repo.get_revision(branch2.last_revision())
598
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
599
out, err = self.run_bzr('info tree/lightcheckout --verbose')
600
self.assertEqualDiff(
601
"""Lightweight checkout (format: %s)
603
light checkout root: tree/lightcheckout
604
checkout of branch: repo/branch
605
shared repository: repo
608
control: Meta directory format 1
609
working tree: Working tree format 6
621
0 versioned subdirectories
631
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
632
format.repository_format.get_format_description(),
633
datestring_first, datestring_first,
635
self.assertEqual('', err)
637
# Out of date checkout
638
out, err = self.run_bzr('info -v tree/checkout')
639
self.assertEqualDiff(
640
"""Checkout (format: unnamed)
642
checkout root: tree/checkout
643
checkout of branch: repo/branch
646
control: Meta directory format 1
647
working tree: Working tree format 6
651
Branch is out of date: missing 1 revision.
661
0 versioned subdirectories
668
""" % (format.get_branch_format().get_format_description(),
669
format.repository_format.get_format_description(),
671
self.assertEqual('', err)
675
self.build_tree(['tree/checkout/b'])
677
out, err = self.run_bzr('info tree/checkout --verbose')
678
self.assertEqualDiff(
679
"""Checkout (format: unnamed)
681
checkout root: tree/checkout
682
checkout of branch: repo/branch
685
control: Meta directory format 1
686
working tree: Working tree format 6
698
0 versioned subdirectories
708
""" % (format.get_branch_format().get_format_description(),
709
format.repository_format.get_format_description(),
710
datestring_first, datestring_first,
712
self.assertEqual('', err)
713
tree3.commit('commit two')
715
# Out of date lightweight checkout
716
rev = repo.get_revision(branch1.last_revision())
717
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
718
out, err = self.run_bzr('info tree/lightcheckout --verbose')
719
self.assertEqualDiff(
720
"""Lightweight checkout (format: %s)
722
light checkout root: tree/lightcheckout
723
checkout of branch: repo/branch
724
shared repository: repo
727
control: Meta directory format 1
728
working tree: Working tree format 6
732
Working tree is out of date: missing 1 revision.
742
0 versioned subdirectories
752
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
753
format.repository_format.get_format_description(),
754
datestring_first, datestring_last,
756
self.assertEqual('', err)
758
# Show info about shared branch
759
out, err = self.run_bzr('info repo/branch --verbose')
760
self.assertEqualDiff(
761
"""Repository branch (format: dirstate or knit)
763
shared repository: repo
764
repository branch: repo/branch
767
control: Meta directory format 1
779
""" % (format.get_branch_format().get_format_description(),
780
format.repository_format.get_format_description(),
781
datestring_first, datestring_last,
783
self.assertEqual('', err)
785
# Show info about repository with revisions
786
out, err = self.run_bzr('info -v repo')
787
self.assertEqualDiff(
788
"""Shared repository (format: dirstate or dirstate-tags or knit)
790
shared repository: repo
793
control: Meta directory format 1
798
""" % (format.repository_format.get_format_description(),
800
self.assertEqual('', err)
802
def test_info_shared_repository_with_trees(self):
803
format = bzrdir.format_registry.make_bzrdir('knit')
804
transport = self.get_transport()
806
# Create shared repository with working trees
807
repo = self.make_repository('repo', shared=True, format=format)
808
repo.set_make_working_trees(True)
809
out, err = self.run_bzr('info -v repo')
810
self.assertEqualDiff(
811
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
813
shared repository: repo
816
control: Meta directory format 1
819
Create working tree for new branches inside the repository.
823
""" % (format.repository_format.get_format_description(),
825
self.assertEqual('', err)
827
# Create two branches
828
repo.bzrdir.root_transport.mkdir('branch1')
829
branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
831
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
834
out, err = self.run_bzr('info repo/branch1 --verbose')
835
self.assertEqualDiff(
836
"""Repository tree (format: knit)
838
shared repository: repo
839
repository branch: repo/branch1
842
control: Meta directory format 1
843
working tree: Working tree format 3
855
0 versioned subdirectories
862
""" % (format.get_branch_format().get_format_description(),
863
format.repository_format.get_format_description(),
865
self.assertEqual('', err)
867
# Update first branch
868
self.build_tree(['repo/branch1/a'])
869
tree1 = branch1.bzrdir.open_workingtree()
871
tree1.commit('commit one')
872
rev = repo.get_revision(branch1.last_revision())
873
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
874
out, err = self.run_bzr('info -v repo/branch1')
875
self.assertEqualDiff(
876
"""Repository tree (format: knit)
878
shared repository: repo
879
repository branch: repo/branch1
882
control: Meta directory format 1
883
working tree: Working tree format 3
895
0 versioned subdirectories
905
""" % (format.get_branch_format().get_format_description(),
906
format.repository_format.get_format_description(),
907
datestring_first, datestring_first,
909
self.assertEqual('', err)
911
# Out of date second branch
912
out, err = self.run_bzr('info repo/branch2 --verbose')
913
self.assertEqualDiff(
914
"""Repository tree (format: knit)
916
shared repository: repo
917
repository branch: repo/branch2
920
parent branch: repo/branch1
923
control: Meta directory format 1
924
working tree: Working tree format 3
936
0 versioned subdirectories
943
""" % (format.get_branch_format().get_format_description(),
944
format.repository_format.get_format_description(),
946
self.assertEqual('', err)
948
# Update second branch
949
tree2 = branch2.bzrdir.open_workingtree()
951
out, err = self.run_bzr('info -v repo/branch2')
952
self.assertEqualDiff(
953
"""Repository tree (format: knit)
955
shared repository: repo
956
repository branch: repo/branch2
959
parent branch: repo/branch1
962
control: Meta directory format 1
963
working tree: Working tree format 3
975
0 versioned subdirectories
985
""" % (format.get_branch_format().get_format_description(),
986
format.repository_format.get_format_description(),
987
datestring_first, datestring_first,
989
self.assertEqual('', err)
991
# Show info about repository with revisions
992
out, err = self.run_bzr('info -v repo')
993
self.assertEqualDiff(
994
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
996
shared repository: repo
999
control: Meta directory format 1
1002
Create working tree for new branches inside the repository.
1006
""" % (format.repository_format.get_format_description(),
1009
self.assertEqual('', err)
1011
def test_info_shared_repository_with_tree_in_root(self):
1012
format = bzrdir.format_registry.make_bzrdir('knit')
1013
transport = self.get_transport()
1015
# Create shared repository with working trees
1016
repo = self.make_repository('repo', shared=True, format=format)
1017
repo.set_make_working_trees(True)
1018
out, err = self.run_bzr('info -v repo')
1019
self.assertEqualDiff(
1020
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1022
shared repository: repo
1025
control: Meta directory format 1
1028
Create working tree for new branches inside the repository.
1032
""" % (format.repository_format.get_format_description(),
1034
self.assertEqual('', err)
1036
# Create branch in root of repository
1037
control = repo.bzrdir
1038
branch = control.create_branch()
1039
control.create_workingtree()
1040
out, err = self.run_bzr('info -v repo')
1041
self.assertEqualDiff(
1042
"""Repository tree (format: knit)
1044
shared repository: repo
1045
repository branch: repo
1048
control: Meta directory format 1
1049
working tree: Working tree format 3
1053
In the working tree:
1061
0 versioned subdirectories
1068
""" % (format.get_branch_format().get_format_description(),
1069
format.repository_format.get_format_description(),
1071
self.assertEqual('', err)
1073
def test_info_repository_hook(self):
1074
format = bzrdir.format_registry.make_bzrdir('knit')
1075
def repo_info(repo, stats, outf):
1076
outf.write("more info\n")
1077
info.hooks.install_named_hook('repository', repo_info, None)
1078
# Create shared repository with working trees
1079
repo = self.make_repository('repo', shared=True, format=format)
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
1090
Create working tree for new branches inside the repository.
1095
""" % (format.repository_format.get_format_description(),
1097
self.assertEqual('', err)
1099
def assertCheckoutStatusOutput(self,
1100
command_string, lco_tree, shared_repo=None,
1103
branch_locked=False, repo_locked=False,
1105
light_checkout=True,
1106
checkout_root=None):
1107
"""Check the output of info in a checkout.
1109
This is not quite a mirror of the info code: rather than using the
1110
tree being examined to predict output, it uses a bunch of flags which
1111
allow us, the test writers, to document what *should* be present in
1112
the output. Removing this separation would remove the value of the
1115
:param path: the path to the light checkout.
1116
:param lco_tree: the tree object for the light checkout.
1117
:param shared_repo: A shared repository is in use, expect that in
1119
:param repo_branch: A branch in a shared repository for non light
1121
:param tree_locked: If true, expect the tree to be locked.
1122
:param branch_locked: If true, expect the branch to be locked.
1123
:param repo_locked: If true, expect the repository to be locked.
1124
Note that the lco_tree.branch.repository is inspected, and if is not
1125
actually locked then this parameter is overridden. This is because
1126
pack repositories do not have any public API for obtaining an
1127
exclusive repository wide lock.
1128
:param verbose: verbosity level: 2 or higher to show committers
1130
def friendly_location(url):
1131
path = urlutils.unescape_for_display(url, 'ascii')
1133
return osutils.relpath(osutils.getcwd(), path)
1134
except errors.PathNotChild:
1138
# We expect this to fail because of locking errors.
1139
# (A write-locked file cannot be read-locked
1140
# in the different process -- either on win32 or on linux).
1141
# This should be removed when the locking errors are fixed.
1142
self.expectFailure('OS locks are exclusive '
1143
'for different processes (Bug #174055)',
1144
self.run_bzr_subprocess,
1145
'info ' + command_string)
1146
out, err = self.run_bzr('info %s' % command_string)
1148
(True, True): 'Lightweight checkout',
1149
(True, False): 'Repository checkout',
1150
(False, True): 'Lightweight checkout',
1151
(False, False): 'Checkout',
1152
}[(shared_repo is not None, light_checkout)]
1153
format = {True: self._repo_strings,
1154
False: 'unnamed'}[light_checkout]
1156
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1157
if repo_locked or branch_locked or tree_locked:
1158
def locked_message(a_bool):
1163
expected_lock_output = (
1166
" working tree: %s\n"
1168
" repository: %s\n" % (
1169
locked_message(tree_locked),
1170
locked_message(branch_locked),
1171
locked_message(repo_locked)))
1173
expected_lock_output = ''
1177
tree_data = (" light checkout root: %s\n" %
1178
friendly_location(lco_tree.bzrdir.root_transport.base))
1180
if lco_tree.branch.get_bound_location() is not None:
1181
tree_data += ("%s checkout root: %s\n" % (extra_space,
1182
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1183
if shared_repo is not None:
1185
" checkout of branch: %s\n"
1186
" shared repository: %s\n" %
1187
(friendly_location(repo_branch.bzrdir.root_transport.base),
1188
friendly_location(shared_repo.bzrdir.root_transport.base)))
1189
elif repo_branch is not None:
1191
"%s checkout of branch: %s\n" %
1193
friendly_location(repo_branch.bzrdir.root_transport.base)))
1195
branch_data = (" checkout of branch: %s\n" %
1196
lco_tree.branch.bzrdir.root_transport.base)
1199
verbose_info = ' 0 committers\n'
1203
self.assertEqualDiff(
1208
control: Meta directory format 1
1213
In the working tree:
1221
0 versioned subdirectories
1232
lco_tree._format.get_format_description(),
1233
lco_tree.branch._format.get_format_description(),
1234
lco_tree.branch.repository._format.get_format_description(),
1235
expected_lock_output,
1238
self.assertEqual('', err)
1240
def test_info_locking(self):
1241
transport = self.get_transport()
1242
# Create shared repository with a branch
1243
repo = self.make_repository('repo', shared=True,
1244
format=bzrdir.BzrDirMetaFormat1())
1245
repo.set_make_working_trees(False)
1246
repo.bzrdir.root_transport.mkdir('branch')
1247
repo_branch = controldir.ControlDir.create_branch_convenience(
1248
'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1249
# Do a heavy checkout
1250
transport.mkdir('tree')
1251
transport.mkdir('tree/checkout')
1252
co_branch = controldir.ControlDir.create_branch_convenience(
1253
'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1254
co_branch.bind(repo_branch)
1255
# Do a light checkout of the heavy one
1256
transport.mkdir('tree/lightcheckout')
1257
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1258
branch.BranchReferenceFormat().initialize(lco_dir,
1259
target_branch=co_branch)
1260
lco_dir.create_workingtree()
1261
lco_tree = lco_dir.open_workingtree()
1263
# Test all permutations of locking the working tree, branch and repository
1267
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1268
repo_branch=repo_branch,
1269
verbose=True, light_checkout=True)
1271
lco_tree.branch.repository.lock_write()
1273
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1274
lco_tree, repo_branch=repo_branch,
1275
repo_locked=True, verbose=True, light_checkout=True)
1277
lco_tree.branch.repository.unlock()
1279
lco_tree.branch.lock_write()
1281
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1285
repo_branch=repo_branch,
1288
lco_tree.branch.unlock()
1290
lco_tree.lock_write()
1292
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1293
lco_tree, repo_branch=repo_branch,
1301
lco_tree.lock_write()
1302
lco_tree.branch.repository.unlock()
1304
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1305
lco_tree, repo_branch=repo_branch,
1310
lco_tree.branch.repository.lock_write()
1313
lco_tree.lock_write()
1314
lco_tree.branch.unlock()
1316
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1317
lco_tree, repo_branch=repo_branch,
1321
lco_tree.branch.lock_write()
1324
lco_tree.lock_write()
1325
lco_tree.branch.unlock()
1326
lco_tree.branch.repository.lock_write()
1328
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1329
lco_tree, repo_branch=repo_branch,
1334
lco_tree.branch.repository.unlock()
1335
lco_tree.branch.lock_write()
1338
lco_tree.branch.lock_write()
1339
lco_tree.branch.repository.unlock()
1341
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1342
lco_tree, repo_branch=repo_branch,
1346
lco_tree.branch.repository.lock_write()
1347
lco_tree.branch.unlock()
1349
if sys.platform == 'win32':
1350
self.knownFailure('Win32 cannot run "bzr info"'
1351
' when the tree is locked.')
1353
def test_info_stacked(self):
1354
# We have a mainline
1355
trunk_tree = self.make_branch_and_tree('mainline',
1357
trunk_tree.commit('mainline')
1358
# and a branch from it which is stacked
1359
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1360
out, err = self.run_bzr('info newbranch')
1362
"""Standalone tree (format: 1.6)
1364
branch root: newbranch
1367
parent branch: mainline
1368
stacked on: mainline
1370
self.assertEqual("", err)
1372
def test_info_revinfo_optional(self):
1373
tree = self.make_branch_and_tree('.')
1374
def last_revision_info(self):
1375
raise errors.UnsupportedOperation(last_revision_info, self)
1377
branch.Branch, "last_revision_info", last_revision_info)
1378
out, err = self.run_bzr('info -v .')
1380
"""Standalone tree (format: 2a)
1385
control: Meta directory format 1
1386
working tree: Working tree format 6
1387
branch: Branch format 7
1388
repository: Repository format 2a - rich roots, group compression and chk inventories
1390
In the working tree:
1398
0 versioned subdirectories
1400
self.assertEqual("", err)
1402
def test_info_shows_colocated_branches(self):
1403
bzrdir = self.make_branch('.', format='development-colo').bzrdir
1404
bzrdir.create_branch(name="colo1")
1405
bzrdir.create_branch(name="colo2")
1406
bzrdir.create_branch(name="colo3")
1407
out, err = self.run_bzr('info -v .')
1408
self.assertEqualDiff(
1409
"""Standalone branch (format: development-colo)
1414
control: Meta directory format 1 with support for colocated branches
1415
branch: Branch format 7
1416
repository: Repository format 2a - rich roots, group compression and chk inventories
1427
self.assertEqual("", err)
1430
class TestSmartServerInfo(tests.TestCaseWithTransport):
1432
def test_simple_branch_info(self):
1433
self.setup_smart_server_with_call_log()
1434
t = self.make_branch_and_tree('branch')
1435
self.build_tree_contents([('branch/foo', 'thecontents')])
1438
self.reset_smart_call_log()
1439
out, err = self.run_bzr(['info', self.get_url('branch')])
1440
# This figure represent the amount of work to perform this use case. It
1441
# is entirely ok to reduce this number if a test fails due to rpc_count
1442
# being too low. If rpc_count increases, more network roundtrips have
1443
# become necessary for this use case. Please do not adjust this number
1444
# upwards without agreement from bzr's network support maintainers.
1445
self.assertLength(12, self.hpss_calls)
1447
def test_verbose_branch_info(self):
1448
self.setup_smart_server_with_call_log()
1449
t = self.make_branch_and_tree('branch')
1450
self.build_tree_contents([('branch/foo', 'thecontents')])
1453
self.reset_smart_call_log()
1454
out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
1455
# This figure represent the amount of work to perform this use case. It
1456
# is entirely ok to reduce this number if a test fails due to rpc_count
1457
# being too low. If rpc_count increases, more network roundtrips have
1458
# become necessary for this use case. Please do not adjust this number
1459
# upwards without agreement from bzr's network support maintainers.
1460
self.assertLength(16, self.hpss_calls)