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 import repository
25
from bzrlib.osutils import format_date
26
from bzrlib.tests import TestSkipped
27
from bzrlib.tests.blackbox import ExternalBase
30
class TestInfo(ExternalBase):
32
def test_info_non_existing(self):
33
if sys.platform == "win32":
34
location = "C:/i/do/not/exist/"
36
location = "/i/do/not/exist/"
37
out, err = self.runbzr('info '+location, retcode=3)
38
self.assertEqual(out, '')
39
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
41
def test_info_standalone(self):
42
transport = self.get_transport()
44
# Create initial standalone branch
45
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
46
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
47
tree1 = self.make_branch_and_tree('standalone')
48
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
49
self.build_tree(['standalone/a'])
51
branch1 = tree1.branch
52
out, err = self.runbzr('info standalone')
58
control: All-in-one format 6
59
working tree: Working tree format 2
60
branch: Branch format 4
61
repository: Weave repository format 6
71
0 versioned subdirectories
79
""" % branch1.bzrdir.root_transport.base, out)
80
self.assertEqual('', err)
81
tree1.commit('commit one')
82
rev = branch1.repository.get_revision(branch1.revision_history()[0])
83
datestring_first = format_date(rev.timestamp, rev.timezone)
85
# Branch standalone with push location
86
branch2 = branch1.bzrdir.sprout('branch').open_branch()
87
branch2.set_push_location(branch1.bzrdir.root_transport.base)
88
out, err = self.runbzr('info branch --verbose')
98
control: All-in-one format 6
99
working tree: Working tree format 2
100
branch: Branch format 4
101
repository: Weave repository format 6
111
0 versioned subdirectories
123
""" % (branch2.bzrdir.root_transport.base,
124
branch1.bzrdir.root_transport.base,
125
branch1.bzrdir.root_transport.base,
126
datestring_first, datestring_first,
127
# poking at _revision_store isn't all that clean, but neither is
128
# having the ui test dependent on the exact overhead of a given store.
129
branch2.repository._revision_store.total_size(
130
branch2.repository.get_transaction())[1] / 1024,
132
self.assertEqual('', err)
134
# Branch and bind to standalone, needs upgrade to metadir
135
# (creates backup as unknown)
136
branch1.bzrdir.sprout('bound')
137
knit1_format = bzrlib.bzrdir.BzrDirMetaFormat1()
138
knit1_format.repository_format = repository.RepositoryFormatKnit1()
139
bzrlib.upgrade.upgrade('bound', knit1_format)
140
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
141
branch3.bind(branch1)
142
bound_tree = branch3.bzrdir.open_workingtree()
143
out, err = self.runbzr('info bound')
144
self.assertEqualDiff(
147
checkout of branch: %s
153
control: Meta directory format 1
155
branch: Branch format 5
166
0 versioned subdirectories
177
""" % (branch3.bzrdir.root_transport.base,
178
branch1.bzrdir.root_transport.base,
179
branch1.bzrdir.root_transport.base,
180
bound_tree._format.get_format_description(),
181
branch3.repository._format.get_format_description(),
182
datestring_first, datestring_first,
183
# poking at _revision_store isn't all that clean, but neither is
184
# having the ui test dependent on the exact overhead of a given store.
185
branch3.repository._revision_store.total_size(
186
branch3.repository.get_transaction())[1] / 1024,
188
self.assertEqual('', err)
190
# Checkout standalone (same as above, but does not have parent set)
191
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
192
bzrlib.bzrdir.BzrDirFormat.set_default_format(knit1_format)
193
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout')
194
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
195
branch4.bind(branch1)
196
branch4.bzrdir.open_workingtree().update()
197
out, err = self.runbzr('info checkout --verbose')
198
self.assertEqualDiff(
201
checkout of branch: %s
204
control: Meta directory format 1
205
working tree: Working tree format 3
206
branch: Branch format 5
217
0 versioned subdirectories
229
""" % (branch4.bzrdir.root_transport.base,
230
branch1.bzrdir.root_transport.base,
231
branch4.repository._format.get_format_description(),
232
datestring_first, datestring_first,
233
# poking at _revision_store isn't all that clean, but neither is
234
# having the ui test dependent on the exact overhead of a given store.
235
branch4.repository._revision_store.total_size(
236
branch4.repository.get_transaction())[1] / 1024,
238
self.assertEqual('', err)
240
# Lightweight checkout (same as above, different branch and repository)
241
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
242
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
243
transport.mkdir('lightcheckout')
244
dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
245
bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
246
dir5.create_workingtree()
247
tree5 = dir5.open_workingtree()
248
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
249
branch5 = tree5.branch
250
out, err = self.runbzr('info lightcheckout')
251
self.assertEqualDiff(
253
light checkout root: %s
254
checkout of branch: %s
257
control: Meta directory format 1
258
working tree: Working tree format 3
259
branch: Branch format 4
260
repository: Weave repository format 6
270
0 versioned subdirectories
281
""" % (tree5.bzrdir.root_transport.base,
282
branch1.bzrdir.root_transport.base,
283
datestring_first, datestring_first,
285
self.assertEqual('', err)
287
# Update initial standalone branch
288
self.build_tree(['standalone/b'])
290
tree1.commit('commit two')
291
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
292
datestring_last = format_date(rev.timestamp, rev.timezone)
294
# Out of date branched standalone branch will not be detected
295
out, err = self.runbzr('info branch')
296
self.assertEqualDiff(
302
publish to branch: %s
305
control: All-in-one format 6
306
working tree: Working tree format 2
307
branch: Branch format 4
308
repository: Weave repository format 6
318
0 versioned subdirectories
329
""" % (branch2.bzrdir.root_transport.base,
330
branch1.bzrdir.root_transport.base,
331
branch1.bzrdir.root_transport.base,
332
datestring_first, datestring_first,
334
self.assertEqual('', err)
336
# Out of date bound branch
337
out, err = self.runbzr('info bound')
338
self.assertEqualDiff(
341
checkout of branch: %s
347
control: Meta directory format 1
348
working tree: Working tree format 3
349
branch: Branch format 5
352
Branch is out of date: missing 1 revision.
362
0 versioned subdirectories
373
""" % (branch3.bzrdir.root_transport.base,
374
branch1.bzrdir.root_transport.base,
375
branch1.bzrdir.root_transport.base,
376
branch3.repository._format.get_format_description(),
377
datestring_first, datestring_first,
378
# poking at _revision_store isn't all that clean, but neither is
379
# having the ui test dependent on the exact overhead of a given store.
380
branch3.repository._revision_store.total_size(
381
branch3.repository.get_transaction())[1] / 1024,
383
self.assertEqual('', err)
385
# Out of date checkout
386
out, err = self.runbzr('info checkout')
387
self.assertEqualDiff(
390
checkout of branch: %s
393
control: Meta directory format 1
394
working tree: Working tree format 3
395
branch: Branch format 5
398
Branch is out of date: missing 1 revision.
408
0 versioned subdirectories
419
""" % (branch4.bzrdir.root_transport.base,
420
branch1.bzrdir.root_transport.base,
421
branch4.repository._format.get_format_description(),
422
datestring_first, datestring_first,
423
# poking at _revision_store isn't all that clean, but neither is
424
# having the ui test dependent on the exact overhead of a given store.
425
branch4.repository._revision_store.total_size(
426
branch4.repository.get_transaction())[1] / 1024,
428
self.assertEqual('', err)
430
# Out of date lightweight checkout
431
out, err = self.runbzr('info lightcheckout --verbose')
432
self.assertEqualDiff(
434
light checkout root: %s
435
checkout of branch: %s
438
control: Meta directory format 1
439
working tree: Working tree format 3
440
branch: Branch format 4
441
repository: Weave repository format 6
443
Working tree is out of date: missing 1 revision.
453
0 versioned subdirectories
465
""" % (tree5.bzrdir.root_transport.base,
466
branch1.bzrdir.root_transport.base,
467
datestring_first, datestring_last,
469
self.assertEqual('', err)
471
def test_info_standalone_no_tree(self):
472
# create standalone branch without a working tree
473
branch = self.make_branch('branch')
474
repo = branch.repository
475
out, err = self.runbzr('info branch')
476
self.assertEqualDiff(
481
control: Meta directory format 1
482
branch: Branch format 5
491
""" % (branch.bzrdir.root_transport.base,
492
repo._format.get_format_description(),
494
self.assertEqual('', err)
496
def test_info_shared_repository(self):
497
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
498
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
499
transport = self.get_transport()
501
# Create shared repository
502
repo = self.make_repository('repo', shared=True)
503
repo.set_make_working_trees(False)
504
out, err = self.runbzr('info repo')
505
self.assertEqualDiff(
507
shared repository: %s
510
control: Meta directory format 1
516
""" % (repo.bzrdir.root_transport.base,
517
repo._format.get_format_description(),
519
self.assertEqual('', err)
521
# Create branch inside shared repository
522
repo.bzrdir.root_transport.mkdir('branch')
523
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
524
out, err = self.runbzr('info repo/branch')
525
self.assertEqualDiff(
527
shared repository: %s
528
repository branch: branch
531
control: Meta directory format 1
532
branch: Branch format 5
541
""" % (repo.bzrdir.root_transport.base,
542
repo._format.get_format_description(),
544
self.assertEqual('', err)
546
# Create lightweight checkout
547
transport.mkdir('tree')
548
transport.mkdir('tree/lightcheckout')
549
dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
550
bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
551
dir2.create_workingtree()
552
tree2 = dir2.open_workingtree()
553
branch2 = tree2.branch
554
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
556
# Create normal checkout
557
tree3 = branch1.create_checkout('tree/checkout')
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)