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 \
267
knitpack-experimental or rich-root)
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 \
446
knitpack-experimental or rich-root)
448
light checkout root: lightcheckout
449
checkout of branch: standalone
452
control: Meta directory format 1
453
working tree: Working tree format 4
454
branch: Branch format 4
455
repository: Weave repository format 6
457
Working tree is out of date: missing 1 revision.
467
0 versioned subdirectories
479
""" % (datestring_first, datestring_last,), out)
480
self.assertEqual('', err)
482
def test_info_standalone_no_tree(self):
483
# create standalone branch without a working tree
484
format = bzrdir.format_registry.make_bzrdir('default')
485
branch = self.make_branch('branch')
486
repo = branch.repository
487
out, err = self.run_bzr('info branch -v')
488
self.assertEqualDiff(
489
"""Standalone branch (format: dirstate-tags)
494
control: Meta directory format 1
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 \
585
knitpack-experimental or rich-root)
587
light checkout root: tree/lightcheckout
588
checkout of branch: repo/branch
589
shared repository: repo
592
control: Meta directory format 1
593
working tree: Working tree format 4
605
0 versioned subdirectories
617
""" % (format.get_branch_format().get_format_description(),
618
format.repository_format.get_format_description(),
619
datestring_first, datestring_first,
620
# poking at _revision_store isn't all that clean, but neither is
621
# having the ui test dependent on the exact overhead of a given store.
622
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
624
self.assertEqual('', err)
626
# Out of date checkout
627
out, err = self.run_bzr('info -v tree/checkout')
628
self.assertEqualDiff(
629
"""Checkout (format: dirstate)
631
checkout root: tree/checkout
632
checkout of branch: repo/branch
635
control: Meta directory format 1
636
working tree: Working tree format 4
640
Branch is out of date: missing 1 revision.
650
0 versioned subdirectories
659
""" % (format.get_branch_format().get_format_description(),
660
format.repository_format.get_format_description(),
662
self.assertEqual('', err)
666
self.build_tree(['tree/checkout/b'])
668
out, err = self.run_bzr('info tree/checkout --verbose')
669
self.assertEqualDiff(
670
"""Checkout (format: dirstate)
672
checkout root: tree/checkout
673
checkout of branch: repo/branch
676
control: Meta directory format 1
677
working tree: Working tree format 4
689
0 versioned subdirectories
701
""" % (format.get_branch_format().get_format_description(),
702
format.repository_format.get_format_description(),
703
datestring_first, datestring_first,
704
# poking at _revision_store isn't all that clean, but neither is
705
# having the ui test dependent on the exact overhead of a given store.
706
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
708
self.assertEqual('', err)
709
tree3.commit('commit two')
711
# Out of date lightweight checkout
712
rev = repo.get_revision(branch1.revision_history()[-1])
713
datestring_last = format_date(rev.timestamp, rev.timezone)
714
out, err = self.run_bzr('info tree/lightcheckout --verbose')
715
self.assertEqualDiff(
716
"""Lightweight checkout (format: dirstate or dirstate-tags or \
717
knitpack-experimental or rich-root)
719
light checkout root: tree/lightcheckout
720
checkout of branch: repo/branch
721
shared repository: repo
724
control: Meta directory format 1
725
working tree: Working tree format 4
729
Working tree is out of date: missing 1 revision.
739
0 versioned subdirectories
751
""" % (format.get_branch_format().get_format_description(),
752
format.repository_format.get_format_description(),
753
datestring_first, datestring_last,
754
# poking at _revision_store isn't all that clean, but neither is
755
# having the ui test dependent on the exact overhead of a given store.
756
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
758
self.assertEqual('', err)
760
# Show info about shared branch
761
out, err = self.run_bzr('info repo/branch --verbose')
762
self.assertEqualDiff(
763
"""Repository branch (format: dirstate or knit)
765
shared repository: repo
766
repository branch: repo/branch
769
control: Meta directory format 1
783
""" % (format.get_branch_format().get_format_description(),
784
format.repository_format.get_format_description(),
785
datestring_first, datestring_last,
786
# poking at _revision_store isn't all that clean, but neither is
787
# having the ui test dependent on the exact overhead of a given store.
788
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
790
self.assertEqual('', err)
792
# Show info about repository with revisions
793
out, err = self.run_bzr('info -v repo')
794
self.assertEqualDiff(
795
"""Shared repository (format: dirstate or dirstate-tags or knit)
797
shared repository: repo
800
control: Meta directory format 1
806
""" % (format.repository_format.get_format_description(),
807
# poking at _revision_store isn't all that clean, but neither is
808
# having the ui test dependent on the exact overhead of a given store.
809
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
811
self.assertEqual('', err)
813
def test_info_shared_repository_with_trees(self):
814
format = bzrdir.format_registry.make_bzrdir('knit')
815
transport = self.get_transport()
817
# Create shared repository with working trees
818
repo = self.make_repository('repo', shared=True, format=format)
819
repo.set_make_working_trees(True)
820
out, err = self.run_bzr('info -v repo')
821
self.assertEqualDiff(
822
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
824
shared repository: repo
827
control: Meta directory format 1
830
Create working tree for new branches inside the repository.
835
""" % (format.repository_format.get_format_description(),
837
self.assertEqual('', err)
839
# Create two branches
840
repo.bzrdir.root_transport.mkdir('branch1')
841
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
843
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
846
out, err = self.run_bzr('info repo/branch1 --verbose')
847
self.assertEqualDiff(
848
"""Repository tree (format: knit)
850
shared repository: repo
851
repository branch: repo/branch1
854
control: Meta directory format 1
855
working tree: Working tree format 3
867
0 versioned subdirectories
876
""" % (format.get_branch_format().get_format_description(),
877
format.repository_format.get_format_description(),
879
self.assertEqual('', err)
881
# Update first branch
882
self.build_tree(['repo/branch1/a'])
883
tree1 = branch1.bzrdir.open_workingtree()
885
tree1.commit('commit one')
886
rev = repo.get_revision(branch1.revision_history()[0])
887
datestring_first = format_date(rev.timestamp, rev.timezone)
888
out, err = self.run_bzr('info -v repo/branch1')
889
self.assertEqualDiff(
890
"""Repository tree (format: knit)
892
shared repository: repo
893
repository branch: repo/branch1
896
control: Meta directory format 1
897
working tree: Working tree format 3
909
0 versioned subdirectories
921
""" % (format.get_branch_format().get_format_description(),
922
format.repository_format.get_format_description(),
923
datestring_first, datestring_first,
924
# poking at _revision_store isn't all that clean, but neither is
925
# having the ui test dependent on the exact overhead of a given store.
926
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
928
self.assertEqual('', err)
930
# Out of date second branch
931
out, err = self.run_bzr('info repo/branch2 --verbose')
932
self.assertEqualDiff(
933
"""Repository tree (format: knit)
935
shared repository: repo
936
repository branch: repo/branch2
939
parent branch: repo/branch1
942
control: Meta directory format 1
943
working tree: Working tree format 3
955
0 versioned subdirectories
964
""" % (format.get_branch_format().get_format_description(),
965
format.repository_format.get_format_description(),
966
# poking at _revision_store isn't all that clean, but neither is
967
# having the ui test dependent on the exact overhead of a given store.
968
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
970
self.assertEqual('', err)
972
# Update second branch
973
tree2 = branch2.bzrdir.open_workingtree()
975
out, err = self.run_bzr('info -v repo/branch2')
976
self.assertEqualDiff(
977
"""Repository tree (format: knit)
979
shared repository: repo
980
repository branch: repo/branch2
983
parent branch: repo/branch1
986
control: Meta directory format 1
987
working tree: Working tree format 3
999
0 versioned subdirectories
1011
""" % (format.get_branch_format().get_format_description(),
1012
format.repository_format.get_format_description(),
1013
datestring_first, datestring_first,
1014
# poking at _revision_store isn't all that clean, but neither is
1015
# having the ui test dependent on the exact overhead of a given store.
1016
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1018
self.assertEqual('', err)
1020
# Show info about repository with revisions
1021
out, err = self.run_bzr('info -v repo')
1022
self.assertEqualDiff(
1023
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1025
shared repository: repo
1028
control: Meta directory format 1
1031
Create working tree for new branches inside the repository.
1036
""" % (format.repository_format.get_format_description(),
1037
# poking at _revision_store isn't all that clean, but neither is
1038
# having the ui test dependent on the exact overhead of a given store.
1039
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1042
self.assertEqual('', err)
1044
def test_info_shared_repository_with_tree_in_root(self):
1045
format = bzrdir.format_registry.make_bzrdir('knit')
1046
transport = self.get_transport()
1048
# Create shared repository with working trees
1049
repo = self.make_repository('repo', shared=True, format=format)
1050
repo.set_make_working_trees(True)
1051
out, err = self.run_bzr('info -v repo')
1052
self.assertEqualDiff(
1053
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1055
shared repository: repo
1058
control: Meta directory format 1
1061
Create working tree for new branches inside the repository.
1066
""" % (format.repository_format.get_format_description(),
1068
self.assertEqual('', err)
1070
# Create branch in root of repository
1071
control = repo.bzrdir
1072
branch = control.create_branch()
1073
control.create_workingtree()
1074
out, err = self.run_bzr('info -v repo')
1075
self.assertEqualDiff(
1076
"""Repository tree (format: knit)
1078
shared repository: repo
1079
repository branch: repo
1082
control: Meta directory format 1
1083
working tree: Working tree format 3
1087
In the working tree:
1095
0 versioned subdirectories
1104
""" % (format.get_branch_format().get_format_description(),
1105
format.repository_format.get_format_description(),
1107
self.assertEqual('', err)
1109
def assertCheckoutStatusOutput(self,
1110
command_string, lco_tree, shared_repo=None,
1113
branch_locked=False, repo_locked=False,
1115
light_checkout=True,
1116
checkout_root=None):
1117
"""Check the output of info in a checkout.
1119
This is not quite a mirror of the info code: rather than using the
1120
tree being examined to predict output, it uses a bunch of flags which
1121
allow us, the test writers, to document what *should* be present in
1122
the output. Removing this separation would remove the value of the
1125
:param path: the path to the light checkout.
1126
:param lco_tree: the tree object for the light checkout.
1127
:param shared_repo: A shared repository is in use, expect that in
1129
:param repo_branch: A branch in a shared repository for non light
1131
:param tree_locked: If true, expect the tree to be locked.
1132
:param branch_locked: If true, expect the branch to be locked.
1133
:param repo_locked: If true, expect the repository to be locked.
1134
:param verbose: If true, expect verbose output
1136
def friendly_location(url):
1137
path = urlutils.unescape_for_display(url, 'ascii')
1139
return osutils.relpath(osutils.getcwd(), path)
1140
except errors.PathNotChild:
1143
if tree_locked and sys.platform == 'win32':
1144
# We expect this to fail because of locking errors. (A write-locked
1145
# file cannot be read-locked in the same process).
1146
# This should be removed when the locking errors are fixed.
1147
self.run_bzr_error([], 'info ' + command_string)
1149
out, err = self.run_bzr('info %s' % command_string)
1151
(True, True): 'Lightweight checkout',
1152
(True, False): 'Repository checkout',
1153
(False, True): 'Lightweight checkout',
1154
(False, False): 'Checkout',
1155
}[(shared_repo is not None, light_checkout)]
1156
format = {True: 'dirstate or dirstate-tags or knitpack-experimental'
1158
False: 'dirstate'}[light_checkout]
1159
if repo_locked or branch_locked or tree_locked:
1160
def locked_message(a_bool):
1165
expected_lock_output = (
1168
" working tree: %s\n"
1170
" repository: %s\n" % (
1171
locked_message(tree_locked),
1172
locked_message(branch_locked),
1173
locked_message(repo_locked)))
1175
expected_lock_output = ''
1179
tree_data = (" light checkout root: %s\n" %
1180
friendly_location(lco_tree.bzrdir.root_transport.base))
1182
if lco_tree.branch.get_bound_location() is not None:
1183
tree_data += ("%s checkout root: %s\n" % (extra_space,
1184
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1185
if shared_repo is not None:
1187
" checkout of branch: %s\n"
1188
" shared repository: %s\n" %
1189
(friendly_location(repo_branch.bzrdir.root_transport.base),
1190
friendly_location(shared_repo.bzrdir.root_transport.base)))
1191
elif repo_branch is not None:
1193
"%s checkout of branch: %s\n" %
1195
friendly_location(repo_branch.bzrdir.root_transport.base)))
1197
branch_data = (" checkout of branch: %s\n" %
1198
lco_tree.branch.bzrdir.root_transport.base)
1201
verbose_info = ' 0 committers\n'
1205
self.assertEqualDiff(
1210
control: Meta directory format 1
1215
In the working tree:
1223
0 versioned subdirectories
1235
lco_tree._format.get_format_description(),
1236
lco_tree.branch._format.get_format_description(),
1237
lco_tree.branch.repository._format.get_format_description(),
1238
expected_lock_output,
1241
self.assertEqual('', err)
1243
def test_info_locking(self):
1244
transport = self.get_transport()
1245
# Create shared repository with a branch
1246
repo = self.make_repository('repo', shared=True,
1247
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1248
repo.set_make_working_trees(False)
1249
repo.bzrdir.root_transport.mkdir('branch')
1250
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1251
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1252
# Do a heavy checkout
1253
transport.mkdir('tree')
1254
transport.mkdir('tree/checkout')
1255
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1256
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1257
co_branch.bind(repo_branch)
1258
# Do a light checkout of the heavy one
1259
transport.mkdir('tree/lightcheckout')
1260
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1261
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1262
lco_dir.create_workingtree()
1263
lco_tree = lco_dir.open_workingtree()
1265
# Test all permutations of locking the working tree, branch and repository
1269
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1270
repo_branch=repo_branch,
1271
verbose=True, light_checkout=True)
1273
lco_tree.branch.repository.lock_write()
1275
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1276
lco_tree, repo_branch=repo_branch,
1277
repo_locked=True, verbose=True, light_checkout=True)
1279
lco_tree.branch.repository.unlock()
1281
lco_tree.branch.lock_write()
1283
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1287
repo_branch=repo_branch,
1290
lco_tree.branch.unlock()
1292
lco_tree.lock_write()
1294
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1295
lco_tree, repo_branch=repo_branch,
1303
lco_tree.lock_write()
1304
lco_tree.branch.repository.unlock()
1306
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1307
lco_tree, repo_branch=repo_branch,
1312
lco_tree.branch.repository.lock_write()
1315
lco_tree.lock_write()
1316
lco_tree.branch.unlock()
1318
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1319
lco_tree, repo_branch=repo_branch,
1323
lco_tree.branch.lock_write()
1326
lco_tree.lock_write()
1327
lco_tree.branch.unlock()
1328
lco_tree.branch.repository.lock_write()
1330
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1331
lco_tree, repo_branch=repo_branch,
1336
lco_tree.branch.repository.unlock()
1337
lco_tree.branch.lock_write()
1340
lco_tree.branch.lock_write()
1341
lco_tree.branch.repository.unlock()
1343
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1344
lco_tree, repo_branch=repo_branch,
1348
lco_tree.branch.repository.lock_write()
1349
lco_tree.branch.unlock()
1351
if sys.platform == 'win32':
1352
self.knownFailure('Win32 cannot run "bzr info"'
1353
' when the tree is locked.')
1355
def test_info_locking_oslocks(self):
1356
if sys.platform == "win32":
1357
raise TestSkipped("don't use oslocks on win32 in unix manner")
1359
tree = self.make_branch_and_tree('branch',
1360
format=bzrlib.bzrdir.BzrDirFormat6())
1362
# Test all permutations of locking the working tree, branch and repository
1363
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1364
# implemented by raising NotImplementedError and get_physical_lock_status()
1365
# always returns false. This makes bzr info hide the lock status. (Olaf)
1369
out, err = self.run_bzr('info -v branch')
1370
self.assertEqualDiff(
1371
"""Standalone tree (format: weave)
1376
control: All-in-one format 6
1377
working tree: Working tree format 2
1378
branch: Branch format 4
1381
In the working tree:
1389
0 versioned subdirectories
1398
""" % ('branch', tree.branch.repository._format.get_format_description(),
1400
self.assertEqual('', err)
1403
out, err = self.run_bzr('info -v branch')
1404
self.assertEqualDiff(
1405
"""Standalone tree (format: weave)
1410
control: All-in-one format 6
1411
working tree: Working tree format 2
1412
branch: Branch format 4
1415
In the working tree:
1423
0 versioned subdirectories
1432
""" % ('branch', tree.branch.repository._format.get_format_description(),
1434
self.assertEqual('', err)