1
# Copyright (C) 2006, 2007 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
"""Tests for the info command of bzr."""
32
from bzrlib.osutils import format_date
33
from bzrlib.tests import TestSkipped
34
from bzrlib.tests.blackbox import ExternalBase
37
class TestInfo(ExternalBase):
39
def test_info_non_existing(self):
40
if sys.platform == "win32":
41
location = "C:/i/do/not/exist/"
43
location = "/i/do/not/exist/"
44
out, err = self.run_bzr('info '+location, retcode=3)
45
self.assertEqual(out, '')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
48
def test_info_standalone(self):
49
transport = self.get_transport()
51
# Create initial standalone branch
52
tree1 = self.make_branch_and_tree('standalone', 'weave')
53
self.build_tree(['standalone/a'])
55
branch1 = tree1.branch
57
out, err = self.run_bzr('info standalone')
59
"""Standalone tree (format: weave)
61
branch root: standalone
63
self.assertEqual('', err)
65
out, err = self.run_bzr('info standalone -v')
67
"""Standalone tree (format: weave)
69
branch root: standalone
72
control: All-in-one format 6
73
working tree: Working tree format 2
74
branch: Branch format 4
75
repository: Weave repository format 6
85
0 versioned subdirectories
95
self.assertEqual('', err)
96
tree1.commit('commit one')
97
rev = branch1.repository.get_revision(branch1.revision_history()[0])
98
datestring_first = format_date(rev.timestamp, rev.timezone)
100
# Branch standalone with push location
101
branch2 = branch1.bzrdir.sprout('branch').open_branch()
102
branch2.set_push_location(branch1.bzrdir.root_transport.base)
104
out, err = self.run_bzr('info branch')
105
self.assertEqualDiff(
106
"""Standalone tree (format: weave)
111
push branch: standalone
112
parent branch: standalone
114
self.assertEqual('', err)
116
out, err = self.run_bzr('info branch --verbose')
117
self.assertEqualDiff(
118
"""Standalone tree (format: weave)
123
push branch: standalone
124
parent branch: standalone
127
control: All-in-one format 6
128
working tree: Working tree format 2
129
branch: Branch format 4
130
repository: Weave repository format 6
140
0 versioned subdirectories
152
""" % (datestring_first, datestring_first,
153
# poking at _revision_store isn't all that clean, but neither is
154
# having the ui test dependent on the exact overhead of a given store.
155
branch2.repository._revision_store.total_size(
156
branch2.repository.get_transaction())[1] / 1024,
158
self.assertEqual('', err)
160
# Branch and bind to standalone, needs upgrade to metadir
161
# (creates backup as unknown)
162
branch1.bzrdir.sprout('bound')
163
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
164
bzrlib.upgrade.upgrade('bound', knit1_format)
165
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
166
branch3.bind(branch1)
167
bound_tree = branch3.bzrdir.open_workingtree()
168
out, err = self.run_bzr('info -v bound')
169
self.assertEqualDiff(
170
"""Checkout (format: knit)
173
checkout of branch: standalone
176
parent branch: standalone
179
control: Meta directory format 1
192
0 versioned subdirectories
204
""" % (bound_tree._format.get_format_description(),
205
branch3._format.get_format_description(),
206
branch3.repository._format.get_format_description(),
207
datestring_first, datestring_first,
208
# poking at _revision_store isn't all that clean, but neither is
209
# having the ui test dependent on the exact overhead of a given store.
210
branch3.repository._revision_store.total_size(
211
branch3.repository.get_transaction())[1] / 1024,
213
self.assertEqual('', err)
215
# Checkout standalone (same as above, but does not have parent set)
216
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
218
branch4.bind(branch1)
219
branch4.bzrdir.open_workingtree().update()
220
out, err = self.run_bzr('info checkout --verbose')
221
self.assertEqualDiff(
222
"""Checkout (format: knit)
224
checkout root: checkout
225
checkout of branch: standalone
228
control: Meta directory format 1
229
working tree: Working tree format 3
230
branch: Branch format 5
241
0 versioned subdirectories
253
""" % (branch4.repository._format.get_format_description(),
254
datestring_first, datestring_first,
255
# poking at _revision_store isn't all that clean, but neither is
256
# having the ui test dependent on the exact overhead of a given store.
257
branch4.repository._revision_store.total_size(
258
branch4.repository.get_transaction())[1] / 1024,
260
self.assertEqual('', err)
262
# Lightweight checkout (same as above, different branch and repository)
263
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
264
branch5 = tree5.branch
265
out, err = self.run_bzr('info -v lightcheckout')
266
self.assertEqualDiff(
267
"""Lightweight checkout (format: dirstate or dirstate-tags or knitpack-experimental)
269
light checkout root: lightcheckout
270
checkout of branch: standalone
273
control: Meta directory format 1
274
working tree: Working tree format 4
275
branch: Branch format 4
276
repository: Weave repository format 6
286
0 versioned subdirectories
298
""" % (datestring_first, datestring_first,), out)
299
self.assertEqual('', err)
301
# Update initial standalone branch
302
self.build_tree(['standalone/b'])
304
tree1.commit('commit two')
305
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
306
datestring_last = format_date(rev.timestamp, rev.timezone)
308
# Out of date branched standalone branch will not be detected
309
out, err = self.run_bzr('info -v branch')
310
self.assertEqualDiff(
311
"""Standalone tree (format: weave)
316
push branch: standalone
317
parent branch: standalone
320
control: All-in-one format 6
321
working tree: Working tree format 2
322
branch: Branch format 4
323
repository: Weave repository format 6
333
0 versioned subdirectories
345
""" % (datestring_first, datestring_first,
347
self.assertEqual('', err)
349
# Out of date bound branch
350
out, err = self.run_bzr('info -v bound')
351
self.assertEqualDiff(
352
"""Checkout (format: knit)
355
checkout of branch: standalone
358
parent branch: standalone
361
control: Meta directory format 1
362
working tree: Working tree format 3
363
branch: Branch format 5
366
Branch is out of date: missing 1 revision.
376
0 versioned subdirectories
388
""" % (branch3.repository._format.get_format_description(),
389
datestring_first, datestring_first,
390
# poking at _revision_store isn't all that clean, but neither is
391
# having the ui test dependent on the exact overhead of a given store.
392
branch3.repository._revision_store.total_size(
393
branch3.repository.get_transaction())[1] / 1024,
395
self.assertEqual('', err)
397
# Out of date checkout
398
out, err = self.run_bzr('info -v checkout')
399
self.assertEqualDiff(
400
"""Checkout (format: knit)
402
checkout root: checkout
403
checkout of branch: standalone
406
control: Meta directory format 1
407
working tree: Working tree format 3
408
branch: Branch format 5
411
Branch is out of date: missing 1 revision.
421
0 versioned subdirectories
433
""" % (branch4.repository._format.get_format_description(),
434
datestring_first, datestring_first,
435
# poking at _revision_store isn't all that clean, but neither is
436
# having the ui test dependent on the exact overhead of a given store.
437
branch4.repository._revision_store.total_size(
438
branch4.repository.get_transaction())[1] / 1024,
440
self.assertEqual('', err)
442
# Out of date lightweight checkout
443
out, err = self.run_bzr('info lightcheckout --verbose')
444
self.assertEqualDiff(
445
"""Lightweight checkout (format: dirstate or dirstate-tags or knitpack-experimental)
447
light checkout root: lightcheckout
448
checkout of branch: standalone
451
control: Meta directory format 1
452
working tree: Working tree format 4
453
branch: Branch format 4
454
repository: Weave repository format 6
456
Working tree is out of date: missing 1 revision.
466
0 versioned subdirectories
478
""" % (datestring_first, datestring_last,), out)
479
self.assertEqual('', err)
481
def test_info_standalone_no_tree(self):
482
# create standalone branch without a working tree
483
format = bzrdir.format_registry.make_bzrdir('default')
484
branch = self.make_branch('branch')
485
repo = branch.repository
486
out, err = self.run_bzr('info branch -v')
487
self.assertEqualDiff(
488
"""Standalone branch (format: %s)
493
control: Meta directory format 1
504
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
505
format.get_branch_format().get_format_description(),
506
format.repository_format.get_format_description(),
508
self.assertEqual('', err)
510
def test_info_shared_repository(self):
511
format = bzrdir.format_registry.make_bzrdir('knit')
512
transport = self.get_transport()
514
# Create shared repository
515
repo = self.make_repository('repo', shared=True, format=format)
516
repo.set_make_working_trees(False)
517
out, err = self.run_bzr('info -v repo')
518
self.assertEqualDiff(
519
"""Shared repository (format: dirstate or dirstate-tags or knit)
521
shared repository: %s
524
control: Meta directory format 1
530
""" % ('repo', format.repository_format.get_format_description(),
532
self.assertEqual('', err)
534
# Create branch inside shared repository
535
repo.bzrdir.root_transport.mkdir('branch')
536
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
538
out, err = self.run_bzr('info -v repo/branch')
539
self.assertEqualDiff(
540
"""Repository branch (format: dirstate or knit)
542
shared repository: repo
543
repository branch: repo/branch
546
control: Meta directory format 1
557
""" % (format.get_branch_format().get_format_description(),
558
format.repository_format.get_format_description(),
560
self.assertEqual('', err)
562
# Create lightweight checkout
563
transport.mkdir('tree')
564
transport.mkdir('tree/lightcheckout')
565
tree2 = branch1.create_checkout('tree/lightcheckout',
567
branch2 = tree2.branch
568
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
569
shared_repo=repo, repo_branch=branch1, verbose=True)
571
# Create normal checkout
572
tree3 = branch1.create_checkout('tree/checkout')
573
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
575
light_checkout=False, repo_branch=branch1)
576
# Update lightweight checkout
577
self.build_tree(['tree/lightcheckout/a'])
579
tree2.commit('commit one')
580
rev = repo.get_revision(branch2.revision_history()[0])
581
datestring_first = format_date(rev.timestamp, rev.timezone)
582
out, err = self.run_bzr('info tree/lightcheckout --verbose')
583
self.assertEqualDiff(
584
"""Lightweight checkout (format: dirstate or dirstate-tags or knitpack-experimental)
586
light checkout root: tree/lightcheckout
587
checkout of branch: repo/branch
588
shared repository: repo
591
control: Meta directory format 1
592
working tree: Working tree format 4
604
0 versioned subdirectories
616
""" % (format.get_branch_format().get_format_description(),
617
format.repository_format.get_format_description(),
618
datestring_first, datestring_first,
619
# poking at _revision_store isn't all that clean, but neither is
620
# having the ui test dependent on the exact overhead of a given store.
621
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
623
self.assertEqual('', err)
625
# Out of date checkout
626
out, err = self.run_bzr('info -v tree/checkout')
627
self.assertEqualDiff(
628
"""Checkout (format: dirstate)
630
checkout root: tree/checkout
631
checkout of branch: repo/branch
634
control: Meta directory format 1
635
working tree: Working tree format 4
639
Branch is out of date: missing 1 revision.
649
0 versioned subdirectories
658
""" % (format.get_branch_format().get_format_description(),
659
format.repository_format.get_format_description(),
661
self.assertEqual('', err)
665
self.build_tree(['tree/checkout/b'])
667
out, err = self.run_bzr('info tree/checkout --verbose')
668
self.assertEqualDiff(
669
"""Checkout (format: dirstate)
671
checkout root: tree/checkout
672
checkout of branch: repo/branch
675
control: Meta directory format 1
676
working tree: Working tree format 4
688
0 versioned subdirectories
700
""" % (format.get_branch_format().get_format_description(),
701
format.repository_format.get_format_description(),
702
datestring_first, datestring_first,
703
# poking at _revision_store isn't all that clean, but neither is
704
# having the ui test dependent on the exact overhead of a given store.
705
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
707
self.assertEqual('', err)
708
tree3.commit('commit two')
710
# Out of date lightweight checkout
711
rev = repo.get_revision(branch1.revision_history()[-1])
712
datestring_last = format_date(rev.timestamp, rev.timezone)
713
out, err = self.run_bzr('info tree/lightcheckout --verbose')
714
self.assertEqualDiff(
715
"""Lightweight checkout (format: dirstate or dirstate-tags or knitpack-experimental)
717
light checkout root: tree/lightcheckout
718
checkout of branch: repo/branch
719
shared repository: repo
722
control: Meta directory format 1
723
working tree: Working tree format 4
727
Working tree is out of date: missing 1 revision.
737
0 versioned subdirectories
749
""" % (format.get_branch_format().get_format_description(),
750
format.repository_format.get_format_description(),
751
datestring_first, datestring_last,
752
# poking at _revision_store isn't all that clean, but neither is
753
# having the ui test dependent on the exact overhead of a given store.
754
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
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
781
""" % (format.get_branch_format().get_format_description(),
782
format.repository_format.get_format_description(),
783
datestring_first, datestring_last,
784
# poking at _revision_store isn't all that clean, but neither is
785
# having the ui test dependent on the exact overhead of a given store.
786
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
788
self.assertEqual('', err)
790
# Show info about repository with revisions
791
out, err = self.run_bzr('info -v repo')
792
self.assertEqualDiff(
793
"""Shared repository (format: dirstate or dirstate-tags or knit)
795
shared repository: repo
798
control: Meta directory format 1
804
""" % (format.repository_format.get_format_description(),
805
# poking at _revision_store isn't all that clean, but neither is
806
# having the ui test dependent on the exact overhead of a given store.
807
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
809
self.assertEqual('', err)
811
def test_info_shared_repository_with_trees(self):
812
format = bzrdir.format_registry.make_bzrdir('knit')
813
transport = self.get_transport()
815
# Create shared repository with working trees
816
repo = self.make_repository('repo', shared=True, format=format)
817
repo.set_make_working_trees(True)
818
out, err = self.run_bzr('info -v repo')
819
self.assertEqualDiff(
820
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
822
shared repository: repo
825
control: Meta directory format 1
828
Create working tree for new branches inside the repository.
833
""" % (format.repository_format.get_format_description(),
835
self.assertEqual('', err)
837
# Create two branches
838
repo.bzrdir.root_transport.mkdir('branch1')
839
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
841
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
844
out, err = self.run_bzr('info repo/branch1 --verbose')
845
self.assertEqualDiff(
846
"""Repository tree (format: knit)
848
shared repository: repo
849
repository branch: repo/branch1
852
control: Meta directory format 1
853
working tree: Working tree format 3
865
0 versioned subdirectories
874
""" % (format.get_branch_format().get_format_description(),
875
format.repository_format.get_format_description(),
877
self.assertEqual('', err)
879
# Update first branch
880
self.build_tree(['repo/branch1/a'])
881
tree1 = branch1.bzrdir.open_workingtree()
883
tree1.commit('commit one')
884
rev = repo.get_revision(branch1.revision_history()[0])
885
datestring_first = format_date(rev.timestamp, rev.timezone)
886
out, err = self.run_bzr('info -v repo/branch1')
887
self.assertEqualDiff(
888
"""Repository tree (format: knit)
890
shared repository: repo
891
repository branch: repo/branch1
894
control: Meta directory format 1
895
working tree: Working tree format 3
907
0 versioned subdirectories
919
""" % (format.get_branch_format().get_format_description(),
920
format.repository_format.get_format_description(),
921
datestring_first, datestring_first,
922
# poking at _revision_store isn't all that clean, but neither is
923
# having the ui test dependent on the exact overhead of a given store.
924
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
926
self.assertEqual('', err)
928
# Out of date second branch
929
out, err = self.run_bzr('info repo/branch2 --verbose')
930
self.assertEqualDiff(
931
"""Repository tree (format: knit)
933
shared repository: repo
934
repository branch: repo/branch2
937
parent branch: repo/branch1
940
control: Meta directory format 1
941
working tree: Working tree format 3
953
0 versioned subdirectories
962
""" % (format.get_branch_format().get_format_description(),
963
format.repository_format.get_format_description(),
964
# poking at _revision_store isn't all that clean, but neither is
965
# having the ui test dependent on the exact overhead of a given store.
966
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
968
self.assertEqual('', err)
970
# Update second branch
971
tree2 = branch2.bzrdir.open_workingtree()
973
out, err = self.run_bzr('info -v repo/branch2')
974
self.assertEqualDiff(
975
"""Repository tree (format: knit)
977
shared repository: repo
978
repository branch: repo/branch2
981
parent branch: repo/branch1
984
control: Meta directory format 1
985
working tree: Working tree format 3
997
0 versioned subdirectories
1009
""" % (format.get_branch_format().get_format_description(),
1010
format.repository_format.get_format_description(),
1011
datestring_first, datestring_first,
1012
# poking at _revision_store isn't all that clean, but neither is
1013
# having the ui test dependent on the exact overhead of a given store.
1014
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1016
self.assertEqual('', err)
1018
# Show info about repository with revisions
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.
1034
""" % (format.repository_format.get_format_description(),
1035
# poking at _revision_store isn't all that clean, but neither is
1036
# having the ui test dependent on the exact overhead of a given store.
1037
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1040
self.assertEqual('', err)
1042
def test_info_shared_repository_with_tree_in_root(self):
1043
format = bzrdir.format_registry.make_bzrdir('knit')
1044
transport = self.get_transport()
1046
# Create shared repository with working trees
1047
repo = self.make_repository('repo', shared=True, format=format)
1048
repo.set_make_working_trees(True)
1049
out, err = self.run_bzr('info -v repo')
1050
self.assertEqualDiff(
1051
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1053
shared repository: repo
1056
control: Meta directory format 1
1059
Create working tree for new branches inside the repository.
1064
""" % (format.repository_format.get_format_description(),
1066
self.assertEqual('', err)
1068
# Create branch in root of repository
1069
control = repo.bzrdir
1070
branch = control.create_branch()
1071
control.create_workingtree()
1072
out, err = self.run_bzr('info -v repo')
1073
self.assertEqualDiff(
1074
"""Repository tree (format: knit)
1076
shared repository: repo
1077
repository branch: repo
1080
control: Meta directory format 1
1081
working tree: Working tree format 3
1085
In the working tree:
1093
0 versioned subdirectories
1102
""" % (format.get_branch_format().get_format_description(),
1103
format.repository_format.get_format_description(),
1105
self.assertEqual('', err)
1107
def assertCheckoutStatusOutput(self,
1108
command_string, lco_tree, shared_repo=None,
1111
branch_locked=False, repo_locked=False,
1113
light_checkout=True,
1114
checkout_root=None):
1115
"""Check the output of info in a checkout.
1117
This is not quite a mirror of the info code: rather than using the
1118
tree being examined to predict output, it uses a bunch of flags which
1119
allow us, the test writers, to document what *should* be present in
1120
the output. Removing this separation would remove the value of the
1123
:param path: the path to the light checkout.
1124
:param lco_tree: the tree object for the light checkout.
1125
:param shared_repo: A shared repository is in use, expect that in
1127
:param repo_branch: A branch in a shared repository for non light
1129
:param tree_locked: If true, expect the tree to be locked.
1130
:param branch_locked: If true, expect the branch to be locked.
1131
:param repo_locked: If true, expect the repository to be locked.
1132
Note that the lco_tree.branch.repository is inspected, and if is not
1133
actually locked then this parameter is overridden. This is because
1134
pack repositories do not have any public API for obtaining an
1135
exclusive repository wide lock.
1136
:param verbose: If true, expect verbose output
1138
def friendly_location(url):
1139
path = urlutils.unescape_for_display(url, 'ascii')
1141
return osutils.relpath(osutils.getcwd(), path)
1142
except errors.PathNotChild:
1145
if tree_locked and sys.platform == 'win32':
1146
# We expect this to fail because of locking errors. (A write-locked
1147
# file cannot be read-locked in the same process).
1148
# This should be removed when the locking errors are fixed.
1149
self.run_bzr_error([], 'info ' + command_string)
1151
out, err = self.run_bzr('info %s' % command_string)
1153
(True, True): 'Lightweight checkout',
1154
(True, False): 'Repository checkout',
1155
(False, True): 'Lightweight checkout',
1156
(False, False): 'Checkout',
1157
}[(shared_repo is not None, light_checkout)]
1158
format = {True: 'dirstate or dirstate-tags or knitpack-experimental',
1159
False: 'dirstate'}[light_checkout]
1161
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1162
if repo_locked or branch_locked or tree_locked:
1163
def locked_message(a_bool):
1168
expected_lock_output = (
1171
" working tree: %s\n"
1173
" repository: %s\n" % (
1174
locked_message(tree_locked),
1175
locked_message(branch_locked),
1176
locked_message(repo_locked)))
1178
expected_lock_output = ''
1182
tree_data = (" light checkout root: %s\n" %
1183
friendly_location(lco_tree.bzrdir.root_transport.base))
1185
if lco_tree.branch.get_bound_location() is not None:
1186
tree_data += ("%s checkout root: %s\n" % (extra_space,
1187
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1188
if shared_repo is not None:
1190
" checkout of branch: %s\n"
1191
" shared repository: %s\n" %
1192
(friendly_location(repo_branch.bzrdir.root_transport.base),
1193
friendly_location(shared_repo.bzrdir.root_transport.base)))
1194
elif repo_branch is not None:
1196
"%s checkout of branch: %s\n" %
1198
friendly_location(repo_branch.bzrdir.root_transport.base)))
1200
branch_data = (" checkout of branch: %s\n" %
1201
lco_tree.branch.bzrdir.root_transport.base)
1204
verbose_info = ' 0 committers\n'
1208
self.assertEqualDiff(
1213
control: Meta directory format 1
1218
In the working tree:
1226
0 versioned subdirectories
1238
lco_tree._format.get_format_description(),
1239
lco_tree.branch._format.get_format_description(),
1240
lco_tree.branch.repository._format.get_format_description(),
1241
expected_lock_output,
1244
self.assertEqual('', err)
1246
def test_info_locking(self):
1247
transport = self.get_transport()
1248
# Create shared repository with a branch
1249
repo = self.make_repository('repo', shared=True,
1250
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1251
repo.set_make_working_trees(False)
1252
repo.bzrdir.root_transport.mkdir('branch')
1253
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1254
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1255
# Do a heavy checkout
1256
transport.mkdir('tree')
1257
transport.mkdir('tree/checkout')
1258
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1259
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1260
co_branch.bind(repo_branch)
1261
# Do a light checkout of the heavy one
1262
transport.mkdir('tree/lightcheckout')
1263
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1264
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1265
lco_dir.create_workingtree()
1266
lco_tree = lco_dir.open_workingtree()
1268
# Test all permutations of locking the working tree, branch and repository
1272
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1273
repo_branch=repo_branch,
1274
verbose=True, light_checkout=True)
1276
lco_tree.branch.repository.lock_write()
1278
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1279
lco_tree, repo_branch=repo_branch,
1280
repo_locked=True, verbose=True, light_checkout=True)
1282
lco_tree.branch.repository.unlock()
1284
lco_tree.branch.lock_write()
1286
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1290
repo_branch=repo_branch,
1293
lco_tree.branch.unlock()
1295
lco_tree.lock_write()
1297
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1298
lco_tree, repo_branch=repo_branch,
1306
lco_tree.lock_write()
1307
lco_tree.branch.repository.unlock()
1309
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1310
lco_tree, repo_branch=repo_branch,
1315
lco_tree.branch.repository.lock_write()
1318
lco_tree.lock_write()
1319
lco_tree.branch.unlock()
1321
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1322
lco_tree, repo_branch=repo_branch,
1326
lco_tree.branch.lock_write()
1329
lco_tree.lock_write()
1330
lco_tree.branch.unlock()
1331
lco_tree.branch.repository.lock_write()
1333
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1334
lco_tree, repo_branch=repo_branch,
1339
lco_tree.branch.repository.unlock()
1340
lco_tree.branch.lock_write()
1343
lco_tree.branch.lock_write()
1344
lco_tree.branch.repository.unlock()
1346
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1347
lco_tree, repo_branch=repo_branch,
1351
lco_tree.branch.repository.lock_write()
1352
lco_tree.branch.unlock()
1354
if sys.platform == 'win32':
1355
self.knownFailure('Win32 cannot run "bzr info"'
1356
' when the tree is locked.')
1358
def test_info_locking_oslocks(self):
1359
if sys.platform == "win32":
1360
raise TestSkipped("don't use oslocks on win32 in unix manner")
1362
tree = self.make_branch_and_tree('branch',
1363
format=bzrlib.bzrdir.BzrDirFormat6())
1365
# Test all permutations of locking the working tree, branch and repository
1366
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1367
# implemented by raising NotImplementedError and get_physical_lock_status()
1368
# always returns false. This makes bzr info hide the lock status. (Olaf)
1372
out, err = self.run_bzr('info -v branch')
1373
self.assertEqualDiff(
1374
"""Standalone tree (format: weave)
1379
control: All-in-one format 6
1380
working tree: Working tree format 2
1381
branch: Branch format 4
1384
In the working tree:
1392
0 versioned subdirectories
1401
""" % ('branch', tree.branch.repository._format.get_format_description(),
1403
self.assertEqual('', err)
1406
out, err = self.run_bzr('info -v branch')
1407
self.assertEqualDiff(
1408
"""Standalone tree (format: weave)
1413
control: All-in-one format 6
1414
working tree: Working tree format 2
1415
branch: Branch format 4
1418
In the working tree:
1426
0 versioned subdirectories
1435
""" % ('branch', tree.branch.repository._format.get_format_description(),
1437
self.assertEqual('', err)