13
13
# You should have received a copy of the GNU General Public License
14
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
18
"""Tests for the info command of bzr."""
23
23
from bzrlib import (
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"
27
from bzrlib.osutils import format_date
28
from bzrlib.tests import TestSkipped
29
from bzrlib.tests.blackbox import ExternalBase
32
class TestInfo(ExternalBase):
44
34
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)
35
if sys.platform == "win32":
36
location = "C:/i/do/not/exist/"
38
location = "/i/do/not/exist/"
39
out, err = self.runbzr('info '+location, retcode=3)
48
40
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, '')
41
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
72
43
def test_info_standalone(self):
73
44
transport = self.get_transport()
75
46
# Create initial standalone branch
76
tree1 = self.make_branch_and_tree('standalone', 'knit')
47
tree1 = self.make_branch_and_tree('standalone', 'weave')
77
48
self.build_tree(['standalone/a'])
79
50
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
51
out, err = self.runbzr('info standalone')
57
control: All-in-one format 6
58
working tree: Working tree format 2
59
branch: Branch format 4
60
repository: Weave repository format 6
70
0 versioned subdirectories
78
""" % branch1.bzrdir.root_transport.base, out)
150
79
self.assertEqual('', err)
151
80
tree1.commit('commit one')
152
rev = branch1.repository.get_revision(branch1.last_revision())
153
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
81
rev = branch1.repository.get_revision(branch1.revision_history()[0])
82
datestring_first = format_date(rev.timestamp, rev.timezone)
155
84
# Branch standalone with push location
156
85
branch2 = branch1.bzrdir.sprout('branch').open_branch()
157
86
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
87
out, err = self.runbzr('info branch --verbose')
182
control: Meta directory format 1
183
working tree: Working tree format 3
184
branch: Branch format 5
185
repository: Knit repository format 1
97
control: All-in-one format 6
98
working tree: Working tree format 2
99
branch: Branch format 4
100
repository: Weave repository format 6
187
102
In the working tree:
251
""" % (bound_tree._format.get_format_description(),
175
""" % (branch3.bzrdir.root_transport.base,
176
branch1.bzrdir.root_transport.base,
177
branch1.bzrdir.root_transport.base,
178
bound_tree._format.get_format_description(),
252
179
branch3._format.get_format_description(),
253
180
branch3.repository._format.get_format_description(),
254
181
datestring_first, datestring_first,
182
# poking at _revision_store isn't all that clean, but neither is
183
# having the ui test dependent on the exact overhead of a given store.
184
branch3.repository._revision_store.total_size(
185
branch3.repository.get_transaction())[1] / 1024,
256
187
self.assertEqual('', err)
258
189
# Checkout standalone (same as above, but does not have parent set)
259
branch4 = controldir.ControlDir.create_branch_convenience('checkout',
190
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
260
191
format=knit1_format)
261
192
branch4.bind(branch1)
262
193
branch4.bzrdir.open_workingtree().update()
263
out, err = self.run_bzr('info checkout --verbose')
194
out, err = self.runbzr('info checkout --verbose')
264
195
self.assertEqualDiff(
265
"""Checkout (format: knit)
267
checkout root: checkout
268
checkout of branch: standalone
198
checkout of branch: %s
271
201
control: Meta directory format 1
289
220
first revision: %s
290
221
latest revision: %s
294
""" % (branch4.repository._format.get_format_description(),
226
""" % (branch4.bzrdir.root_transport.base,
227
branch1.bzrdir.root_transport.base,
228
branch4.repository._format.get_format_description(),
295
229
datestring_first, datestring_first,
230
# poking at _revision_store isn't all that clean, but neither is
231
# having the ui test dependent on the exact overhead of a given store.
232
branch4.repository._revision_store.total_size(
233
branch4.repository.get_transaction())[1] / 1024,
297
235
self.assertEqual('', err)
299
237
# Lightweight checkout (same as above, different branch and repository)
300
238
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
301
239
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"
240
out, err = self.runbzr('info lightcheckout')
307
241
self.assertEqualDiff(
308
"""Lightweight checkout (format: %s)
310
light checkout root: lightcheckout
311
checkout of branch: standalone
243
light checkout root: %s
244
checkout of branch: %s
314
247
control: Meta directory format 1
315
working tree: Working tree format 3
316
branch: Branch format 5
317
repository: Knit repository format 1
248
working tree: Working tree format 4
249
branch: Branch format 4
250
repository: Weave repository format 6
319
252
In the working tree:
337
""" % (format_description, datestring_first, datestring_first,), out)
271
""" % (tree5.bzrdir.root_transport.base,
272
branch1.bzrdir.root_transport.base,
273
datestring_first, datestring_first,
338
275
self.assertEqual('', err)
340
277
# Update initial standalone branch
341
278
self.build_tree(['standalone/b'])
343
280
tree1.commit('commit two')
344
rev = branch1.repository.get_revision(branch1.last_revision())
345
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
281
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
282
datestring_last = format_date(rev.timestamp, rev.timezone)
347
284
# Out of date branched standalone branch will not be detected
348
out, err = self.run_bzr('info -v branch')
285
out, err = self.runbzr('info branch')
349
286
self.assertEqualDiff(
350
"""Standalone tree (format: knit)
354
290
Related branches:
355
push branch: standalone
356
parent branch: standalone
292
publish to branch: %s
359
control: Meta directory format 1
360
working tree: Working tree format 3
361
branch: Branch format 5
362
repository: Knit repository format 1
295
control: All-in-one format 6
296
working tree: Working tree format 2
297
branch: Branch format 4
298
repository: Weave repository format 6
364
300
In the working tree:
423
""" % (branch3.repository._format.get_format_description(),
363
""" % (branch3.bzrdir.root_transport.base,
364
branch1.bzrdir.root_transport.base,
365
branch1.bzrdir.root_transport.base,
366
branch3.repository._format.get_format_description(),
424
367
datestring_first, datestring_first,
368
# poking at _revision_store isn't all that clean, but neither is
369
# having the ui test dependent on the exact overhead of a given store.
370
branch3.repository._revision_store.total_size(
371
branch3.repository.get_transaction())[1] / 1024,
426
373
self.assertEqual('', err)
428
375
# Out of date checkout
429
out, err = self.run_bzr('info -v checkout')
376
out, err = self.runbzr('info checkout')
430
377
self.assertEqualDiff(
431
"""Checkout (format: knit)
433
checkout root: checkout
434
checkout of branch: standalone
380
checkout of branch: %s
437
383
control: Meta directory format 1
462
""" % (branch4.repository._format.get_format_description(),
409
""" % (branch4.bzrdir.root_transport.base,
410
branch1.bzrdir.root_transport.base,
411
branch4.repository._format.get_format_description(),
463
412
datestring_first, datestring_first,
413
# poking at _revision_store isn't all that clean, but neither is
414
# having the ui test dependent on the exact overhead of a given store.
415
branch4.repository._revision_store.total_size(
416
branch4.repository.get_transaction())[1] / 1024,
465
418
self.assertEqual('', err)
467
420
# Out of date lightweight checkout
468
out, err = self.run_bzr('info lightcheckout --verbose')
421
out, err = self.runbzr('info lightcheckout --verbose')
469
422
self.assertEqualDiff(
470
"""Lightweight checkout (format: %s)
472
light checkout root: lightcheckout
473
checkout of branch: standalone
424
light checkout root: %s
425
checkout of branch: %s
476
428
control: Meta directory format 1
477
working tree: Working tree format 3
478
branch: Branch format 5
479
repository: Knit repository format 1
429
working tree: Working tree format 4
430
branch: Branch format 4
431
repository: Weave repository format 6
481
433
Working tree is out of date: missing 1 revision.
550
""" % ('repo', format.repository_format.get_format_description(),
507
""" % (repo.bzrdir.root_transport.base,
508
format.repository_format.get_format_description(),
552
510
self.assertEqual('', err)
554
512
# Create branch inside shared repository
555
513
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')
514
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
516
out, err = self.runbzr('info repo/branch')
559
517
self.assertEqualDiff(
560
"""Repository branch (format: dirstate or knit)
562
shared repository: repo
563
repository branch: repo/branch
519
shared repository: %s
520
repository branch: branch
566
523
control: Meta directory format 1
627
586
first revision: %s
628
587
latest revision: %s
632
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
592
""" % (tree2.bzrdir.root_transport.base,
593
repo.bzrdir.root_transport.base,
594
format.get_branch_format().get_format_description(),
633
595
format.repository_format.get_format_description(),
634
596
datestring_first, datestring_first,
597
# poking at _revision_store isn't all that clean, but neither is
598
# having the ui test dependent on the exact overhead of a given store.
599
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
636
601
self.assertEqual('', err)
638
603
# Out of date checkout
639
out, err = self.run_bzr('info -v tree/checkout')
604
out, err = self.runbzr('info tree/checkout')
640
605
self.assertEqualDiff(
641
"""Checkout (format: unnamed)
643
checkout root: tree/checkout
644
checkout of branch: repo/branch
608
checkout of branch: %s
647
611
control: Meta directory format 1
648
working tree: Working tree format 6
612
working tree: Working tree format 4
704
671
first revision: %s
705
672
latest revision: %s
709
""" % (format.get_branch_format().get_format_description(),
677
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
678
format.get_branch_format().get_format_description(),
710
679
format.repository_format.get_format_description(),
711
680
datestring_first, datestring_first,
681
# poking at _revision_store isn't all that clean, but neither is
682
# having the ui test dependent on the exact overhead of a given store.
683
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
713
685
self.assertEqual('', err)
714
686
tree3.commit('commit two')
716
688
# 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')
689
rev = repo.get_revision(branch1.revision_history()[-1])
690
datestring_last = format_date(rev.timestamp, rev.timezone)
691
out, err = self.runbzr('info tree/lightcheckout --verbose')
720
692
self.assertEqualDiff(
721
"""Lightweight checkout (format: %s)
723
light checkout root: tree/lightcheckout
724
checkout of branch: repo/branch
725
shared repository: repo
694
light checkout root: %s
695
shared repository: %s
696
repository branch: branch
728
699
control: Meta directory format 1
729
working tree: Working tree format 6
700
working tree: Working tree format 4
748
720
first revision: %s
749
721
latest revision: %s
753
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
726
""" % (tree2.bzrdir.root_transport.base,
727
repo.bzrdir.root_transport.base,
728
format.get_branch_format().get_format_description(),
754
729
format.repository_format.get_format_description(),
755
730
datestring_first, datestring_last,
731
# poking at _revision_store isn't all that clean, but neither is
732
# having the ui test dependent on the exact overhead of a given store.
733
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
757
735
self.assertEqual('', err)
759
737
# Show info about shared branch
760
out, err = self.run_bzr('info repo/branch --verbose')
738
out, err = self.runbzr('info repo/branch --verbose')
761
739
self.assertEqualDiff(
762
"""Repository branch (format: dirstate or knit)
764
shared repository: repo
765
repository branch: repo/branch
741
shared repository: %s
742
repository branch: branch
768
745
control: Meta directory format 1
775
753
first revision: %s
776
754
latest revision: %s
780
""" % (format.get_branch_format().get_format_description(),
759
""" % (repo.bzrdir.root_transport.base,
760
format.get_branch_format().get_format_description(),
781
761
format.repository_format.get_format_description(),
782
762
datestring_first, datestring_last,
763
# poking at _revision_store isn't all that clean, but neither is
764
# having the ui test dependent on the exact overhead of a given store.
765
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
784
767
self.assertEqual('', err)
786
769
# Show info about repository with revisions
787
out, err = self.run_bzr('info -v repo')
770
out, err = self.runbzr('info repo')
788
771
self.assertEqualDiff(
789
"""Shared repository (format: dirstate or dirstate-tags or knit)
791
shared repository: repo
773
shared repository: %s
794
776
control: Meta directory format 1
906
""" % (format.get_branch_format().get_format_description(),
896
""" % (repo.bzrdir.root_transport.base,
897
format.get_branch_format().get_format_description(),
907
898
format.repository_format.get_format_description(),
908
899
datestring_first, datestring_first,
900
# poking at _revision_store isn't all that clean, but neither is
901
# having the ui test dependent on the exact overhead of a given store.
902
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
910
904
self.assertEqual('', err)
912
906
# Out of date second branch
913
out, err = self.run_bzr('info repo/branch2 --verbose')
907
out, err = self.runbzr('info repo/branch2 --verbose')
914
908
self.assertEqualDiff(
915
"""Repository tree (format: knit)
917
shared repository: repo
918
repository branch: repo/branch2
910
shared repository: %s
911
repository checkout: branch2
920
913
Related branches:
921
parent branch: repo/branch1
924
917
control: Meta directory format 1
944
""" % (format.get_branch_format().get_format_description(),
939
""" % (repo.bzrdir.root_transport.base,
940
branch1.bzrdir.root_transport.base,
941
format.get_branch_format().get_format_description(),
945
942
format.repository_format.get_format_description(),
943
# poking at _revision_store isn't all that clean, but neither is
944
# having the ui test dependent on the exact overhead of a given store.
945
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
947
947
self.assertEqual('', err)
949
949
# Update second branch
950
950
tree2 = branch2.bzrdir.open_workingtree()
951
951
tree2.pull(branch1)
952
out, err = self.run_bzr('info -v repo/branch2')
952
out, err = self.runbzr('info repo/branch2')
953
953
self.assertEqualDiff(
954
"""Repository tree (format: knit)
956
shared repository: repo
957
repository branch: repo/branch2
955
shared repository: %s
956
repository checkout: branch2
959
958
Related branches:
960
parent branch: repo/branch1
963
962
control: Meta directory format 1
986
""" % (format.get_branch_format().get_format_description(),
986
""" % (repo.bzrdir.root_transport.base,
987
branch1.bzrdir.root_transport.base,
988
format.get_branch_format().get_format_description(),
987
989
format.repository_format.get_format_description(),
988
990
datestring_first, datestring_first,
991
# poking at _revision_store isn't all that clean, but neither is
992
# having the ui test dependent on the exact overhead of a given store.
993
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
990
995
self.assertEqual('', err)
992
997
# Show info about repository with revisions
993
out, err = self.run_bzr('info -v repo')
998
out, err = self.runbzr('info repo')
994
999
self.assertEqualDiff(
995
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
997
shared repository: repo
1001
shared repository: %s
1000
1004
control: Meta directory format 1
1069
""" % (format.get_branch_format().get_format_description(),
1079
""" % (repo.bzrdir.root_transport.base,
1080
format.get_branch_format().get_format_description(),
1070
1081
format.repository_format.get_format_description(),
1072
1083
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,
1085
def assertCheckoutStatusOutput(self,
1101
1086
command_string, lco_tree, shared_repo=None,
1102
1087
repo_branch=None,
1103
1088
tree_locked=False,
1104
1089
branch_locked=False, repo_locked=False,
1106
light_checkout=True,
1107
checkout_root=None):
1108
"""Check the output of info in a checkout.
1091
light_checkout=True):
1092
"""Check the output of info in a light checkout tree.
1110
1094
This is not quite a mirror of the info code: rather than using the
1111
1095
tree being examined to predict output, it uses a bunch of flags which
1112
1096
allow us, the test writers, to document what *should* be present in
1113
1097
the output. Removing this separation would remove the value of the
1116
1100
:param path: the path to the light checkout.
1117
1101
:param lco_tree: the tree object for the light checkout.
1118
1102
:param shared_repo: A shared repository is in use, expect that in
1122
1106
:param tree_locked: If true, expect the tree to be locked.
1123
1107
:param branch_locked: If true, expect the branch to be locked.
1124
1108
: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
1109
:param verbose: If true, expect verbose output
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).
1111
if tree_locked and sys.platform == 'win32':
1112
# We expect this to fail because of locking errors. (A write-locked
1113
# file cannot be read-locked in the same process).
1142
1114
# 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()
1115
args = command_string.split(' ')
1116
self.run_bzr_error([], 'info', *args)
1118
out, err = self.runbzr('info %s' % command_string)
1158
1119
if repo_locked or branch_locked or tree_locked:
1159
1120
def locked_message(a_bool):
1172
1133
locked_message(repo_locked)))
1174
1135
expected_lock_output = ''
1177
1136
if light_checkout:
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)))
1137
tree_data = (" light checkout root: %s" %
1138
lco_tree.bzrdir.root_transport.base)
1140
tree_data = (" checkout root: %s" %
1141
lco_tree.bzrdir.root_transport.base)
1184
1142
if shared_repo is not None:
1185
1143
branch_data = (
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)))
1144
" shared repository: %s\n"
1145
" repository branch: branch\n" %
1146
shared_repo.bzrdir.root_transport.base)
1190
1147
elif repo_branch is not None:
1191
1148
branch_data = (
1192
"%s checkout of branch: %s\n" %
1194
friendly_location(repo_branch.bzrdir.root_transport.base)))
1149
" checkout of branch: %s\n" %
1150
repo_branch.bzrdir.root_transport.base)
1196
branch_data = (" checkout of branch: %s\n" %
1152
branch_data = (" checkout of branch: %s\n" %
1197
1153
lco_tree.branch.bzrdir.root_transport.base)
1200
1156
verbose_info = ' 0 committers\n'
1202
1158
verbose_info = ''
1204
1160
self.assertEqualDiff(
1209
1165
control: Meta directory format 1
1210
1166
working tree: %s
1242
1197
transport = self.get_transport()
1243
1198
# Create shared repository with a branch
1244
1199
repo = self.make_repository('repo', shared=True,
1245
format=bzrdir.BzrDirMetaFormat1())
1200
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1246
1201
repo.set_make_working_trees(False)
1247
1202
repo.bzrdir.root_transport.mkdir('branch')
1248
repo_branch = controldir.ControlDir.create_branch_convenience(
1249
'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1203
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1204
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1250
1205
# Do a heavy checkout
1251
1206
transport.mkdir('tree')
1252
1207
transport.mkdir('tree/checkout')
1253
co_branch = controldir.ControlDir.create_branch_convenience(
1254
'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1208
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1209
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1255
1210
co_branch.bind(repo_branch)
1256
1211
# Do a light checkout of the heavy one
1257
1212
transport.mkdir('tree/lightcheckout')
1258
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1259
branch.BranchReferenceFormat().initialize(lco_dir,
1260
target_branch=co_branch)
1213
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1214
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1261
1215
lco_dir.create_workingtree()
1262
1216
lco_tree = lco_dir.open_workingtree()
1268
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1269
repo_branch=repo_branch,
1270
verbose=True, light_checkout=True)
1222
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1272
1224
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)
1226
self.assertCheckoutStatusOutput('tree/lightcheckout',
1278
1230
lco_tree.branch.repository.unlock()
1280
1232
lco_tree.branch.lock_write()
1282
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1234
self.assertCheckoutStatusOutput('tree/lightcheckout',
1284
1236
branch_locked=True,
1286
repo_branch=repo_branch,
1289
1239
lco_tree.branch.unlock()
1291
1241
lco_tree.lock_write()
1293
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1294
lco_tree, repo_branch=repo_branch,
1243
self.assertCheckoutStatusOutput('tree/lightcheckout',
1295
1245
tree_locked=True,
1296
1246
branch_locked=True,
1300
1249
lco_tree.unlock()
1302
1251
lco_tree.lock_write()
1303
1252
lco_tree.branch.repository.unlock()
1305
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1306
lco_tree, repo_branch=repo_branch,
1254
self.assertCheckoutStatusOutput('tree/lightcheckout',
1307
1256
tree_locked=True,
1311
1259
lco_tree.branch.repository.lock_write()
1312
1260
lco_tree.unlock()
1351
1296
self.knownFailure('Win32 cannot run "bzr info"'
1352
1297
' 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.assertThat(self.hpss_calls, ContainsNoVfsCalls)
1449
def test_verbose_branch_info(self):
1450
self.setup_smart_server_with_call_log()
1451
t = self.make_branch_and_tree('branch')
1452
self.build_tree_contents([('branch/foo', 'thecontents')])
1455
self.reset_smart_call_log()
1456
out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
1457
# This figure represent the amount of work to perform this use case. It
1458
# is entirely ok to reduce this number if a test fails due to rpc_count
1459
# being too low. If rpc_count increases, more network roundtrips have
1460
# become necessary for this use case. Please do not adjust this number
1461
# upwards without agreement from bzr's network support maintainers.
1462
self.assertLength(16, self.hpss_calls)
1463
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
1299
def test_info_locking_oslocks(self):
1300
if sys.platform == "win32":
1301
raise TestSkipped("don't use oslocks on win32 in unix manner")
1303
tree = self.make_branch_and_tree('branch',
1304
format=bzrlib.bzrdir.BzrDirFormat6())
1306
# Test all permutations of locking the working tree, branch and repository
1307
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1308
# implemented by raising NotImplementedError and get_physical_lock_status()
1309
# always returns false. This makes bzr info hide the lock status. (Olaf)
1313
out, err = self.runbzr('info branch')
1314
self.assertEqualDiff(
1319
control: All-in-one format 6
1320
working tree: Working tree format 2
1321
branch: Branch format 4
1324
In the working tree:
1332
0 versioned subdirectories
1340
""" % (tree.bzrdir.root_transport.base,
1341
tree.branch.repository._format.get_format_description(),
1343
self.assertEqual('', err)
1346
out, err = self.runbzr('info branch')
1347
self.assertEqualDiff(
1352
control: All-in-one format 6
1353
working tree: Working tree format 2
1354
branch: Branch format 4
1357
In the working tree:
1365
0 versioned subdirectories
1373
""" % (tree.bzrdir.root_transport.base,
1374
tree.branch.repository._format.get_format_description(),
1376
self.assertEqual('', err)