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."""
31
from bzrlib.osutils import format_date
32
from bzrlib.tests import TestSkipped
33
from bzrlib.tests.blackbox import ExternalBase
36
class TestInfo(ExternalBase):
38
def test_info_non_existing(self):
39
if sys.platform == "win32":
40
location = "C:/i/do/not/exist/"
42
location = "/i/do/not/exist/"
43
out, err = self.run_bzr('info '+location, retcode=3)
44
self.assertEqual(out, '')
45
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
47
def test_info_standalone(self):
48
transport = self.get_transport()
50
# Create initial standalone branch
51
tree1 = self.make_branch_and_tree('standalone', 'weave')
52
self.build_tree(['standalone/a'])
54
branch1 = tree1.branch
56
out, err = self.run_bzr('info standalone')
58
"""Standalone tree (format: weave)
60
branch root: standalone
62
self.assertEqual('', err)
64
out, err = self.run_bzr('info standalone -v')
66
"""Standalone tree (format: weave)
68
branch root: standalone
71
control: All-in-one format 6
72
working tree: Working tree format 2
73
branch: Branch format 4
74
repository: Weave repository format 6
84
0 versioned subdirectories
94
self.assertEqual('', err)
95
tree1.commit('commit one')
96
rev = branch1.repository.get_revision(branch1.revision_history()[0])
97
datestring_first = format_date(rev.timestamp, rev.timezone)
99
# Branch standalone with push location
100
branch2 = branch1.bzrdir.sprout('branch').open_branch()
101
branch2.set_push_location(branch1.bzrdir.root_transport.base)
103
out, err = self.run_bzr('info branch')
104
self.assertEqualDiff(
105
"""Standalone tree (format: weave)
110
push branch: standalone
111
parent branch: standalone
113
self.assertEqual('', err)
115
out, err = self.run_bzr('info branch --verbose')
116
self.assertEqualDiff(
117
"""Standalone tree (format: weave)
122
push branch: standalone
123
parent branch: standalone
126
control: All-in-one format 6
127
working tree: Working tree format 2
128
branch: Branch format 4
129
repository: Weave repository format 6
139
0 versioned subdirectories
151
""" % (datestring_first, datestring_first,
152
# poking at _revision_store isn't all that clean, but neither is
153
# having the ui test dependent on the exact overhead of a given store.
154
branch2.repository._revision_store.total_size(
155
branch2.repository.get_transaction())[1] / 1024,
157
self.assertEqual('', err)
159
# Branch and bind to standalone, needs upgrade to metadir
160
# (creates backup as unknown)
161
branch1.bzrdir.sprout('bound')
162
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
163
bzrlib.upgrade.upgrade('bound', knit1_format)
164
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
165
branch3.bind(branch1)
166
bound_tree = branch3.bzrdir.open_workingtree()
167
out, err = self.run_bzr('info -v bound')
168
self.assertEqualDiff(
169
"""Checkout (format: knit)
172
checkout of branch: standalone
175
parent branch: standalone
178
control: Meta directory format 1
191
0 versioned subdirectories
203
""" % (bound_tree._format.get_format_description(),
204
branch3._format.get_format_description(),
205
branch3.repository._format.get_format_description(),
206
datestring_first, datestring_first,
207
# poking at _revision_store isn't all that clean, but neither is
208
# having the ui test dependent on the exact overhead of a given store.
209
branch3.repository._revision_store.total_size(
210
branch3.repository.get_transaction())[1] / 1024,
212
self.assertEqual('', err)
214
# Checkout standalone (same as above, but does not have parent set)
215
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
217
branch4.bind(branch1)
218
branch4.bzrdir.open_workingtree().update()
219
out, err = self.run_bzr('info checkout --verbose')
220
self.assertEqualDiff(
221
"""Checkout (format: knit)
223
checkout root: checkout
224
checkout of branch: standalone
227
control: Meta directory format 1
228
working tree: Working tree format 3
229
branch: Branch format 5
240
0 versioned subdirectories
252
""" % (branch4.repository._format.get_format_description(),
253
datestring_first, datestring_first,
254
# poking at _revision_store isn't all that clean, but neither is
255
# having the ui test dependent on the exact overhead of a given store.
256
branch4.repository._revision_store.total_size(
257
branch4.repository.get_transaction())[1] / 1024,
259
self.assertEqual('', err)
261
# Lightweight checkout (same as above, different branch and repository)
262
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
263
branch5 = tree5.branch
264
out, err = self.run_bzr('info -v lightcheckout')
265
self.assertEqualDiff(
266
"""Lightweight checkout (format: dirstate or dirstate-tags or knitpack-experimental)
268
light checkout root: lightcheckout
269
checkout of branch: standalone
272
control: Meta directory format 1
273
working tree: Working tree format 4
274
branch: Branch format 4
275
repository: Weave repository format 6
285
0 versioned subdirectories
297
""" % (datestring_first, datestring_first,), out)
298
self.assertEqual('', err)
300
# Update initial standalone branch
301
self.build_tree(['standalone/b'])
303
tree1.commit('commit two')
304
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
305
datestring_last = format_date(rev.timestamp, rev.timezone)
307
# Out of date branched standalone branch will not be detected
308
out, err = self.run_bzr('info -v branch')
309
self.assertEqualDiff(
310
"""Standalone tree (format: weave)
315
push branch: standalone
316
parent branch: standalone
319
control: All-in-one format 6
320
working tree: Working tree format 2
321
branch: Branch format 4
322
repository: Weave repository format 6
332
0 versioned subdirectories
344
""" % (datestring_first, datestring_first,
346
self.assertEqual('', err)
348
# Out of date bound branch
349
out, err = self.run_bzr('info -v bound')
350
self.assertEqualDiff(
351
"""Checkout (format: knit)
354
checkout of branch: standalone
357
parent branch: standalone
360
control: Meta directory format 1
361
working tree: Working tree format 3
362
branch: Branch format 5
365
Branch is out of date: missing 1 revision.
375
0 versioned subdirectories
387
""" % (branch3.repository._format.get_format_description(),
388
datestring_first, datestring_first,
389
# poking at _revision_store isn't all that clean, but neither is
390
# having the ui test dependent on the exact overhead of a given store.
391
branch3.repository._revision_store.total_size(
392
branch3.repository.get_transaction())[1] / 1024,
394
self.assertEqual('', err)
396
# Out of date checkout
397
out, err = self.run_bzr('info -v checkout')
398
self.assertEqualDiff(
399
"""Checkout (format: knit)
401
checkout root: checkout
402
checkout of branch: standalone
405
control: Meta directory format 1
406
working tree: Working tree format 3
407
branch: Branch format 5
410
Branch is out of date: missing 1 revision.
420
0 versioned subdirectories
432
""" % (branch4.repository._format.get_format_description(),
433
datestring_first, datestring_first,
434
# poking at _revision_store isn't all that clean, but neither is
435
# having the ui test dependent on the exact overhead of a given store.
436
branch4.repository._revision_store.total_size(
437
branch4.repository.get_transaction())[1] / 1024,
439
self.assertEqual('', err)
441
# Out of date lightweight checkout
442
out, err = self.run_bzr('info lightcheckout --verbose')
443
self.assertEqualDiff(
444
"""Lightweight checkout (format: dirstate or dirstate-tags or knitpack-experimental)
446
light checkout root: lightcheckout
447
checkout of branch: standalone
450
control: Meta directory format 1
451
working tree: Working tree format 4
452
branch: Branch format 4
453
repository: Weave repository format 6
455
Working tree is out of date: missing 1 revision.
465
0 versioned subdirectories
477
""" % (datestring_first, datestring_last,), out)
478
self.assertEqual('', err)
480
def test_info_standalone_no_tree(self):
481
# create standalone branch without a working tree
482
format = bzrdir.format_registry.make_bzrdir('default')
483
branch = self.make_branch('branch')
484
repo = branch.repository
485
out, err = self.run_bzr('info branch -v')
486
self.assertEqualDiff(
487
"""Standalone branch (format: dirstate-tags)
492
control: Meta directory format 1
503
""" % (format.get_branch_format().get_format_description(),
504
format.repository_format.get_format_description(),
506
self.assertEqual('', err)
508
def test_info_shared_repository(self):
509
format = bzrdir.format_registry.make_bzrdir('knit')
510
transport = self.get_transport()
512
# Create shared repository
513
repo = self.make_repository('repo', shared=True, format=format)
514
repo.set_make_working_trees(False)
515
out, err = self.run_bzr('info -v repo')
516
self.assertEqualDiff(
517
"""Shared repository (format: dirstate or dirstate-tags or knit)
519
shared repository: %s
522
control: Meta directory format 1
528
""" % ('repo', format.repository_format.get_format_description(),
530
self.assertEqual('', err)
532
# Create branch inside shared repository
533
repo.bzrdir.root_transport.mkdir('branch')
534
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
536
out, err = self.run_bzr('info -v repo/branch')
537
self.assertEqualDiff(
538
"""Repository branch (format: dirstate or knit)
540
shared repository: repo
541
repository branch: repo/branch
544
control: Meta directory format 1
555
""" % (format.get_branch_format().get_format_description(),
556
format.repository_format.get_format_description(),
558
self.assertEqual('', err)
560
# Create lightweight checkout
561
transport.mkdir('tree')
562
transport.mkdir('tree/lightcheckout')
563
tree2 = branch1.create_checkout('tree/lightcheckout',
565
branch2 = tree2.branch
566
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
567
shared_repo=repo, repo_branch=branch1, verbose=True)
569
# Create normal checkout
570
tree3 = branch1.create_checkout('tree/checkout')
571
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
573
light_checkout=False, repo_branch=branch1)
574
# Update lightweight checkout
575
self.build_tree(['tree/lightcheckout/a'])
577
tree2.commit('commit one')
578
rev = repo.get_revision(branch2.revision_history()[0])
579
datestring_first = format_date(rev.timestamp, rev.timezone)
580
out, err = self.run_bzr('info tree/lightcheckout --verbose')
581
self.assertEqualDiff(
582
"""Lightweight checkout (format: dirstate or dirstate-tags or knitpack-experimental)
584
light checkout root: tree/lightcheckout
585
checkout of branch: repo/branch
586
shared repository: repo
589
control: Meta directory format 1
590
working tree: Working tree format 4
602
0 versioned subdirectories
614
""" % (format.get_branch_format().get_format_description(),
615
format.repository_format.get_format_description(),
616
datestring_first, datestring_first,
617
# poking at _revision_store isn't all that clean, but neither is
618
# having the ui test dependent on the exact overhead of a given store.
619
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
621
self.assertEqual('', err)
623
# Out of date checkout
624
out, err = self.run_bzr('info -v tree/checkout')
625
self.assertEqualDiff(
626
"""Checkout (format: dirstate)
628
checkout root: tree/checkout
629
checkout of branch: repo/branch
632
control: Meta directory format 1
633
working tree: Working tree format 4
637
Branch is out of date: missing 1 revision.
647
0 versioned subdirectories
656
""" % (format.get_branch_format().get_format_description(),
657
format.repository_format.get_format_description(),
659
self.assertEqual('', err)
663
self.build_tree(['tree/checkout/b'])
665
out, err = self.run_bzr('info tree/checkout --verbose')
666
self.assertEqualDiff(
667
"""Checkout (format: dirstate)
669
checkout root: tree/checkout
670
checkout of branch: repo/branch
673
control: Meta directory format 1
674
working tree: Working tree format 4
686
0 versioned subdirectories
698
""" % (format.get_branch_format().get_format_description(),
699
format.repository_format.get_format_description(),
700
datestring_first, datestring_first,
701
# poking at _revision_store isn't all that clean, but neither is
702
# having the ui test dependent on the exact overhead of a given store.
703
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
705
self.assertEqual('', err)
706
tree3.commit('commit two')
708
# Out of date lightweight checkout
709
rev = repo.get_revision(branch1.revision_history()[-1])
710
datestring_last = format_date(rev.timestamp, rev.timezone)
711
out, err = self.run_bzr('info tree/lightcheckout --verbose')
712
self.assertEqualDiff(
713
"""Lightweight checkout (format: dirstate or dirstate-tags or knitpack-experimental)
715
light checkout root: tree/lightcheckout
716
checkout of branch: repo/branch
717
shared repository: repo
720
control: Meta directory format 1
721
working tree: Working tree format 4
725
Working tree is out of date: missing 1 revision.
735
0 versioned subdirectories
747
""" % (format.get_branch_format().get_format_description(),
748
format.repository_format.get_format_description(),
749
datestring_first, datestring_last,
750
# poking at _revision_store isn't all that clean, but neither is
751
# having the ui test dependent on the exact overhead of a given store.
752
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
754
self.assertEqual('', err)
756
# Show info about shared branch
757
out, err = self.run_bzr('info repo/branch --verbose')
758
self.assertEqualDiff(
759
"""Repository branch (format: dirstate or knit)
761
shared repository: repo
762
repository branch: repo/branch
765
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,
782
# poking at _revision_store isn't all that clean, but neither is
783
# having the ui test dependent on the exact overhead of a given store.
784
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
786
self.assertEqual('', err)
788
# Show info about repository with revisions
789
out, err = self.run_bzr('info -v repo')
790
self.assertEqualDiff(
791
"""Shared repository (format: dirstate or dirstate-tags or knit)
793
shared repository: repo
796
control: Meta directory format 1
802
""" % (format.repository_format.get_format_description(),
803
# poking at _revision_store isn't all that clean, but neither is
804
# having the ui test dependent on the exact overhead of a given store.
805
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
807
self.assertEqual('', err)
809
def test_info_shared_repository_with_trees(self):
810
format = bzrdir.format_registry.make_bzrdir('knit')
811
transport = self.get_transport()
813
# Create shared repository with working trees
814
repo = self.make_repository('repo', shared=True, format=format)
815
repo.set_make_working_trees(True)
816
out, err = self.run_bzr('info -v repo')
817
self.assertEqualDiff(
818
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
820
shared repository: repo
823
control: Meta directory format 1
826
Create working tree for new branches inside the repository.
831
""" % (format.repository_format.get_format_description(),
833
self.assertEqual('', err)
835
# Create two branches
836
repo.bzrdir.root_transport.mkdir('branch1')
837
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
839
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
842
out, err = self.run_bzr('info repo/branch1 --verbose')
843
self.assertEqualDiff(
844
"""Repository tree (format: knit)
846
shared repository: repo
847
repository branch: repo/branch1
850
control: Meta directory format 1
851
working tree: Working tree format 3
863
0 versioned subdirectories
872
""" % (format.get_branch_format().get_format_description(),
873
format.repository_format.get_format_description(),
875
self.assertEqual('', err)
877
# Update first branch
878
self.build_tree(['repo/branch1/a'])
879
tree1 = branch1.bzrdir.open_workingtree()
881
tree1.commit('commit one')
882
rev = repo.get_revision(branch1.revision_history()[0])
883
datestring_first = format_date(rev.timestamp, rev.timezone)
884
out, err = self.run_bzr('info -v repo/branch1')
885
self.assertEqualDiff(
886
"""Repository tree (format: knit)
888
shared repository: repo
889
repository branch: repo/branch1
892
control: Meta directory format 1
893
working tree: Working tree format 3
905
0 versioned subdirectories
917
""" % (format.get_branch_format().get_format_description(),
918
format.repository_format.get_format_description(),
919
datestring_first, datestring_first,
920
# poking at _revision_store isn't all that clean, but neither is
921
# having the ui test dependent on the exact overhead of a given store.
922
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
924
self.assertEqual('', err)
926
# Out of date second branch
927
out, err = self.run_bzr('info repo/branch2 --verbose')
928
self.assertEqualDiff(
929
"""Repository tree (format: knit)
931
shared repository: repo
932
repository branch: repo/branch2
935
parent branch: repo/branch1
938
control: Meta directory format 1
939
working tree: Working tree format 3
951
0 versioned subdirectories
960
""" % (format.get_branch_format().get_format_description(),
961
format.repository_format.get_format_description(),
962
# poking at _revision_store isn't all that clean, but neither is
963
# having the ui test dependent on the exact overhead of a given store.
964
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
966
self.assertEqual('', err)
968
# Update second branch
969
tree2 = branch2.bzrdir.open_workingtree()
971
out, err = self.run_bzr('info -v repo/branch2')
972
self.assertEqualDiff(
973
"""Repository tree (format: knit)
975
shared repository: repo
976
repository branch: repo/branch2
979
parent branch: repo/branch1
982
control: Meta directory format 1
983
working tree: Working tree format 3
995
0 versioned subdirectories
1007
""" % (format.get_branch_format().get_format_description(),
1008
format.repository_format.get_format_description(),
1009
datestring_first, datestring_first,
1010
# poking at _revision_store isn't all that clean, but neither is
1011
# having the ui test dependent on the exact overhead of a given store.
1012
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1014
self.assertEqual('', err)
1016
# Show info about repository with revisions
1017
out, err = self.run_bzr('info -v repo')
1018
self.assertEqualDiff(
1019
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1021
shared repository: repo
1024
control: Meta directory format 1
1027
Create working tree for new branches inside the repository.
1032
""" % (format.repository_format.get_format_description(),
1033
# poking at _revision_store isn't all that clean, but neither is
1034
# having the ui test dependent on the exact overhead of a given store.
1035
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1038
self.assertEqual('', err)
1040
def test_info_shared_repository_with_tree_in_root(self):
1041
format = bzrdir.format_registry.make_bzrdir('knit')
1042
transport = self.get_transport()
1044
# Create shared repository with working trees
1045
repo = self.make_repository('repo', shared=True, format=format)
1046
repo.set_make_working_trees(True)
1047
out, err = self.run_bzr('info -v repo')
1048
self.assertEqualDiff(
1049
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1051
shared repository: repo
1054
control: Meta directory format 1
1057
Create working tree for new branches inside the repository.
1062
""" % (format.repository_format.get_format_description(),
1064
self.assertEqual('', err)
1066
# Create branch in root of repository
1067
control = repo.bzrdir
1068
branch = control.create_branch()
1069
control.create_workingtree()
1070
out, err = self.run_bzr('info -v repo')
1071
self.assertEqualDiff(
1072
"""Repository tree (format: knit)
1074
shared repository: repo
1075
repository branch: repo
1078
control: Meta directory format 1
1079
working tree: Working tree format 3
1083
In the working tree:
1091
0 versioned subdirectories
1100
""" % (format.get_branch_format().get_format_description(),
1101
format.repository_format.get_format_description(),
1103
self.assertEqual('', err)
1105
def assertCheckoutStatusOutput(self,
1106
command_string, lco_tree, shared_repo=None,
1109
branch_locked=False, repo_locked=False,
1111
light_checkout=True,
1112
checkout_root=None):
1113
"""Check the output of info in a checkout.
1115
This is not quite a mirror of the info code: rather than using the
1116
tree being examined to predict output, it uses a bunch of flags which
1117
allow us, the test writers, to document what *should* be present in
1118
the output. Removing this separation would remove the value of the
1121
:param path: the path to the light checkout.
1122
:param lco_tree: the tree object for the light checkout.
1123
:param shared_repo: A shared repository is in use, expect that in
1125
:param repo_branch: A branch in a shared repository for non light
1127
:param tree_locked: If true, expect the tree to be locked.
1128
:param branch_locked: If true, expect the branch to be locked.
1129
:param repo_locked: If true, expect the repository to be locked.
1130
:param verbose: If true, expect verbose output
1132
def friendly_location(url):
1133
path = urlutils.unescape_for_display(url, 'ascii')
1135
return osutils.relpath(osutils.getcwd(), path)
1136
except errors.PathNotChild:
1139
if tree_locked and sys.platform == 'win32':
1140
# We expect this to fail because of locking errors. (A write-locked
1141
# file cannot be read-locked in the same process).
1142
# This should be removed when the locking errors are fixed.
1143
self.run_bzr_error([], 'info ' + command_string)
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 or knitpack-experimental',
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)