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
branch3 = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout')
555
branch3.bind(branch1)
556
tree3 = branch3.bzrdir.open_workingtree()
558
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
560
light_checkout=False, repo_branch=branch1)
561
# Update lightweight checkout
562
self.build_tree(['tree/lightcheckout/a'])
564
tree2.commit('commit one')
565
rev = repo.get_revision(branch2.revision_history()[0])
566
datestring_first = format_date(rev.timestamp, rev.timezone)
567
out, err = self.runbzr('info tree/lightcheckout --verbose')
568
self.assertEqualDiff(
570
light checkout root: %s
571
shared repository: %s
572
repository branch: branch
575
control: Meta directory format 1
576
working tree: Working tree format 3
577
branch: Branch format 5
588
0 versioned subdirectories
600
""" % (tree2.bzrdir.root_transport.base,
601
repo.bzrdir.root_transport.base,
602
repo._format.get_format_description(),
603
datestring_first, datestring_first,
604
# poking at _revision_store isn't all that clean, but neither is
605
# having the ui test dependent on the exact overhead of a given store.
606
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
608
self.assertEqual('', err)
610
# Out of date checkout
611
out, err = self.runbzr('info tree/checkout')
612
self.assertEqualDiff(
615
checkout of branch: %s
618
control: Meta directory format 1
619
working tree: Working tree format 3
620
branch: Branch format 5
623
Branch is out of date: missing 1 revision.
633
0 versioned subdirectories
641
""" % (tree3.bzrdir.root_transport.base,
642
branch1.bzrdir.root_transport.base,
643
repo._format.get_format_description(),
645
self.assertEqual('', err)
649
self.build_tree(['tree/checkout/b'])
651
out, err = self.runbzr('info tree/checkout --verbose')
652
self.assertEqualDiff(
655
checkout of branch: %s
658
control: Meta directory format 1
659
working tree: Working tree format 3
660
branch: Branch format 5
671
0 versioned subdirectories
683
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
684
repo._format.get_format_description(),
685
datestring_first, datestring_first,
686
# poking at _revision_store isn't all that clean, but neither is
687
# having the ui test dependent on the exact overhead of a given store.
688
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
690
self.assertEqual('', err)
691
tree3.commit('commit two')
693
# Out of date lightweight checkout
694
rev = repo.get_revision(branch1.revision_history()[-1])
695
datestring_last = format_date(rev.timestamp, rev.timezone)
696
out, err = self.runbzr('info tree/lightcheckout --verbose')
697
self.assertEqualDiff(
699
light checkout root: %s
700
shared repository: %s
701
repository branch: branch
704
control: Meta directory format 1
705
working tree: Working tree format 3
706
branch: Branch format 5
709
Working tree is out of date: missing 1 revision.
719
0 versioned subdirectories
731
""" % (tree2.bzrdir.root_transport.base,
732
repo.bzrdir.root_transport.base,
733
repo._format.get_format_description(),
734
datestring_first, datestring_last,
735
# poking at _revision_store isn't all that clean, but neither is
736
# having the ui test dependent on the exact overhead of a given store.
737
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
739
self.assertEqual('', err)
741
# Show info about shared branch
742
out, err = self.runbzr('info repo/branch --verbose')
743
self.assertEqualDiff(
745
shared repository: %s
746
repository branch: branch
749
control: Meta directory format 1
750
branch: Branch format 5
763
""" % (repo.bzrdir.root_transport.base,
764
repo._format.get_format_description(),
765
datestring_first, datestring_last,
766
# poking at _revision_store isn't all that clean, but neither is
767
# having the ui test dependent on the exact overhead of a given store.
768
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
770
self.assertEqual('', err)
772
# Show info about repository with revisions
773
out, err = self.runbzr('info repo')
774
self.assertEqualDiff(
776
shared repository: %s
779
control: Meta directory format 1
785
""" % (repo.bzrdir.root_transport.base,
786
repo._format.get_format_description(),
787
# poking at _revision_store isn't all that clean, but neither is
788
# having the ui test dependent on the exact overhead of a given store.
789
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
791
self.assertEqual('', err)
793
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
795
def test_info_shared_repository_with_trees(self):
796
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
797
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
798
transport = self.get_transport()
800
# Create shared repository with working trees
801
repo = self.make_repository('repo', shared=True)
802
repo.set_make_working_trees(True)
803
out, err = self.runbzr('info repo')
804
self.assertEqualDiff(
806
shared repository: %s
809
control: Meta directory format 1
812
Create working tree for new branches inside the repository.
817
""" % (repo.bzrdir.root_transport.base,
818
repo._format.get_format_description(),
820
self.assertEqual('', err)
822
# Create two branches
823
repo.bzrdir.root_transport.mkdir('branch1')
824
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
825
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
828
out, err = self.runbzr('info repo/branch1 --verbose')
829
self.assertEqualDiff(
831
shared repository: %s
832
repository checkout: branch1
835
control: Meta directory format 1
836
working tree: Working tree format 3
837
branch: Branch format 5
848
0 versioned subdirectories
857
""" % (repo.bzrdir.root_transport.base,
858
repo._format.get_format_description(),
860
self.assertEqual('', err)
862
# Update first branch
863
self.build_tree(['repo/branch1/a'])
864
tree1 = branch1.bzrdir.open_workingtree()
866
tree1.commit('commit one')
867
rev = repo.get_revision(branch1.revision_history()[0])
868
datestring_first = format_date(rev.timestamp, rev.timezone)
869
out, err = self.runbzr('info repo/branch1')
870
self.assertEqualDiff(
872
shared repository: %s
873
repository checkout: branch1
876
control: Meta directory format 1
877
working tree: Working tree format 3
878
branch: Branch format 5
889
0 versioned subdirectories
900
""" % (repo.bzrdir.root_transport.base,
901
repo._format.get_format_description(),
902
datestring_first, datestring_first,
903
# poking at _revision_store isn't all that clean, but neither is
904
# having the ui test dependent on the exact overhead of a given store.
905
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
907
self.assertEqual('', err)
909
# Out of date second branch
910
out, err = self.runbzr('info repo/branch2 --verbose')
911
self.assertEqualDiff(
913
shared repository: %s
914
repository checkout: branch2
920
control: Meta directory format 1
921
working tree: Working tree format 3
922
branch: Branch format 5
933
0 versioned subdirectories
942
""" % (repo.bzrdir.root_transport.base,
943
branch1.bzrdir.root_transport.base,
944
repo._format.get_format_description(),
945
# poking at _revision_store isn't all that clean, but neither is
946
# having the ui test dependent on the exact overhead of a given store.
947
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
949
self.assertEqual('', err)
951
# Update second branch
952
tree2 = branch2.bzrdir.open_workingtree()
954
out, err = self.runbzr('info repo/branch2')
955
self.assertEqualDiff(
957
shared repository: %s
958
repository checkout: branch2
964
control: Meta directory format 1
965
working tree: Working tree format 3
966
branch: Branch format 5
977
0 versioned subdirectories
988
""" % (repo.bzrdir.root_transport.base,
989
branch1.bzrdir.root_transport.base,
990
repo._format.get_format_description(),
991
datestring_first, datestring_first,
992
# poking at _revision_store isn't all that clean, but neither is
993
# having the ui test dependent on the exact overhead of a given store.
994
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
996
self.assertEqual('', err)
998
# Show info about repository with revisions
999
out, err = self.runbzr('info repo')
1000
self.assertEqualDiff(
1002
shared repository: %s
1005
control: Meta directory format 1
1008
Create working tree for new branches inside the repository.
1013
""" % (repo.bzrdir.root_transport.base,
1014
repo._format.get_format_description(),
1015
# poking at _revision_store isn't all that clean, but neither is
1016
# having the ui test dependent on the exact overhead of a given store.
1017
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1020
self.assertEqual('', err)
1022
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1024
def test_info_shared_repository_with_tree_in_root(self):
1025
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1026
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
1027
transport = self.get_transport()
1029
# Create shared repository with working trees
1030
repo = self.make_repository('repo', shared=True)
1031
repo.set_make_working_trees(True)
1032
out, err = self.runbzr('info repo')
1033
self.assertEqualDiff(
1035
shared repository: %s
1038
control: Meta directory format 1
1041
Create working tree for new branches inside the repository.
1046
""" % (repo.bzrdir.root_transport.base,
1047
repo._format.get_format_description(),
1049
self.assertEqual('', err)
1051
# Create branch in root of repository
1052
control = repo.bzrdir
1053
branch = control.create_branch()
1054
control.create_workingtree()
1055
out, err = self.runbzr('info repo')
1056
self.assertEqualDiff(
1058
shared repository: %s
1059
repository checkout: .
1062
control: Meta directory format 1
1063
working tree: Working tree format 3
1064
branch: Branch format 5
1067
In the working tree:
1075
0 versioned subdirectories
1083
""" % (repo.bzrdir.root_transport.base,
1084
repo._format.get_format_description(),
1086
self.assertEqual('', err)
1088
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1090
def assertCheckoutStatusOutput(self,
1091
command_string, lco_tree, shared_repo=None,
1094
branch_locked=False, repo_locked=False,
1096
light_checkout=True):
1097
"""Check the output of info in a light checkout tree.
1099
This is not quite a mirror of the info code: rather than using the
1100
tree being examined to predict output, it uses a bunch of flags which
1101
allow us, the test writers, to document what *should* be present in
1102
the output. Removing this separation would remove the value of the
1105
:param path: the path to the light checkout.
1106
:param lco_tree: the tree object for the light checkout.
1107
:param shared_repo: A shared repository is in use, expect that in
1109
:param repo_branch: A branch in a shared repository for non light
1111
:param tree_locked: If true, expect the tree to be locked.
1112
:param branch_locked: If true, expect the branch to be locked.
1113
:param repo_locked: If true, expect the repository to be locked.
1114
:param verbose: If true, expect verbose output
1116
out, err = self.runbzr('info %s' % command_string)
1117
if repo_locked or branch_locked or tree_locked:
1118
def locked_message(a_bool):
1123
expected_lock_output = (
1126
" working tree: %s\n"
1128
" repository: %s\n" % (
1129
locked_message(tree_locked),
1130
locked_message(branch_locked),
1131
locked_message(repo_locked)))
1133
expected_lock_output = ''
1135
tree_data = (" light checkout root: %s" %
1136
lco_tree.bzrdir.root_transport.base)
1138
tree_data = (" checkout root: %s" %
1139
lco_tree.bzrdir.root_transport.base)
1140
if shared_repo is not None:
1142
" shared repository: %s\n"
1143
" repository branch: branch\n" %
1144
shared_repo.bzrdir.root_transport.base)
1145
elif repo_branch is not None:
1147
" checkout of branch: %s\n" %
1148
repo_branch.bzrdir.root_transport.base)
1150
branch_data = (" checkout of branch: %s\n" %
1151
lco_tree.branch.bzrdir.root_transport.base)
1154
verbose_info = ' 0 committers\n'
1158
self.assertEqualDiff(
1163
control: Meta directory format 1
1165
branch: Branch format 5
1168
In the working tree:
1176
0 versioned subdirectories
1186
lco_tree._format.get_format_description(),
1187
lco_tree.branch.repository._format.get_format_description(),
1188
expected_lock_output,
1191
self.assertEqual('', err)
1193
def test_info_locking(self):
1194
transport = self.get_transport()
1195
# Create shared repository with a branch
1196
repo = self.make_repository('repo', shared=True,
1197
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1198
repo.set_make_working_trees(False)
1199
repo.bzrdir.root_transport.mkdir('branch')
1200
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1201
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1202
# Do a heavy checkout
1203
transport.mkdir('tree')
1204
transport.mkdir('tree/checkout')
1205
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1206
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1207
co_branch.bind(repo_branch)
1208
# Do a light checkout of the heavy one
1209
transport.mkdir('tree/lightcheckout')
1210
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1211
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1212
lco_dir.create_workingtree()
1213
lco_tree = lco_dir.open_workingtree()
1215
# Test all permutations of locking the working tree, branch and repository
1219
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1221
lco_tree.branch.repository.lock_write()
1223
self.assertCheckoutStatusOutput('tree/lightcheckout',
1227
lco_tree.branch.repository.unlock()
1229
lco_tree.branch.lock_write()
1231
self.assertCheckoutStatusOutput('tree/lightcheckout',
1236
lco_tree.branch.unlock()
1238
lco_tree.lock_write()
1240
self.assertCheckoutStatusOutput('tree/lightcheckout',
1248
lco_tree.lock_write()
1249
lco_tree.branch.repository.unlock()
1251
self.assertCheckoutStatusOutput('tree/lightcheckout',
1256
lco_tree.branch.repository.lock_write()
1259
lco_tree.lock_write()
1260
lco_tree.branch.unlock()
1262
self.assertCheckoutStatusOutput('tree/lightcheckout',
1266
lco_tree.branch.lock_write()
1269
lco_tree.lock_write()
1270
lco_tree.branch.unlock()
1271
lco_tree.branch.repository.lock_write()
1273
self.assertCheckoutStatusOutput('tree/lightcheckout',
1278
lco_tree.branch.repository.unlock()
1279
lco_tree.branch.lock_write()
1282
lco_tree.branch.lock_write()
1283
lco_tree.branch.repository.unlock()
1285
self.assertCheckoutStatusOutput('tree/lightcheckout',
1289
lco_tree.branch.repository.lock_write()
1290
lco_tree.branch.unlock()
1292
def test_info_locking_oslocks(self):
1293
if sys.platform == "win32":
1294
raise TestSkipped("don't use oslocks on win32 in unix manner")
1296
tree = self.make_branch_and_tree('branch',
1297
format=bzrlib.bzrdir.BzrDirFormat6())
1299
# Test all permutations of locking the working tree, branch and repository
1300
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1301
# implemented by raising NotImplementedError and get_physical_lock_status()
1302
# always returns false. This makes bzr info hide the lock status. (Olaf)
1306
out, err = self.runbzr('info branch')
1307
self.assertEqualDiff(
1312
control: All-in-one format 6
1313
working tree: Working tree format 2
1314
branch: Branch format 4
1317
In the working tree:
1325
0 versioned subdirectories
1333
""" % (tree.bzrdir.root_transport.base,
1334
tree.branch.repository._format.get_format_description(),
1336
self.assertEqual('', err)
1339
out, err = self.runbzr('info branch')
1340
self.assertEqualDiff(
1345
control: All-in-one format 6
1346
working tree: Working tree format 2
1347
branch: Branch format 4
1350
In the working tree:
1358
0 versioned subdirectories
1366
""" % (tree.bzrdir.root_transport.base,
1367
tree.branch.repository._format.get_format_description(),
1369
self.assertEqual('', err)