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."""
30
from bzrlib.osutils import format_date
31
from bzrlib.tests import TestSkipped
32
from bzrlib.tests.blackbox import ExternalBase
35
class TestInfo(ExternalBase):
37
def test_info_non_existing(self):
38
if sys.platform == "win32":
39
location = "C:/i/do/not/exist/"
41
location = "/i/do/not/exist/"
42
out, err = self.run_bzr('info '+location, retcode=3)
43
self.assertEqual(out, '')
44
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
46
def test_info_standalone(self):
47
transport = self.get_transport()
49
# Create initial standalone branch
50
tree1 = self.make_branch_and_tree('standalone', 'weave')
51
self.build_tree(['standalone/a'])
53
branch1 = tree1.branch
55
out, err = self.run_bzr('info standalone')
57
"""Standalone tree (format: weave)
59
branch root: standalone
61
self.assertEqual('', err)
63
out, err = self.run_bzr('info standalone -v')
65
"""Standalone tree (format: weave)
67
branch root: standalone
70
control: All-in-one format 6
71
working tree: Working tree format 2
72
branch: Branch format 4
73
repository: Weave repository format 6
83
0 versioned subdirectories
93
self.assertEqual('', err)
94
tree1.commit('commit one')
95
rev = branch1.repository.get_revision(branch1.revision_history()[0])
96
datestring_first = format_date(rev.timestamp, rev.timezone)
98
# Branch standalone with push location
99
branch2 = branch1.bzrdir.sprout('branch').open_branch()
100
branch2.set_push_location(branch1.bzrdir.root_transport.base)
102
out, err = self.run_bzr('info branch')
103
self.assertEqualDiff(
104
"""Standalone tree (format: weave)
109
push branch: standalone
110
parent branch: standalone
112
self.assertEqual('', err)
114
out, err = self.run_bzr('info branch --verbose')
115
self.assertEqualDiff(
116
"""Standalone tree (format: weave)
121
push branch: standalone
122
parent branch: standalone
125
control: All-in-one format 6
126
working tree: Working tree format 2
127
branch: Branch format 4
128
repository: Weave repository format 6
138
0 versioned subdirectories
150
""" % (datestring_first, datestring_first,
151
# poking at _revision_store isn't all that clean, but neither is
152
# having the ui test dependent on the exact overhead of a given store.
153
branch2.repository._revision_store.total_size(
154
branch2.repository.get_transaction())[1] / 1024,
156
self.assertEqual('', err)
158
# Branch and bind to standalone, needs upgrade to metadir
159
# (creates backup as unknown)
160
branch1.bzrdir.sprout('bound')
161
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
162
bzrlib.upgrade.upgrade('bound', knit1_format)
163
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
164
branch3.bind(branch1)
165
bound_tree = branch3.bzrdir.open_workingtree()
166
out, err = self.run_bzr('info -v bound')
167
self.assertEqualDiff(
168
"""Checkout (format: knit)
171
checkout of branch: standalone
174
parent branch: standalone
177
control: Meta directory format 1
190
0 versioned subdirectories
202
""" % (bound_tree._format.get_format_description(),
203
branch3._format.get_format_description(),
204
branch3.repository._format.get_format_description(),
205
datestring_first, datestring_first,
206
# poking at _revision_store isn't all that clean, but neither is
207
# having the ui test dependent on the exact overhead of a given store.
208
branch3.repository._revision_store.total_size(
209
branch3.repository.get_transaction())[1] / 1024,
211
self.assertEqual('', err)
213
# Checkout standalone (same as above, but does not have parent set)
214
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
216
branch4.bind(branch1)
217
branch4.bzrdir.open_workingtree().update()
218
out, err = self.run_bzr('info checkout --verbose')
219
self.assertEqualDiff(
220
"""Checkout (format: knit)
222
checkout root: checkout
223
checkout of branch: standalone
226
control: Meta directory format 1
227
working tree: Working tree format 3
228
branch: Branch format 5
239
0 versioned subdirectories
251
""" % (branch4.repository._format.get_format_description(),
252
datestring_first, datestring_first,
253
# poking at _revision_store isn't all that clean, but neither is
254
# having the ui test dependent on the exact overhead of a given store.
255
branch4.repository._revision_store.total_size(
256
branch4.repository.get_transaction())[1] / 1024,
258
self.assertEqual('', err)
260
# Lightweight checkout (same as above, different branch and repository)
261
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
262
branch5 = tree5.branch
263
out, err = self.run_bzr('info -v lightcheckout')
264
self.assertEqualDiff(
265
"""Lightweight checkout (format: dirstate or dirstate-tags)
267
light checkout root: lightcheckout
268
checkout of branch: standalone
271
control: Meta directory format 1
272
working tree: Working tree format 4
273
branch: Branch format 4
274
repository: Weave repository format 6
284
0 versioned subdirectories
296
""" % (datestring_first, datestring_first,), out)
297
self.assertEqual('', err)
299
# Update initial standalone branch
300
self.build_tree(['standalone/b'])
302
tree1.commit('commit two')
303
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
304
datestring_last = format_date(rev.timestamp, rev.timezone)
306
# Out of date branched standalone branch will not be detected
307
out, err = self.run_bzr('info -v branch')
308
self.assertEqualDiff(
309
"""Standalone tree (format: weave)
314
push branch: standalone
315
parent branch: standalone
318
control: All-in-one format 6
319
working tree: Working tree format 2
320
branch: Branch format 4
321
repository: Weave repository format 6
331
0 versioned subdirectories
343
""" % (datestring_first, datestring_first,
345
self.assertEqual('', err)
347
# Out of date bound branch
348
out, err = self.run_bzr('info -v bound')
349
self.assertEqualDiff(
350
"""Checkout (format: knit)
353
checkout of branch: standalone
356
parent branch: standalone
359
control: Meta directory format 1
360
working tree: Working tree format 3
361
branch: Branch format 5
364
Branch is out of date: missing 1 revision.
374
0 versioned subdirectories
386
""" % (branch3.repository._format.get_format_description(),
387
datestring_first, datestring_first,
388
# poking at _revision_store isn't all that clean, but neither is
389
# having the ui test dependent on the exact overhead of a given store.
390
branch3.repository._revision_store.total_size(
391
branch3.repository.get_transaction())[1] / 1024,
393
self.assertEqual('', err)
395
# Out of date checkout
396
out, err = self.run_bzr('info -v checkout')
397
self.assertEqualDiff(
398
"""Checkout (format: knit)
400
checkout root: checkout
401
checkout of branch: standalone
404
control: Meta directory format 1
405
working tree: Working tree format 3
406
branch: Branch format 5
409
Branch is out of date: missing 1 revision.
419
0 versioned subdirectories
431
""" % (branch4.repository._format.get_format_description(),
432
datestring_first, datestring_first,
433
# poking at _revision_store isn't all that clean, but neither is
434
# having the ui test dependent on the exact overhead of a given store.
435
branch4.repository._revision_store.total_size(
436
branch4.repository.get_transaction())[1] / 1024,
438
self.assertEqual('', err)
440
# Out of date lightweight checkout
441
out, err = self.run_bzr('info lightcheckout --verbose')
442
self.assertEqualDiff(
443
"""Lightweight checkout (format: dirstate or dirstate-tags)
445
light checkout root: lightcheckout
446
checkout of branch: standalone
449
control: Meta directory format 1
450
working tree: Working tree format 4
451
branch: Branch format 4
452
repository: Weave repository format 6
454
Working tree is out of date: missing 1 revision.
464
0 versioned subdirectories
476
""" % (datestring_first, datestring_last,), out)
477
self.assertEqual('', err)
479
def test_info_standalone_no_tree(self):
480
# create standalone branch without a working tree
481
format = bzrdir.format_registry.make_bzrdir('default')
482
branch = self.make_branch('branch')
483
repo = branch.repository
484
out, err = self.run_bzr('info branch -v')
485
self.assertEqualDiff(
486
"""Standalone branch (format: dirstate or knit)
491
control: Meta directory format 1
502
""" % (format.get_branch_format().get_format_description(),
503
format.repository_format.get_format_description(),
505
self.assertEqual('', err)
507
def test_info_shared_repository(self):
508
format = bzrdir.format_registry.make_bzrdir('knit')
509
transport = self.get_transport()
511
# Create shared repository
512
repo = self.make_repository('repo', shared=True, format=format)
513
repo.set_make_working_trees(False)
514
out, err = self.run_bzr('info -v repo')
515
self.assertEqualDiff(
516
"""Shared repository (format: dirstate or dirstate-tags or knit)
518
shared repository: %s
521
control: Meta directory format 1
527
""" % ('repo', format.repository_format.get_format_description(),
529
self.assertEqual('', err)
531
# Create branch inside shared repository
532
repo.bzrdir.root_transport.mkdir('branch')
533
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
535
out, err = self.run_bzr('info -v repo/branch')
536
self.assertEqualDiff(
537
"""Repository branch (format: dirstate or knit)
539
shared repository: repo
540
repository branch: repo/branch
543
control: Meta directory format 1
554
""" % (format.get_branch_format().get_format_description(),
555
format.repository_format.get_format_description(),
557
self.assertEqual('', err)
559
# Create lightweight checkout
560
transport.mkdir('tree')
561
transport.mkdir('tree/lightcheckout')
562
tree2 = branch1.create_checkout('tree/lightcheckout',
564
branch2 = tree2.branch
565
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
566
shared_repo=repo, repo_branch=branch1, verbose=True)
568
# Create normal checkout
569
tree3 = branch1.create_checkout('tree/checkout')
570
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
572
light_checkout=False, repo_branch=branch1)
573
# Update lightweight checkout
574
self.build_tree(['tree/lightcheckout/a'])
576
tree2.commit('commit one')
577
rev = repo.get_revision(branch2.revision_history()[0])
578
datestring_first = format_date(rev.timestamp, rev.timezone)
579
out, err = self.run_bzr('info tree/lightcheckout --verbose')
580
self.assertEqualDiff(
581
"""Lightweight checkout (format: dirstate or dirstate-tags)
583
light checkout root: tree/lightcheckout
584
checkout of branch: repo/branch
585
shared repository: repo
588
control: Meta directory format 1
589
working tree: Working tree format 4
601
0 versioned subdirectories
613
""" % (format.get_branch_format().get_format_description(),
614
format.repository_format.get_format_description(),
615
datestring_first, datestring_first,
616
# poking at _revision_store isn't all that clean, but neither is
617
# having the ui test dependent on the exact overhead of a given store.
618
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
620
self.assertEqual('', err)
622
# Out of date checkout
623
out, err = self.run_bzr('info -v tree/checkout')
624
self.assertEqualDiff(
625
"""Checkout (format: dirstate)
627
checkout root: tree/checkout
628
checkout of branch: repo/branch
631
control: Meta directory format 1
632
working tree: Working tree format 4
636
Branch is out of date: missing 1 revision.
646
0 versioned subdirectories
655
""" % (format.get_branch_format().get_format_description(),
656
format.repository_format.get_format_description(),
658
self.assertEqual('', err)
662
self.build_tree(['tree/checkout/b'])
664
out, err = self.run_bzr('info tree/checkout --verbose')
665
self.assertEqualDiff(
666
"""Checkout (format: dirstate)
668
checkout root: tree/checkout
669
checkout of branch: repo/branch
672
control: Meta directory format 1
673
working tree: Working tree format 4
685
0 versioned subdirectories
697
""" % (format.get_branch_format().get_format_description(),
698
format.repository_format.get_format_description(),
699
datestring_first, datestring_first,
700
# poking at _revision_store isn't all that clean, but neither is
701
# having the ui test dependent on the exact overhead of a given store.
702
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
704
self.assertEqual('', err)
705
tree3.commit('commit two')
707
# Out of date lightweight checkout
708
rev = repo.get_revision(branch1.revision_history()[-1])
709
datestring_last = format_date(rev.timestamp, rev.timezone)
710
out, err = self.run_bzr('info tree/lightcheckout --verbose')
711
self.assertEqualDiff(
712
"""Lightweight checkout (format: dirstate or dirstate-tags)
714
light checkout root: tree/lightcheckout
715
checkout of branch: repo/branch
716
shared repository: repo
719
control: Meta directory format 1
720
working tree: Working tree format 4
724
Working tree is out of date: missing 1 revision.
734
0 versioned subdirectories
746
""" % (format.get_branch_format().get_format_description(),
747
format.repository_format.get_format_description(),
748
datestring_first, datestring_last,
749
# poking at _revision_store isn't all that clean, but neither is
750
# having the ui test dependent on the exact overhead of a given store.
751
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
753
self.assertEqual('', err)
755
# Show info about shared branch
756
out, err = self.run_bzr('info repo/branch --verbose')
757
self.assertEqualDiff(
758
"""Repository branch (format: dirstate or knit)
760
shared repository: repo
761
repository branch: repo/branch
764
control: Meta directory format 1
778
""" % (format.get_branch_format().get_format_description(),
779
format.repository_format.get_format_description(),
780
datestring_first, datestring_last,
781
# poking at _revision_store isn't all that clean, but neither is
782
# having the ui test dependent on the exact overhead of a given store.
783
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
785
self.assertEqual('', err)
787
# Show info about repository with revisions
788
out, err = self.run_bzr('info -v repo')
789
self.assertEqualDiff(
790
"""Shared repository (format: dirstate or dirstate-tags or knit)
792
shared repository: repo
795
control: Meta directory format 1
801
""" % (format.repository_format.get_format_description(),
802
# poking at _revision_store isn't all that clean, but neither is
803
# having the ui test dependent on the exact overhead of a given store.
804
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
806
self.assertEqual('', err)
808
def test_info_shared_repository_with_trees(self):
809
format = bzrdir.format_registry.make_bzrdir('knit')
810
transport = self.get_transport()
812
# Create shared repository with working trees
813
repo = self.make_repository('repo', shared=True, format=format)
814
repo.set_make_working_trees(True)
815
out, err = self.run_bzr('info -v repo')
816
self.assertEqualDiff(
817
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
819
shared repository: repo
822
control: Meta directory format 1
825
Create working tree for new branches inside the repository.
830
""" % (format.repository_format.get_format_description(),
832
self.assertEqual('', err)
834
# Create two branches
835
repo.bzrdir.root_transport.mkdir('branch1')
836
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
838
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
841
out, err = self.run_bzr('info repo/branch1 --verbose')
842
self.assertEqualDiff(
843
"""Repository tree (format: knit)
845
shared repository: repo
846
repository branch: repo/branch1
849
control: Meta directory format 1
850
working tree: Working tree format 3
862
0 versioned subdirectories
871
""" % (format.get_branch_format().get_format_description(),
872
format.repository_format.get_format_description(),
874
self.assertEqual('', err)
876
# Update first branch
877
self.build_tree(['repo/branch1/a'])
878
tree1 = branch1.bzrdir.open_workingtree()
880
tree1.commit('commit one')
881
rev = repo.get_revision(branch1.revision_history()[0])
882
datestring_first = format_date(rev.timestamp, rev.timezone)
883
out, err = self.run_bzr('info -v repo/branch1')
884
self.assertEqualDiff(
885
"""Repository tree (format: knit)
887
shared repository: repo
888
repository branch: repo/branch1
891
control: Meta directory format 1
892
working tree: Working tree format 3
904
0 versioned subdirectories
916
""" % (format.get_branch_format().get_format_description(),
917
format.repository_format.get_format_description(),
918
datestring_first, datestring_first,
919
# poking at _revision_store isn't all that clean, but neither is
920
# having the ui test dependent on the exact overhead of a given store.
921
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
923
self.assertEqual('', err)
925
# Out of date second branch
926
out, err = self.run_bzr('info repo/branch2 --verbose')
927
self.assertEqualDiff(
928
"""Repository tree (format: knit)
930
shared repository: repo
931
repository branch: repo/branch2
934
parent branch: repo/branch1
937
control: Meta directory format 1
938
working tree: Working tree format 3
950
0 versioned subdirectories
959
""" % (format.get_branch_format().get_format_description(),
960
format.repository_format.get_format_description(),
961
# poking at _revision_store isn't all that clean, but neither is
962
# having the ui test dependent on the exact overhead of a given store.
963
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
965
self.assertEqual('', err)
967
# Update second branch
968
tree2 = branch2.bzrdir.open_workingtree()
970
out, err = self.run_bzr('info -v repo/branch2')
971
self.assertEqualDiff(
972
"""Repository tree (format: knit)
974
shared repository: repo
975
repository branch: repo/branch2
978
parent branch: repo/branch1
981
control: Meta directory format 1
982
working tree: Working tree format 3
994
0 versioned subdirectories
1006
""" % (format.get_branch_format().get_format_description(),
1007
format.repository_format.get_format_description(),
1008
datestring_first, datestring_first,
1009
# poking at _revision_store isn't all that clean, but neither is
1010
# having the ui test dependent on the exact overhead of a given store.
1011
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1013
self.assertEqual('', err)
1015
# Show info about repository with revisions
1016
out, err = self.run_bzr('info -v repo')
1017
self.assertEqualDiff(
1018
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1020
shared repository: repo
1023
control: Meta directory format 1
1026
Create working tree for new branches inside the repository.
1031
""" % (format.repository_format.get_format_description(),
1032
# poking at _revision_store isn't all that clean, but neither is
1033
# having the ui test dependent on the exact overhead of a given store.
1034
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1037
self.assertEqual('', err)
1039
def test_info_shared_repository_with_tree_in_root(self):
1040
format = bzrdir.format_registry.make_bzrdir('knit')
1041
transport = self.get_transport()
1043
# Create shared repository with working trees
1044
repo = self.make_repository('repo', shared=True, format=format)
1045
repo.set_make_working_trees(True)
1046
out, err = self.run_bzr('info -v repo')
1047
self.assertEqualDiff(
1048
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1050
shared repository: repo
1053
control: Meta directory format 1
1056
Create working tree for new branches inside the repository.
1061
""" % (format.repository_format.get_format_description(),
1063
self.assertEqual('', err)
1065
# Create branch in root of repository
1066
control = repo.bzrdir
1067
branch = control.create_branch()
1068
control.create_workingtree()
1069
out, err = self.run_bzr('info -v repo')
1070
self.assertEqualDiff(
1071
"""Repository tree (format: knit)
1073
shared repository: repo
1074
repository branch: repo
1077
control: Meta directory format 1
1078
working tree: Working tree format 3
1082
In the working tree:
1090
0 versioned subdirectories
1099
""" % (format.get_branch_format().get_format_description(),
1100
format.repository_format.get_format_description(),
1102
self.assertEqual('', err)
1104
def assertCheckoutStatusOutput(self,
1105
command_string, lco_tree, shared_repo=None,
1108
branch_locked=False, repo_locked=False,
1110
light_checkout=True,
1111
checkout_root=None):
1112
"""Check the output of info in a checkout.
1114
This is not quite a mirror of the info code: rather than using the
1115
tree being examined to predict output, it uses a bunch of flags which
1116
allow us, the test writers, to document what *should* be present in
1117
the output. Removing this separation would remove the value of the
1120
:param path: the path to the light checkout.
1121
:param lco_tree: the tree object for the light checkout.
1122
:param shared_repo: A shared repository is in use, expect that in
1124
:param repo_branch: A branch in a shared repository for non light
1126
:param tree_locked: If true, expect the tree to be locked.
1127
:param branch_locked: If true, expect the branch to be locked.
1128
:param repo_locked: If true, expect the repository to be locked.
1129
:param verbose: If true, expect verbose output
1131
def friendly_location(url):
1132
path = urlutils.unescape_for_display(url, 'ascii')
1134
return osutils.relpath(os.getcwd(), path)
1135
except errors.PathNotChild:
1138
if tree_locked and sys.platform == 'win32':
1139
# We expect this to fail because of locking errors. (A write-locked
1140
# file cannot be read-locked in the same process).
1141
# This should be removed when the locking errors are fixed.
1142
args = command_string.split(' ')
1143
self.run_bzr_error([], 'info', *args)
1145
out, err = self.run_bzr('info %s' % command_string)
1147
(True, True): 'Lightweight checkout',
1148
(True, False): 'Repository checkout',
1149
(False, True): 'Lightweight checkout',
1150
(False, False): 'Checkout',
1151
}[(shared_repo is not None, light_checkout)]
1152
format = {True: 'dirstate or dirstate-tags',
1153
False: 'dirstate'}[light_checkout]
1154
if repo_locked or branch_locked or tree_locked:
1155
def locked_message(a_bool):
1160
expected_lock_output = (
1163
" working tree: %s\n"
1165
" repository: %s\n" % (
1166
locked_message(tree_locked),
1167
locked_message(branch_locked),
1168
locked_message(repo_locked)))
1170
expected_lock_output = ''
1174
tree_data = (" light checkout root: %s\n" %
1175
friendly_location(lco_tree.bzrdir.root_transport.base))
1177
if lco_tree.branch.get_bound_location() is not None:
1178
tree_data += ("%s checkout root: %s\n" % (extra_space,
1179
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1180
if shared_repo is not None:
1182
" checkout of branch: %s\n"
1183
" shared repository: %s\n" %
1184
(friendly_location(repo_branch.bzrdir.root_transport.base),
1185
friendly_location(shared_repo.bzrdir.root_transport.base)))
1186
elif repo_branch is not None:
1188
"%s checkout of branch: %s\n" %
1190
friendly_location(repo_branch.bzrdir.root_transport.base)))
1192
branch_data = (" checkout of branch: %s\n" %
1193
lco_tree.branch.bzrdir.root_transport.base)
1196
verbose_info = ' 0 committers\n'
1200
self.assertEqualDiff(
1205
control: Meta directory format 1
1210
In the working tree:
1218
0 versioned subdirectories
1230
lco_tree._format.get_format_description(),
1231
lco_tree.branch._format.get_format_description(),
1232
lco_tree.branch.repository._format.get_format_description(),
1233
expected_lock_output,
1236
self.assertEqual('', err)
1238
def test_info_locking(self):
1239
transport = self.get_transport()
1240
# Create shared repository with a branch
1241
repo = self.make_repository('repo', shared=True,
1242
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1243
repo.set_make_working_trees(False)
1244
repo.bzrdir.root_transport.mkdir('branch')
1245
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1246
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1247
# Do a heavy checkout
1248
transport.mkdir('tree')
1249
transport.mkdir('tree/checkout')
1250
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1251
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1252
co_branch.bind(repo_branch)
1253
# Do a light checkout of the heavy one
1254
transport.mkdir('tree/lightcheckout')
1255
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1256
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1257
lco_dir.create_workingtree()
1258
lco_tree = lco_dir.open_workingtree()
1260
# Test all permutations of locking the working tree, branch and repository
1264
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1265
repo_branch=repo_branch,
1266
verbose=True, light_checkout=True)
1268
lco_tree.branch.repository.lock_write()
1270
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1271
lco_tree, repo_branch=repo_branch,
1272
repo_locked=True, verbose=True, light_checkout=True)
1274
lco_tree.branch.repository.unlock()
1276
lco_tree.branch.lock_write()
1278
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1282
repo_branch=repo_branch,
1285
lco_tree.branch.unlock()
1287
lco_tree.lock_write()
1289
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1290
lco_tree, repo_branch=repo_branch,
1298
lco_tree.lock_write()
1299
lco_tree.branch.repository.unlock()
1301
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1302
lco_tree, repo_branch=repo_branch,
1307
lco_tree.branch.repository.lock_write()
1310
lco_tree.lock_write()
1311
lco_tree.branch.unlock()
1313
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1314
lco_tree, repo_branch=repo_branch,
1318
lco_tree.branch.lock_write()
1321
lco_tree.lock_write()
1322
lco_tree.branch.unlock()
1323
lco_tree.branch.repository.lock_write()
1325
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1326
lco_tree, repo_branch=repo_branch,
1331
lco_tree.branch.repository.unlock()
1332
lco_tree.branch.lock_write()
1335
lco_tree.branch.lock_write()
1336
lco_tree.branch.repository.unlock()
1338
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1339
lco_tree, repo_branch=repo_branch,
1343
lco_tree.branch.repository.lock_write()
1344
lco_tree.branch.unlock()
1346
if sys.platform == 'win32':
1347
self.knownFailure('Win32 cannot run "bzr info"'
1348
' when the tree is locked.')
1350
def test_info_locking_oslocks(self):
1351
if sys.platform == "win32":
1352
raise TestSkipped("don't use oslocks on win32 in unix manner")
1354
tree = self.make_branch_and_tree('branch',
1355
format=bzrlib.bzrdir.BzrDirFormat6())
1357
# Test all permutations of locking the working tree, branch and repository
1358
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1359
# implemented by raising NotImplementedError and get_physical_lock_status()
1360
# always returns false. This makes bzr info hide the lock status. (Olaf)
1364
out, err = self.run_bzr('info -v branch')
1365
self.assertEqualDiff(
1366
"""Standalone tree (format: weave)
1371
control: All-in-one format 6
1372
working tree: Working tree format 2
1373
branch: Branch format 4
1376
In the working tree:
1384
0 versioned subdirectories
1393
""" % ('branch', tree.branch.repository._format.get_format_description(),
1395
self.assertEqual('', err)
1398
out, err = self.run_bzr('info -v branch')
1399
self.assertEqualDiff(
1400
"""Standalone tree (format: weave)
1405
control: All-in-one format 6
1406
working tree: Working tree format 2
1407
branch: Branch format 4
1410
In the working tree:
1418
0 versioned subdirectories
1427
""" % ('branch', tree.branch.repository._format.get_format_description(),
1429
self.assertEqual('', err)