1
# Copyright (C) 2006 by Canonical Ltd
2
# -*- coding: utf-8 -*-
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
"""Tests for the info command of bzr."""
24
from bzrlib.osutils import format_date
25
from bzrlib.tests import TestSkipped
26
from bzrlib.tests.blackbox import ExternalBase
29
class TestInfo(ExternalBase):
31
def test_info_non_existing(self):
32
if sys.platform == "win32":
33
location = "C:/i/do/not/exist/"
35
location = "/i/do/not/exist/"
36
out, err = self.runbzr('info '+location, retcode=3)
37
self.assertEqual(out, '')
38
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
40
def test_info_standalone(self):
41
transport = self.get_transport()
43
# Create initial standalone branch
44
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
45
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
46
tree1 = self.make_branch_and_tree('standalone')
47
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
48
self.build_tree(['standalone/a'])
50
branch1 = tree1.branch
51
out, err = self.runbzr('info standalone')
57
control: All-in-one format 6
58
working tree: Working tree format 2
59
branch: Branch format 4
60
repository: Weave repository format 6
70
0 versioned subdirectories
78
""" % branch1.bzrdir.root_transport.base, out)
79
self.assertEqual('', err)
80
tree1.commit('commit one')
81
rev = branch1.repository.get_revision(branch1.revision_history()[0])
82
datestring_first = format_date(rev.timestamp, rev.timezone)
84
# Branch standalone with push location
85
branch2 = branch1.bzrdir.sprout('branch').open_branch()
86
branch2.set_push_location(branch1.bzrdir.root_transport.base)
87
out, err = self.runbzr('info branch --verbose')
97
control: All-in-one format 6
98
working tree: Working tree format 2
99
branch: Branch format 4
100
repository: Weave repository format 6
110
0 versioned subdirectories
122
""" % (branch2.bzrdir.root_transport.base,
123
branch1.bzrdir.root_transport.base,
124
branch1.bzrdir.root_transport.base,
125
datestring_first, datestring_first,
126
# poking at _revision_store isn't all that clean, but neither is
127
# having the ui test dependent on the exact overhead of a given store.
128
branch2.repository._revision_store.total_size(
129
branch2.repository.get_transaction())[1] / 1024,
131
self.assertEqual('', err)
133
# Branch and bind to standalone, needs upgrade to metadir
134
# (creates backup as unknown)
135
branch1.bzrdir.sprout('bound')
136
bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
137
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
138
branch3.bind(branch1)
139
bound_tree = branch3.bzrdir.open_workingtree()
140
out, err = self.runbzr('info bound')
141
self.assertEqualDiff(
144
checkout of branch: %s
150
control: Meta directory format 1
152
branch: Branch format 5
163
0 versioned subdirectories
174
""" % (branch3.bzrdir.root_transport.base,
175
branch1.bzrdir.root_transport.base,
176
branch1.bzrdir.root_transport.base,
177
bound_tree._format.get_format_description(),
178
branch3.repository._format.get_format_description(),
179
datestring_first, datestring_first,
180
# poking at _revision_store isn't all that clean, but neither is
181
# having the ui test dependent on the exact overhead of a given store.
182
branch3.repository._revision_store.total_size(
183
branch3.repository.get_transaction())[1] / 1024,
185
self.assertEqual('', err)
187
# Checkout standalone (same as above, but does not have parent set)
188
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
189
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
190
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout')
191
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
192
branch4.bind(branch1)
193
branch4.bzrdir.open_workingtree().update()
194
out, err = self.runbzr('info checkout --verbose')
195
self.assertEqualDiff(
198
checkout of branch: %s
201
control: Meta directory format 1
202
working tree: Working tree format 3
203
branch: Branch format 5
214
0 versioned subdirectories
226
""" % (branch4.bzrdir.root_transport.base,
227
branch1.bzrdir.root_transport.base,
228
branch4.repository._format.get_format_description(),
229
datestring_first, datestring_first,
230
# poking at _revision_store isn't all that clean, but neither is
231
# having the ui test dependent on the exact overhead of a given store.
232
branch4.repository._revision_store.total_size(
233
branch4.repository.get_transaction())[1] / 1024,
235
self.assertEqual('', err)
237
# Lightweight checkout (same as above, different branch and repository)
238
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
239
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
240
transport.mkdir('lightcheckout')
241
dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
242
bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
243
dir5.create_workingtree()
244
tree5 = dir5.open_workingtree()
245
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
246
branch5 = tree5.branch
247
out, err = self.runbzr('info lightcheckout')
248
self.assertEqualDiff(
250
light checkout root: %s
251
checkout of branch: %s
254
control: Meta directory format 1
255
working tree: Working tree format 3
256
branch: Branch format 4
257
repository: Weave repository format 6
267
0 versioned subdirectories
278
""" % (tree5.bzrdir.root_transport.base,
279
branch1.bzrdir.root_transport.base,
280
datestring_first, datestring_first,
282
self.assertEqual('', err)
284
# Update initial standalone branch
285
self.build_tree(['standalone/b'])
287
tree1.commit('commit two')
288
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
289
datestring_last = format_date(rev.timestamp, rev.timezone)
291
# Out of date branched standalone branch will not be detected
292
out, err = self.runbzr('info branch')
293
self.assertEqualDiff(
299
publish to branch: %s
302
control: All-in-one format 6
303
working tree: Working tree format 2
304
branch: Branch format 4
305
repository: Weave repository format 6
315
0 versioned subdirectories
326
""" % (branch2.bzrdir.root_transport.base,
327
branch1.bzrdir.root_transport.base,
328
branch1.bzrdir.root_transport.base,
329
datestring_first, datestring_first,
331
self.assertEqual('', err)
333
# Out of date bound branch
334
out, err = self.runbzr('info bound')
335
self.assertEqualDiff(
338
checkout of branch: %s
344
control: Meta directory format 1
345
working tree: Working tree format 3
346
branch: Branch format 5
349
Branch is out of date: missing 1 revision.
359
0 versioned subdirectories
370
""" % (branch3.bzrdir.root_transport.base,
371
branch1.bzrdir.root_transport.base,
372
branch1.bzrdir.root_transport.base,
373
branch3.repository._format.get_format_description(),
374
datestring_first, datestring_first,
375
# poking at _revision_store isn't all that clean, but neither is
376
# having the ui test dependent on the exact overhead of a given store.
377
branch3.repository._revision_store.total_size(
378
branch3.repository.get_transaction())[1] / 1024,
380
self.assertEqual('', err)
382
# Out of date checkout
383
out, err = self.runbzr('info checkout')
384
self.assertEqualDiff(
387
checkout of branch: %s
390
control: Meta directory format 1
391
working tree: Working tree format 3
392
branch: Branch format 5
395
Branch is out of date: missing 1 revision.
405
0 versioned subdirectories
416
""" % (branch4.bzrdir.root_transport.base,
417
branch1.bzrdir.root_transport.base,
418
branch4.repository._format.get_format_description(),
419
datestring_first, datestring_first,
420
# poking at _revision_store isn't all that clean, but neither is
421
# having the ui test dependent on the exact overhead of a given store.
422
branch4.repository._revision_store.total_size(
423
branch4.repository.get_transaction())[1] / 1024,
425
self.assertEqual('', err)
427
# Out of date lightweight checkout
428
out, err = self.runbzr('info lightcheckout --verbose')
429
self.assertEqualDiff(
431
light checkout root: %s
432
checkout of branch: %s
435
control: Meta directory format 1
436
working tree: Working tree format 3
437
branch: Branch format 4
438
repository: Weave repository format 6
440
Working tree is out of date: missing 1 revision.
450
0 versioned subdirectories
462
""" % (tree5.bzrdir.root_transport.base,
463
branch1.bzrdir.root_transport.base,
464
datestring_first, datestring_last,
466
self.assertEqual('', err)
468
def test_info_standalone_no_tree(self):
469
# create standalone branch without a working tree
470
branch = self.make_branch('branch')
471
repo = branch.repository
472
out, err = self.runbzr('info branch')
473
self.assertEqualDiff(
478
control: Meta directory format 1
479
branch: Branch format 5
488
""" % (branch.bzrdir.root_transport.base,
489
repo._format.get_format_description(),
491
self.assertEqual('', err)
493
def test_info_shared_repository(self):
494
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
495
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
496
transport = self.get_transport()
498
# Create shared repository
499
repo = self.make_repository('repo', shared=True)
500
repo.set_make_working_trees(False)
501
out, err = self.runbzr('info repo')
502
self.assertEqualDiff(
504
shared repository: %s
507
control: Meta directory format 1
513
""" % (repo.bzrdir.root_transport.base,
514
repo._format.get_format_description(),
516
self.assertEqual('', err)
518
# Create branch inside shared repository
519
repo.bzrdir.root_transport.mkdir('branch')
520
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
521
out, err = self.runbzr('info repo/branch')
522
self.assertEqualDiff(
524
shared repository: %s
525
repository branch: branch
528
control: Meta directory format 1
529
branch: Branch format 5
538
""" % (repo.bzrdir.root_transport.base,
539
repo._format.get_format_description(),
541
self.assertEqual('', err)
543
# Create lightweight checkout
544
transport.mkdir('tree')
545
transport.mkdir('tree/lightcheckout')
546
dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
547
bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
548
dir2.create_workingtree()
549
tree2 = dir2.open_workingtree()
550
branch2 = tree2.branch
551
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
553
# Create normal checkout
554
tree3 = branch1.create_checkout('tree/checkout')
555
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
557
light_checkout=False, repo_branch=branch1)
558
# Update lightweight checkout
559
self.build_tree(['tree/lightcheckout/a'])
561
tree2.commit('commit one')
562
rev = repo.get_revision(branch2.revision_history()[0])
563
datestring_first = format_date(rev.timestamp, rev.timezone)
564
out, err = self.runbzr('info tree/lightcheckout --verbose')
565
self.assertEqualDiff(
567
light checkout root: %s
568
shared repository: %s
569
repository branch: branch
572
control: Meta directory format 1
573
working tree: Working tree format 3
574
branch: Branch format 5
585
0 versioned subdirectories
597
""" % (tree2.bzrdir.root_transport.base,
598
repo.bzrdir.root_transport.base,
599
repo._format.get_format_description(),
600
datestring_first, datestring_first,
601
# poking at _revision_store isn't all that clean, but neither is
602
# having the ui test dependent on the exact overhead of a given store.
603
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
605
self.assertEqual('', err)
607
# Out of date checkout
608
out, err = self.runbzr('info tree/checkout')
609
self.assertEqualDiff(
612
checkout of branch: %s
615
control: Meta directory format 1
616
working tree: Working tree format 3
617
branch: Branch format 5
620
Branch is out of date: missing 1 revision.
630
0 versioned subdirectories
638
""" % (tree3.bzrdir.root_transport.base,
639
branch1.bzrdir.root_transport.base,
640
repo._format.get_format_description(),
642
self.assertEqual('', err)
646
self.build_tree(['tree/checkout/b'])
648
out, err = self.runbzr('info tree/checkout --verbose')
649
self.assertEqualDiff(
652
checkout of branch: %s
655
control: Meta directory format 1
656
working tree: Working tree format 3
657
branch: Branch format 5
668
0 versioned subdirectories
680
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
681
repo._format.get_format_description(),
682
datestring_first, datestring_first,
683
# poking at _revision_store isn't all that clean, but neither is
684
# having the ui test dependent on the exact overhead of a given store.
685
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
687
self.assertEqual('', err)
688
tree3.commit('commit two')
690
# Out of date lightweight checkout
691
rev = repo.get_revision(branch1.revision_history()[-1])
692
datestring_last = format_date(rev.timestamp, rev.timezone)
693
out, err = self.runbzr('info tree/lightcheckout --verbose')
694
self.assertEqualDiff(
696
light checkout root: %s
697
shared repository: %s
698
repository branch: branch
701
control: Meta directory format 1
702
working tree: Working tree format 3
703
branch: Branch format 5
706
Working tree is out of date: missing 1 revision.
716
0 versioned subdirectories
728
""" % (tree2.bzrdir.root_transport.base,
729
repo.bzrdir.root_transport.base,
730
repo._format.get_format_description(),
731
datestring_first, datestring_last,
732
# poking at _revision_store isn't all that clean, but neither is
733
# having the ui test dependent on the exact overhead of a given store.
734
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
736
self.assertEqual('', err)
738
# Show info about shared branch
739
out, err = self.runbzr('info repo/branch --verbose')
740
self.assertEqualDiff(
742
shared repository: %s
743
repository branch: branch
746
control: Meta directory format 1
747
branch: Branch format 5
760
""" % (repo.bzrdir.root_transport.base,
761
repo._format.get_format_description(),
762
datestring_first, datestring_last,
763
# poking at _revision_store isn't all that clean, but neither is
764
# having the ui test dependent on the exact overhead of a given store.
765
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
767
self.assertEqual('', err)
769
# Show info about repository with revisions
770
out, err = self.runbzr('info repo')
771
self.assertEqualDiff(
773
shared repository: %s
776
control: Meta directory format 1
782
""" % (repo.bzrdir.root_transport.base,
783
repo._format.get_format_description(),
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
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
792
def test_info_shared_repository_with_trees(self):
793
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
794
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
795
transport = self.get_transport()
797
# Create shared repository with working trees
798
repo = self.make_repository('repo', shared=True)
799
repo.set_make_working_trees(True)
800
out, err = self.runbzr('info repo')
801
self.assertEqualDiff(
803
shared repository: %s
806
control: Meta directory format 1
809
Create working tree for new branches inside the repository.
814
""" % (repo.bzrdir.root_transport.base,
815
repo._format.get_format_description(),
817
self.assertEqual('', err)
819
# Create two branches
820
repo.bzrdir.root_transport.mkdir('branch1')
821
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
822
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
825
out, err = self.runbzr('info repo/branch1 --verbose')
826
self.assertEqualDiff(
828
shared repository: %s
829
repository checkout: branch1
832
control: Meta directory format 1
833
working tree: Working tree format 3
834
branch: Branch format 5
845
0 versioned subdirectories
854
""" % (repo.bzrdir.root_transport.base,
855
repo._format.get_format_description(),
857
self.assertEqual('', err)
859
# Update first branch
860
self.build_tree(['repo/branch1/a'])
861
tree1 = branch1.bzrdir.open_workingtree()
863
tree1.commit('commit one')
864
rev = repo.get_revision(branch1.revision_history()[0])
865
datestring_first = format_date(rev.timestamp, rev.timezone)
866
out, err = self.runbzr('info repo/branch1')
867
self.assertEqualDiff(
869
shared repository: %s
870
repository checkout: branch1
873
control: Meta directory format 1
874
working tree: Working tree format 3
875
branch: Branch format 5
886
0 versioned subdirectories
897
""" % (repo.bzrdir.root_transport.base,
898
repo._format.get_format_description(),
899
datestring_first, datestring_first,
900
# poking at _revision_store isn't all that clean, but neither is
901
# having the ui test dependent on the exact overhead of a given store.
902
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
904
self.assertEqual('', err)
906
# Out of date second branch
907
out, err = self.runbzr('info repo/branch2 --verbose')
908
self.assertEqualDiff(
910
shared repository: %s
911
repository checkout: branch2
917
control: Meta directory format 1
918
working tree: Working tree format 3
919
branch: Branch format 5
930
0 versioned subdirectories
939
""" % (repo.bzrdir.root_transport.base,
940
branch1.bzrdir.root_transport.base,
941
repo._format.get_format_description(),
942
# poking at _revision_store isn't all that clean, but neither is
943
# having the ui test dependent on the exact overhead of a given store.
944
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
946
self.assertEqual('', err)
948
# Update second branch
949
tree2 = branch2.bzrdir.open_workingtree()
951
out, err = self.runbzr('info repo/branch2')
952
self.assertEqualDiff(
954
shared repository: %s
955
repository checkout: branch2
961
control: Meta directory format 1
962
working tree: Working tree format 3
963
branch: Branch format 5
974
0 versioned subdirectories
985
""" % (repo.bzrdir.root_transport.base,
986
branch1.bzrdir.root_transport.base,
987
repo._format.get_format_description(),
988
datestring_first, datestring_first,
989
# poking at _revision_store isn't all that clean, but neither is
990
# having the ui test dependent on the exact overhead of a given store.
991
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
993
self.assertEqual('', err)
995
# Show info about repository with revisions
996
out, err = self.runbzr('info repo')
997
self.assertEqualDiff(
999
shared repository: %s
1002
control: Meta directory format 1
1005
Create working tree for new branches inside the repository.
1010
""" % (repo.bzrdir.root_transport.base,
1011
repo._format.get_format_description(),
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,
1017
self.assertEqual('', err)
1019
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1021
def test_info_shared_repository_with_tree_in_root(self):
1022
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1023
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
1024
transport = self.get_transport()
1026
# Create shared repository with working trees
1027
repo = self.make_repository('repo', shared=True)
1028
repo.set_make_working_trees(True)
1029
out, err = self.runbzr('info repo')
1030
self.assertEqualDiff(
1032
shared repository: %s
1035
control: Meta directory format 1
1038
Create working tree for new branches inside the repository.
1043
""" % (repo.bzrdir.root_transport.base,
1044
repo._format.get_format_description(),
1046
self.assertEqual('', err)
1048
# Create branch in root of repository
1049
control = repo.bzrdir
1050
branch = control.create_branch()
1051
control.create_workingtree()
1052
out, err = self.runbzr('info repo')
1053
self.assertEqualDiff(
1055
shared repository: %s
1056
repository checkout: .
1059
control: Meta directory format 1
1060
working tree: Working tree format 3
1061
branch: Branch format 5
1064
In the working tree:
1072
0 versioned subdirectories
1080
""" % (repo.bzrdir.root_transport.base,
1081
repo._format.get_format_description(),
1083
self.assertEqual('', err)
1085
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1087
def assertCheckoutStatusOutput(self,
1088
command_string, lco_tree, shared_repo=None,
1091
branch_locked=False, repo_locked=False,
1093
light_checkout=True):
1094
"""Check the output of info in a light checkout tree.
1096
This is not quite a mirror of the info code: rather than using the
1097
tree being examined to predict output, it uses a bunch of flags which
1098
allow us, the test writers, to document what *should* be present in
1099
the output. Removing this separation would remove the value of the
1102
:param path: the path to the light checkout.
1103
:param lco_tree: the tree object for the light checkout.
1104
:param shared_repo: A shared repository is in use, expect that in
1106
:param repo_branch: A branch in a shared repository for non light
1108
:param tree_locked: If true, expect the tree to be locked.
1109
:param branch_locked: If true, expect the branch to be locked.
1110
:param repo_locked: If true, expect the repository to be locked.
1111
:param verbose: If true, expect verbose output
1113
out, err = self.runbzr('info %s' % command_string)
1114
if repo_locked or branch_locked or tree_locked:
1115
def locked_message(a_bool):
1120
expected_lock_output = (
1123
" working tree: %s\n"
1125
" repository: %s\n" % (
1126
locked_message(tree_locked),
1127
locked_message(branch_locked),
1128
locked_message(repo_locked)))
1130
expected_lock_output = ''
1132
tree_data = (" light checkout root: %s" %
1133
lco_tree.bzrdir.root_transport.base)
1135
tree_data = (" checkout root: %s" %
1136
lco_tree.bzrdir.root_transport.base)
1137
if shared_repo is not None:
1139
" shared repository: %s\n"
1140
" repository branch: branch\n" %
1141
shared_repo.bzrdir.root_transport.base)
1142
elif repo_branch is not None:
1144
" checkout of branch: %s\n" %
1145
repo_branch.bzrdir.root_transport.base)
1147
branch_data = (" checkout of branch: %s\n" %
1148
lco_tree.branch.bzrdir.root_transport.base)
1151
verbose_info = ' 0 committers\n'
1155
self.assertEqualDiff(
1160
control: Meta directory format 1
1162
branch: Branch format 5
1165
In the working tree:
1173
0 versioned subdirectories
1183
lco_tree._format.get_format_description(),
1184
lco_tree.branch.repository._format.get_format_description(),
1185
expected_lock_output,
1188
self.assertEqual('', err)
1190
def test_info_locking(self):
1191
transport = self.get_transport()
1192
# Create shared repository with a branch
1193
repo = self.make_repository('repo', shared=True,
1194
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1195
repo.set_make_working_trees(False)
1196
repo.bzrdir.root_transport.mkdir('branch')
1197
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1198
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1199
# Do a heavy checkout
1200
transport.mkdir('tree')
1201
transport.mkdir('tree/checkout')
1202
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1203
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1204
co_branch.bind(repo_branch)
1205
# Do a light checkout of the heavy one
1206
transport.mkdir('tree/lightcheckout')
1207
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1208
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1209
lco_dir.create_workingtree()
1210
lco_tree = lco_dir.open_workingtree()
1212
# Test all permutations of locking the working tree, branch and repository
1216
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1218
lco_tree.branch.repository.lock_write()
1220
self.assertCheckoutStatusOutput('tree/lightcheckout',
1224
lco_tree.branch.repository.unlock()
1226
lco_tree.branch.lock_write()
1228
self.assertCheckoutStatusOutput('tree/lightcheckout',
1233
lco_tree.branch.unlock()
1235
lco_tree.lock_write()
1237
self.assertCheckoutStatusOutput('tree/lightcheckout',
1245
lco_tree.lock_write()
1246
lco_tree.branch.repository.unlock()
1248
self.assertCheckoutStatusOutput('tree/lightcheckout',
1253
lco_tree.branch.repository.lock_write()
1256
lco_tree.lock_write()
1257
lco_tree.branch.unlock()
1259
self.assertCheckoutStatusOutput('tree/lightcheckout',
1263
lco_tree.branch.lock_write()
1266
lco_tree.lock_write()
1267
lco_tree.branch.unlock()
1268
lco_tree.branch.repository.lock_write()
1270
self.assertCheckoutStatusOutput('tree/lightcheckout',
1275
lco_tree.branch.repository.unlock()
1276
lco_tree.branch.lock_write()
1279
lco_tree.branch.lock_write()
1280
lco_tree.branch.repository.unlock()
1282
self.assertCheckoutStatusOutput('tree/lightcheckout',
1286
lco_tree.branch.repository.lock_write()
1287
lco_tree.branch.unlock()
1289
def test_info_locking_oslocks(self):
1290
if sys.platform == "win32":
1291
raise TestSkipped("don't use oslocks on win32 in unix manner")
1293
tree = self.make_branch_and_tree('branch',
1294
format=bzrlib.bzrdir.BzrDirFormat6())
1296
# Test all permutations of locking the working tree, branch and repository
1297
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1298
# implemented by raising NotImplementedError and get_physical_lock_status()
1299
# always returns false. This makes bzr info hide the lock status. (Olaf)
1303
out, err = self.runbzr('info branch')
1304
self.assertEqualDiff(
1309
control: All-in-one format 6
1310
working tree: Working tree format 2
1311
branch: Branch format 4
1314
In the working tree:
1322
0 versioned subdirectories
1330
""" % (tree.bzrdir.root_transport.base,
1331
tree.branch.repository._format.get_format_description(),
1333
self.assertEqual('', err)
1336
out, err = self.runbzr('info branch')
1337
self.assertEqualDiff(
1342
control: All-in-one format 6
1343
working tree: Working tree format 2
1344
branch: Branch format 4
1347
In the working tree:
1355
0 versioned subdirectories
1363
""" % (tree.bzrdir.root_transport.base,
1364
tree.branch.repository._format.get_format_description(),
1366
self.assertEqual('', err)