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."""
27
from bzrlib.osutils import format_date
28
from bzrlib.tests import TestSkipped
29
from bzrlib.tests.blackbox import ExternalBase
32
class TestInfo(ExternalBase):
34
def test_info_non_existing(self):
35
if sys.platform == "win32":
36
location = "C:/i/do/not/exist/"
38
location = "/i/do/not/exist/"
39
out, err = self.runbzr('info '+location, retcode=3)
40
self.assertEqual(out, '')
41
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
43
def test_info_standalone(self):
44
transport = self.get_transport()
46
# Create initial standalone branch
47
tree1 = self.make_branch_and_tree('standalone', 'weave')
48
self.build_tree(['standalone/a'])
50
branch1 = tree1.branch
51
out, err = self.runbzr('info standalone -v')
53
"""Standalone tree (format: weave)
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
80
""" % branch1.bzrdir.root_transport.base, out)
81
self.assertEqual('', err)
82
tree1.commit('commit one')
83
rev = branch1.repository.get_revision(branch1.revision_history()[0])
84
datestring_first = format_date(rev.timestamp, rev.timezone)
86
# Branch standalone with push location
87
branch2 = branch1.bzrdir.sprout('branch').open_branch()
88
branch2.set_push_location(branch1.bzrdir.root_transport.base)
89
out, err = self.runbzr('info branch --verbose')
91
"""Standalone tree (format: weave)
100
control: All-in-one format 6
101
working tree: Working tree format 2
102
branch: Branch format 4
103
repository: Weave repository format 6
113
0 versioned subdirectories
125
""" % (branch2.bzrdir.root_transport.base,
126
branch1.bzrdir.root_transport.base,
127
branch1.bzrdir.root_transport.base,
128
datestring_first, datestring_first,
129
# poking at _revision_store isn't all that clean, but neither is
130
# having the ui test dependent on the exact overhead of a given store.
131
branch2.repository._revision_store.total_size(
132
branch2.repository.get_transaction())[1] / 1024,
134
self.assertEqual('', err)
136
# Branch and bind to standalone, needs upgrade to metadir
137
# (creates backup as unknown)
138
branch1.bzrdir.sprout('bound')
139
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
140
bzrlib.upgrade.upgrade('bound', knit1_format)
141
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
142
branch3.bind(branch1)
143
bound_tree = branch3.bzrdir.open_workingtree()
144
out, err = self.runbzr('info -v bound')
145
self.assertEqualDiff(
146
"""Checkout (format: knit)
149
checkout of branch: %s
155
control: Meta directory format 1
168
0 versioned subdirectories
180
""" % (branch3.bzrdir.root_transport.base,
181
branch1.bzrdir.root_transport.base,
182
branch1.bzrdir.root_transport.base,
183
bound_tree._format.get_format_description(),
184
branch3._format.get_format_description(),
185
branch3.repository._format.get_format_description(),
186
datestring_first, datestring_first,
187
# poking at _revision_store isn't all that clean, but neither is
188
# having the ui test dependent on the exact overhead of a given store.
189
branch3.repository._revision_store.total_size(
190
branch3.repository.get_transaction())[1] / 1024,
192
self.assertEqual('', err)
194
# Checkout standalone (same as above, but does not have parent set)
195
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
197
branch4.bind(branch1)
198
branch4.bzrdir.open_workingtree().update()
199
out, err = self.runbzr('info checkout --verbose')
200
self.assertEqualDiff(
201
"""Checkout (format: knit)
204
checkout of branch: %s
207
control: Meta directory format 1
208
working tree: Working tree format 3
209
branch: Branch format 5
220
0 versioned subdirectories
232
""" % (branch4.bzrdir.root_transport.base,
233
branch1.bzrdir.root_transport.base,
234
branch4.repository._format.get_format_description(),
235
datestring_first, datestring_first,
236
# poking at _revision_store isn't all that clean, but neither is
237
# having the ui test dependent on the exact overhead of a given store.
238
branch4.repository._revision_store.total_size(
239
branch4.repository.get_transaction())[1] / 1024,
241
self.assertEqual('', err)
243
# Lightweight checkout (same as above, different branch and repository)
244
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
245
branch5 = tree5.branch
246
out, err = self.runbzr('info -v lightcheckout')
247
self.assertEqualDiff(
248
"""Lightweight checkout (format: dirstate / dirstate-tags)
250
light checkout root: %s
251
checkout of branch: %s
254
control: Meta directory format 1
255
working tree: Working tree format 4
256
branch: Branch format 4
257
repository: Weave repository format 6
267
0 versioned subdirectories
279
""" % (tree5.bzrdir.root_transport.base,
280
branch1.bzrdir.root_transport.base,
281
datestring_first, datestring_first,
283
self.assertEqual('', err)
285
# Update initial standalone branch
286
self.build_tree(['standalone/b'])
288
tree1.commit('commit two')
289
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
290
datestring_last = format_date(rev.timestamp, rev.timezone)
292
# Out of date branched standalone branch will not be detected
293
out, err = self.runbzr('info -v branch')
294
self.assertEqualDiff(
295
"""Standalone tree (format: weave)
301
publish to branch: %s
304
control: All-in-one format 6
305
working tree: Working tree format 2
306
branch: Branch format 4
307
repository: Weave repository format 6
317
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 -v bound')
338
self.assertEqualDiff(
339
"""Checkout (format: knit)
342
checkout of branch: %s
348
control: Meta directory format 1
349
working tree: Working tree format 3
350
branch: Branch format 5
353
Branch is out of date: missing 1 revision.
363
0 versioned subdirectories
375
""" % (branch3.bzrdir.root_transport.base,
376
branch1.bzrdir.root_transport.base,
377
branch1.bzrdir.root_transport.base,
378
branch3.repository._format.get_format_description(),
379
datestring_first, datestring_first,
380
# poking at _revision_store isn't all that clean, but neither is
381
# having the ui test dependent on the exact overhead of a given store.
382
branch3.repository._revision_store.total_size(
383
branch3.repository.get_transaction())[1] / 1024,
385
self.assertEqual('', err)
387
# Out of date checkout
388
out, err = self.runbzr('info -v checkout')
389
self.assertEqualDiff(
390
"""Checkout (format: knit)
393
checkout of branch: %s
396
control: Meta directory format 1
397
working tree: Working tree format 3
398
branch: Branch format 5
401
Branch is out of date: missing 1 revision.
411
0 versioned subdirectories
423
""" % (branch4.bzrdir.root_transport.base,
424
branch1.bzrdir.root_transport.base,
425
branch4.repository._format.get_format_description(),
426
datestring_first, datestring_first,
427
# poking at _revision_store isn't all that clean, but neither is
428
# having the ui test dependent on the exact overhead of a given store.
429
branch4.repository._revision_store.total_size(
430
branch4.repository.get_transaction())[1] / 1024,
432
self.assertEqual('', err)
434
# Out of date lightweight checkout
435
out, err = self.runbzr('info lightcheckout --verbose')
436
self.assertEqualDiff(
437
"""Lightweight checkout (format: dirstate / dirstate-tags)
439
light checkout root: %s
440
checkout of branch: %s
443
control: Meta directory format 1
444
working tree: Working tree format 4
445
branch: Branch format 4
446
repository: Weave repository format 6
448
Working tree is out of date: missing 1 revision.
458
0 versioned subdirectories
470
""" % (tree5.bzrdir.root_transport.base,
471
branch1.bzrdir.root_transport.base,
472
datestring_first, datestring_last,
474
self.assertEqual('', err)
476
def test_info_standalone_no_tree(self):
477
# create standalone branch without a working tree
478
format = bzrdir.format_registry.make_bzrdir('default')
479
branch = self.make_branch('branch')
480
repo = branch.repository
481
out, err = self.runbzr('info branch -v')
482
self.assertEqualDiff(
483
"""Standalone branch (format: dirstate / knit)
488
control: Meta directory format 1
499
""" % (branch.bzrdir.root_transport.base,
500
format.get_branch_format().get_format_description(),
501
format.repository_format.get_format_description(),
503
self.assertEqual('', err)
505
def test_info_shared_repository(self):
506
format = bzrdir.format_registry.make_bzrdir('knit')
507
transport = self.get_transport()
509
# Create shared repository
510
repo = self.make_repository('repo', shared=True, format=format)
511
repo.set_make_working_trees(False)
512
out, err = self.runbzr('info -v repo')
513
self.assertEqualDiff(
514
"""Shared repository (format: dirstate / dirstate-tags / knit)
516
shared repository: %s
519
control: Meta directory format 1
525
""" % (repo.bzrdir.root_transport.base,
526
format.repository_format.get_format_description(),
528
self.assertEqual('', err)
530
# Create branch inside shared repository
531
repo.bzrdir.root_transport.mkdir('branch')
532
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
534
out, err = self.runbzr('info -v repo/branch')
535
self.assertEqualDiff(
536
"""Repository branch (format: dirstate / knit)
538
shared repository: %s
539
repository branch: branch
542
control: Meta directory format 1
553
""" % (repo.bzrdir.root_transport.base,
554
format.get_branch_format().get_format_description(),
555
format.repository_format.get_format_description(),
557
self.assertEqual('', err)
559
# Create lightweight checkout
560
transport.mkdir('tree')
561
transport.mkdir('tree/lightcheckout')
562
tree2 = branch1.create_checkout('tree/lightcheckout',
564
branch2 = tree2.branch
565
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
566
shared_repo=repo, verbose=True)
568
# Create normal checkout
569
tree3 = branch1.create_checkout('tree/checkout')
570
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
572
light_checkout=False, repo_branch=branch1)
573
# Update lightweight checkout
574
self.build_tree(['tree/lightcheckout/a'])
576
tree2.commit('commit one')
577
rev = repo.get_revision(branch2.revision_history()[0])
578
datestring_first = format_date(rev.timestamp, rev.timezone)
579
out, err = self.runbzr('info tree/lightcheckout --verbose')
580
self.assertEqualDiff(
581
"""Lightweight checkout (format: dirstate / dirstate-tags)
583
light checkout root: %s
584
shared repository: %s
585
repository branch: branch
588
control: Meta directory format 1
589
working tree: Working tree format 4
601
0 versioned subdirectories
613
""" % (tree2.bzrdir.root_transport.base,
614
repo.bzrdir.root_transport.base,
615
format.get_branch_format().get_format_description(),
616
format.repository_format.get_format_description(),
617
datestring_first, datestring_first,
618
# poking at _revision_store isn't all that clean, but neither is
619
# having the ui test dependent on the exact overhead of a given store.
620
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
622
self.assertEqual('', err)
624
# Out of date checkout
625
out, err = self.runbzr('info -v tree/checkout')
626
self.assertEqualDiff(
627
"""Checkout (format: dirstate)
630
checkout of branch: %s
633
control: Meta directory format 1
634
working tree: Working tree format 4
638
Branch is out of date: missing 1 revision.
648
0 versioned subdirectories
657
""" % (tree3.bzrdir.root_transport.base,
658
branch1.bzrdir.root_transport.base,
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.runbzr('info tree/checkout --verbose')
669
self.assertEqualDiff(
670
"""Checkout (format: dirstate)
673
checkout of branch: %s
676
control: Meta directory format 1
677
working tree: Working tree format 4
689
0 versioned subdirectories
701
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
702
format.get_branch_format().get_format_description(),
703
format.repository_format.get_format_description(),
704
datestring_first, datestring_first,
705
# poking at _revision_store isn't all that clean, but neither is
706
# having the ui test dependent on the exact overhead of a given store.
707
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
709
self.assertEqual('', err)
710
tree3.commit('commit two')
712
# Out of date lightweight checkout
713
rev = repo.get_revision(branch1.revision_history()[-1])
714
datestring_last = format_date(rev.timestamp, rev.timezone)
715
out, err = self.runbzr('info tree/lightcheckout --verbose')
716
self.assertEqualDiff(
717
"""Lightweight checkout (format: dirstate / dirstate-tags)
719
light checkout root: %s
720
shared repository: %s
721
repository branch: branch
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
""" % (tree2.bzrdir.root_transport.base,
752
repo.bzrdir.root_transport.base,
753
format.get_branch_format().get_format_description(),
754
format.repository_format.get_format_description(),
755
datestring_first, datestring_last,
756
# poking at _revision_store isn't all that clean, but neither is
757
# having the ui test dependent on the exact overhead of a given store.
758
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
760
self.assertEqual('', err)
762
# Show info about shared branch
763
out, err = self.runbzr('info repo/branch --verbose')
764
self.assertEqualDiff(
765
"""Repository branch (format: dirstate / knit)
767
shared repository: %s
768
repository branch: branch
771
control: Meta directory format 1
785
""" % (repo.bzrdir.root_transport.base,
786
format.get_branch_format().get_format_description(),
787
format.repository_format.get_format_description(),
788
datestring_first, datestring_last,
789
# poking at _revision_store isn't all that clean, but neither is
790
# having the ui test dependent on the exact overhead of a given store.
791
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
793
self.assertEqual('', err)
795
# Show info about repository with revisions
796
out, err = self.runbzr('info -v repo')
797
self.assertEqualDiff(
798
"""Shared repository (format: dirstate / dirstate-tags / knit)
800
shared repository: %s
803
control: Meta directory format 1
809
""" % (repo.bzrdir.root_transport.base,
810
format.repository_format.get_format_description(),
811
# poking at _revision_store isn't all that clean, but neither is
812
# having the ui test dependent on the exact overhead of a given store.
813
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
815
self.assertEqual('', err)
817
def test_info_shared_repository_with_trees(self):
818
format = bzrdir.format_registry.make_bzrdir('knit')
819
transport = self.get_transport()
821
# Create shared repository with working trees
822
repo = self.make_repository('repo', shared=True, format=format)
823
repo.set_make_working_trees(True)
824
out, err = self.runbzr('info -v repo')
825
self.assertEqualDiff(
826
"""Shared repository with trees (format: dirstate / dirstate-tags / knit)
828
shared repository: %s
831
control: Meta directory format 1
834
Create working tree for new branches inside the repository.
839
""" % (repo.bzrdir.root_transport.base,
840
format.repository_format.get_format_description(),
842
self.assertEqual('', err)
844
# Create two branches
845
repo.bzrdir.root_transport.mkdir('branch1')
846
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
848
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
851
out, err = self.runbzr('info repo/branch1 --verbose')
852
self.assertEqualDiff(
853
"""Repository tree (format: knit)
855
shared repository: %s
856
repository checkout: branch1
859
control: Meta directory format 1
860
working tree: Working tree format 3
872
0 versioned subdirectories
881
""" % (repo.bzrdir.root_transport.base,
882
format.get_branch_format().get_format_description(),
883
format.repository_format.get_format_description(),
885
self.assertEqual('', err)
887
# Update first branch
888
self.build_tree(['repo/branch1/a'])
889
tree1 = branch1.bzrdir.open_workingtree()
891
tree1.commit('commit one')
892
rev = repo.get_revision(branch1.revision_history()[0])
893
datestring_first = format_date(rev.timestamp, rev.timezone)
894
out, err = self.runbzr('info -v repo/branch1')
895
self.assertEqualDiff(
896
"""Repository tree (format: knit)
898
shared repository: %s
899
repository checkout: branch1
902
control: Meta directory format 1
903
working tree: Working tree format 3
915
0 versioned subdirectories
927
""" % (repo.bzrdir.root_transport.base,
928
format.get_branch_format().get_format_description(),
929
format.repository_format.get_format_description(),
930
datestring_first, datestring_first,
931
# poking at _revision_store isn't all that clean, but neither is
932
# having the ui test dependent on the exact overhead of a given store.
933
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
935
self.assertEqual('', err)
937
# Out of date second branch
938
out, err = self.runbzr('info repo/branch2 --verbose')
939
self.assertEqualDiff(
940
"""Repository tree (format: knit)
942
shared repository: %s
943
repository checkout: branch2
949
control: Meta directory format 1
950
working tree: Working tree format 3
962
0 versioned subdirectories
971
""" % (repo.bzrdir.root_transport.base,
972
branch1.bzrdir.root_transport.base,
973
format.get_branch_format().get_format_description(),
974
format.repository_format.get_format_description(),
975
# poking at _revision_store isn't all that clean, but neither is
976
# having the ui test dependent on the exact overhead of a given store.
977
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
979
self.assertEqual('', err)
981
# Update second branch
982
tree2 = branch2.bzrdir.open_workingtree()
984
out, err = self.runbzr('info -v repo/branch2')
985
self.assertEqualDiff(
986
"""Repository tree (format: knit)
988
shared repository: %s
989
repository checkout: branch2
995
control: Meta directory format 1
996
working tree: Working tree format 3
1000
In the working tree:
1008
0 versioned subdirectories
1020
""" % (repo.bzrdir.root_transport.base,
1021
branch1.bzrdir.root_transport.base,
1022
format.get_branch_format().get_format_description(),
1023
format.repository_format.get_format_description(),
1024
datestring_first, datestring_first,
1025
# poking at _revision_store isn't all that clean, but neither is
1026
# having the ui test dependent on the exact overhead of a given store.
1027
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1029
self.assertEqual('', err)
1031
# Show info about repository with revisions
1032
out, err = self.runbzr('info -v repo')
1033
self.assertEqualDiff(
1034
"""Shared repository with trees (format: dirstate / dirstate-tags / knit)
1036
shared repository: %s
1039
control: Meta directory format 1
1042
Create working tree for new branches inside the repository.
1047
""" % (repo.bzrdir.root_transport.base,
1048
format.repository_format.get_format_description(),
1049
# poking at _revision_store isn't all that clean, but neither is
1050
# having the ui test dependent on the exact overhead of a given store.
1051
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1054
self.assertEqual('', err)
1056
def test_info_shared_repository_with_tree_in_root(self):
1057
format = bzrdir.format_registry.make_bzrdir('knit')
1058
transport = self.get_transport()
1060
# Create shared repository with working trees
1061
repo = self.make_repository('repo', shared=True, format=format)
1062
repo.set_make_working_trees(True)
1063
out, err = self.runbzr('info -v repo')
1064
self.assertEqualDiff(
1065
"""Shared repository with trees (format: dirstate / dirstate-tags / knit)
1067
shared repository: %s
1070
control: Meta directory format 1
1073
Create working tree for new branches inside the repository.
1078
""" % (repo.bzrdir.root_transport.base,
1079
format.repository_format.get_format_description(),
1081
self.assertEqual('', err)
1083
# Create branch in root of repository
1084
control = repo.bzrdir
1085
branch = control.create_branch()
1086
control.create_workingtree()
1087
out, err = self.runbzr('info -v repo')
1088
self.assertEqualDiff(
1089
"""Repository tree (format: knit)
1091
shared repository: %s
1092
repository checkout: .
1095
control: Meta directory format 1
1096
working tree: Working tree format 3
1100
In the working tree:
1108
0 versioned subdirectories
1117
""" % (repo.bzrdir.root_transport.base,
1118
format.get_branch_format().get_format_description(),
1119
format.repository_format.get_format_description(),
1121
self.assertEqual('', err)
1123
def assertCheckoutStatusOutput(self,
1124
command_string, lco_tree, shared_repo=None,
1127
branch_locked=False, repo_locked=False,
1129
light_checkout=True):
1130
"""Check the output of info in a light checkout tree.
1132
This is not quite a mirror of the info code: rather than using the
1133
tree being examined to predict output, it uses a bunch of flags which
1134
allow us, the test writers, to document what *should* be present in
1135
the output. Removing this separation would remove the value of the
1138
:param path: the path to the light checkout.
1139
:param lco_tree: the tree object for the light checkout.
1140
:param shared_repo: A shared repository is in use, expect that in
1142
:param repo_branch: A branch in a shared repository for non light
1144
:param tree_locked: If true, expect the tree to be locked.
1145
:param branch_locked: If true, expect the branch to be locked.
1146
:param repo_locked: If true, expect the repository to be locked.
1147
:param verbose: If true, expect verbose output
1149
if tree_locked and sys.platform == 'win32':
1150
# We expect this to fail because of locking errors. (A write-locked
1151
# file cannot be read-locked in the same process).
1152
# This should be removed when the locking errors are fixed.
1153
args = command_string.split(' ')
1154
self.run_bzr_error([], 'info', *args)
1156
out, err = self.runbzr('info %s' % command_string)
1158
(True, True): 'Lightweight checkout',
1159
(True, False): 'Repository checkout',
1160
(False, True): 'Lightweight checkout',
1161
(False, False): 'Checkout',
1162
}[(shared_repo is not None, light_checkout)]
1163
format = {True: 'dirstate / dirstate-tags',
1164
False: 'dirstate'}[light_checkout]
1165
if repo_locked or branch_locked or tree_locked:
1166
def locked_message(a_bool):
1171
expected_lock_output = (
1174
" working tree: %s\n"
1176
" repository: %s\n" % (
1177
locked_message(tree_locked),
1178
locked_message(branch_locked),
1179
locked_message(repo_locked)))
1181
expected_lock_output = ''
1183
tree_data = (" light checkout root: %s" %
1184
lco_tree.bzrdir.root_transport.base)
1186
tree_data = (" checkout root: %s" %
1187
lco_tree.bzrdir.root_transport.base)
1188
if shared_repo is not None:
1190
" shared repository: %s\n"
1191
" repository branch: branch\n" %
1192
shared_repo.bzrdir.root_transport.base)
1193
elif repo_branch is not None:
1195
" checkout of branch: %s\n" %
1196
repo_branch.bzrdir.root_transport.base)
1198
branch_data = (" checkout of branch: %s\n" %
1199
lco_tree.branch.bzrdir.root_transport.base)
1202
verbose_info = ' 0 committers\n'
1206
self.assertEqualDiff(
1212
control: Meta directory format 1
1217
In the working tree:
1225
0 versioned subdirectories
1237
lco_tree._format.get_format_description(),
1238
lco_tree.branch._format.get_format_description(),
1239
lco_tree.branch.repository._format.get_format_description(),
1240
expected_lock_output,
1243
self.assertEqual('', err)
1245
def test_info_locking(self):
1246
transport = self.get_transport()
1247
# Create shared repository with a branch
1248
repo = self.make_repository('repo', shared=True,
1249
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1250
repo.set_make_working_trees(False)
1251
repo.bzrdir.root_transport.mkdir('branch')
1252
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1253
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1254
# Do a heavy checkout
1255
transport.mkdir('tree')
1256
transport.mkdir('tree/checkout')
1257
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1258
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1259
co_branch.bind(repo_branch)
1260
# Do a light checkout of the heavy one
1261
transport.mkdir('tree/lightcheckout')
1262
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1263
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1264
lco_dir.create_workingtree()
1265
lco_tree = lco_dir.open_workingtree()
1267
# Test all permutations of locking the working tree, branch and repository
1271
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1274
lco_tree.branch.repository.lock_write()
1276
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1278
repo_locked=True, verbose=True)
1280
lco_tree.branch.repository.unlock()
1282
lco_tree.branch.lock_write()
1284
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1290
lco_tree.branch.unlock()
1292
lco_tree.lock_write()
1294
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1303
lco_tree.lock_write()
1304
lco_tree.branch.repository.unlock()
1306
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1312
lco_tree.branch.repository.lock_write()
1315
lco_tree.lock_write()
1316
lco_tree.branch.unlock()
1318
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
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',
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',
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.runbzr('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
""" % (tree.bzrdir.root_transport.base,
1399
tree.branch.repository._format.get_format_description(),
1401
self.assertEqual('', err)
1404
out, err = self.runbzr('info -v branch')
1405
self.assertEqualDiff(
1406
"""Standalone tree (format: weave)
1411
control: All-in-one format 6
1412
working tree: Working tree format 2
1413
branch: Branch format 4
1416
In the working tree:
1424
0 versioned subdirectories
1433
""" % (tree.bzrdir.root_transport.base,
1434
tree.branch.repository._format.get_format_description(),
1436
self.assertEqual('', err)