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.run_bzr('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.run_bzr('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.run_bzr('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.run_bzr('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.run_bzr('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.run_bzr('info -v lightcheckout')
247
self.assertEqualDiff(
248
"""Lightweight checkout (format: dirstate or 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.run_bzr('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.run_bzr('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.run_bzr('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.run_bzr('info lightcheckout --verbose')
436
self.assertEqualDiff(
437
"""Lightweight checkout (format: dirstate or 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.run_bzr('info branch -v')
482
self.assertEqualDiff(
483
"""Standalone branch (format: dirstate or 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.run_bzr('info -v repo')
513
self.assertEqualDiff(
514
"""Shared repository (format: dirstate or dirstate-tags or 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.run_bzr('info -v repo/branch')
535
self.assertEqualDiff(
536
"""Repository branch (format: dirstate or 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, repo_branch=branch1, 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.run_bzr('info tree/lightcheckout --verbose')
580
self.assertEqualDiff(
581
"""Lightweight checkout (format: dirstate or dirstate-tags)
583
light checkout root: %s
584
checkout of branch: %s
585
shared repository: %s
588
control: Meta directory format 1
589
working tree: Working tree format 4
601
0 versioned subdirectories
613
""" % (tree2.bzrdir.root_transport.base,
614
tree2.branch.bzrdir.root_transport.base,
615
repo.bzrdir.root_transport.base,
616
format.get_branch_format().get_format_description(),
617
format.repository_format.get_format_description(),
618
datestring_first, datestring_first,
619
# poking at _revision_store isn't all that clean, but neither is
620
# having the ui test dependent on the exact overhead of a given store.
621
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
623
self.assertEqual('', err)
625
# Out of date checkout
626
out, err = self.run_bzr('info -v tree/checkout')
627
self.assertEqualDiff(
628
"""Checkout (format: dirstate)
631
checkout of branch: %s
634
control: Meta directory format 1
635
working tree: Working tree format 4
639
Branch is out of date: missing 1 revision.
649
0 versioned subdirectories
658
""" % (tree3.bzrdir.root_transport.base,
659
branch1.bzrdir.root_transport.base,
660
format.get_branch_format().get_format_description(),
661
format.repository_format.get_format_description(),
663
self.assertEqual('', err)
667
self.build_tree(['tree/checkout/b'])
669
out, err = self.run_bzr('info tree/checkout --verbose')
670
self.assertEqualDiff(
671
"""Checkout (format: dirstate)
674
checkout of branch: %s
677
control: Meta directory format 1
678
working tree: Working tree format 4
690
0 versioned subdirectories
702
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
703
format.get_branch_format().get_format_description(),
704
format.repository_format.get_format_description(),
705
datestring_first, datestring_first,
706
# poking at _revision_store isn't all that clean, but neither is
707
# having the ui test dependent on the exact overhead of a given store.
708
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
710
self.assertEqual('', err)
711
tree3.commit('commit two')
713
# Out of date lightweight checkout
714
rev = repo.get_revision(branch1.revision_history()[-1])
715
datestring_last = format_date(rev.timestamp, rev.timezone)
716
out, err = self.run_bzr('info tree/lightcheckout --verbose')
717
self.assertEqualDiff(
718
"""Lightweight checkout (format: dirstate or dirstate-tags)
720
light checkout root: %s
721
checkout of branch: %s
722
shared repository: %s
725
control: Meta directory format 1
726
working tree: Working tree format 4
730
Working tree is out of date: missing 1 revision.
740
0 versioned subdirectories
752
""" % (tree2.bzrdir.root_transport.base,
753
tree2.branch.bzrdir.root_transport.base,
754
repo.bzrdir.root_transport.base,
755
format.get_branch_format().get_format_description(),
756
format.repository_format.get_format_description(),
757
datestring_first, datestring_last,
758
# poking at _revision_store isn't all that clean, but neither is
759
# having the ui test dependent on the exact overhead of a given store.
760
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
762
self.assertEqual('', err)
764
# Show info about shared branch
765
out, err = self.run_bzr('info repo/branch --verbose')
766
self.assertEqualDiff(
767
"""Repository branch (format: dirstate or knit)
769
shared repository: %s
770
repository branch: branch
773
control: Meta directory format 1
787
""" % (repo.bzrdir.root_transport.base,
788
format.get_branch_format().get_format_description(),
789
format.repository_format.get_format_description(),
790
datestring_first, datestring_last,
791
# poking at _revision_store isn't all that clean, but neither is
792
# having the ui test dependent on the exact overhead of a given store.
793
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
795
self.assertEqual('', err)
797
# Show info about repository with revisions
798
out, err = self.run_bzr('info -v repo')
799
self.assertEqualDiff(
800
"""Shared repository (format: dirstate or dirstate-tags or knit)
802
shared repository: %s
805
control: Meta directory format 1
811
""" % (repo.bzrdir.root_transport.base,
812
format.repository_format.get_format_description(),
813
# poking at _revision_store isn't all that clean, but neither is
814
# having the ui test dependent on the exact overhead of a given store.
815
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
817
self.assertEqual('', err)
819
def test_info_shared_repository_with_trees(self):
820
format = bzrdir.format_registry.make_bzrdir('knit')
821
transport = self.get_transport()
823
# Create shared repository with working trees
824
repo = self.make_repository('repo', shared=True, format=format)
825
repo.set_make_working_trees(True)
826
out, err = self.run_bzr('info -v repo')
827
self.assertEqualDiff(
828
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
830
shared repository: %s
833
control: Meta directory format 1
836
Create working tree for new branches inside the repository.
841
""" % (repo.bzrdir.root_transport.base,
842
format.repository_format.get_format_description(),
844
self.assertEqual('', err)
846
# Create two branches
847
repo.bzrdir.root_transport.mkdir('branch1')
848
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
850
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
853
out, err = self.run_bzr('info repo/branch1 --verbose')
854
self.assertEqualDiff(
855
"""Repository tree (format: knit)
857
shared repository: %s
858
repository branch: branch1
861
control: Meta directory format 1
862
working tree: Working tree format 3
874
0 versioned subdirectories
883
""" % (repo.bzrdir.root_transport.base,
884
format.get_branch_format().get_format_description(),
885
format.repository_format.get_format_description(),
887
self.assertEqual('', err)
889
# Update first branch
890
self.build_tree(['repo/branch1/a'])
891
tree1 = branch1.bzrdir.open_workingtree()
893
tree1.commit('commit one')
894
rev = repo.get_revision(branch1.revision_history()[0])
895
datestring_first = format_date(rev.timestamp, rev.timezone)
896
out, err = self.run_bzr('info -v repo/branch1')
897
self.assertEqualDiff(
898
"""Repository tree (format: knit)
900
shared repository: %s
901
repository branch: branch1
904
control: Meta directory format 1
905
working tree: Working tree format 3
917
0 versioned subdirectories
929
""" % (repo.bzrdir.root_transport.base,
930
format.get_branch_format().get_format_description(),
931
format.repository_format.get_format_description(),
932
datestring_first, datestring_first,
933
# poking at _revision_store isn't all that clean, but neither is
934
# having the ui test dependent on the exact overhead of a given store.
935
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
937
self.assertEqual('', err)
939
# Out of date second branch
940
out, err = self.run_bzr('info repo/branch2 --verbose')
941
self.assertEqualDiff(
942
"""Repository tree (format: knit)
944
shared repository: %s
945
repository branch: branch2
951
control: Meta directory format 1
952
working tree: Working tree format 3
964
0 versioned subdirectories
973
""" % (repo.bzrdir.root_transport.base,
974
branch1.bzrdir.root_transport.base,
975
format.get_branch_format().get_format_description(),
976
format.repository_format.get_format_description(),
977
# poking at _revision_store isn't all that clean, but neither is
978
# having the ui test dependent on the exact overhead of a given store.
979
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
981
self.assertEqual('', err)
983
# Update second branch
984
tree2 = branch2.bzrdir.open_workingtree()
986
out, err = self.run_bzr('info -v repo/branch2')
987
self.assertEqualDiff(
988
"""Repository tree (format: knit)
990
shared repository: %s
991
repository branch: branch2
997
control: Meta directory format 1
998
working tree: Working tree format 3
1002
In the working tree:
1010
0 versioned subdirectories
1022
""" % (repo.bzrdir.root_transport.base,
1023
branch1.bzrdir.root_transport.base,
1024
format.get_branch_format().get_format_description(),
1025
format.repository_format.get_format_description(),
1026
datestring_first, datestring_first,
1027
# poking at _revision_store isn't all that clean, but neither is
1028
# having the ui test dependent on the exact overhead of a given store.
1029
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1031
self.assertEqual('', err)
1033
# Show info about repository with revisions
1034
out, err = self.run_bzr('info -v repo')
1035
self.assertEqualDiff(
1036
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1038
shared repository: %s
1041
control: Meta directory format 1
1044
Create working tree for new branches inside the repository.
1049
""" % (repo.bzrdir.root_transport.base,
1050
format.repository_format.get_format_description(),
1051
# poking at _revision_store isn't all that clean, but neither is
1052
# having the ui test dependent on the exact overhead of a given store.
1053
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1056
self.assertEqual('', err)
1058
def test_info_shared_repository_with_tree_in_root(self):
1059
format = bzrdir.format_registry.make_bzrdir('knit')
1060
transport = self.get_transport()
1062
# Create shared repository with working trees
1063
repo = self.make_repository('repo', shared=True, format=format)
1064
repo.set_make_working_trees(True)
1065
out, err = self.run_bzr('info -v repo')
1066
self.assertEqualDiff(
1067
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1069
shared repository: %s
1072
control: Meta directory format 1
1075
Create working tree for new branches inside the repository.
1080
""" % (repo.bzrdir.root_transport.base,
1081
format.repository_format.get_format_description(),
1083
self.assertEqual('', err)
1085
# Create branch in root of repository
1086
control = repo.bzrdir
1087
branch = control.create_branch()
1088
control.create_workingtree()
1089
out, err = self.run_bzr('info -v repo')
1090
self.assertEqualDiff(
1091
"""Repository tree (format: knit)
1093
shared repository: %s
1094
repository branch: .
1097
control: Meta directory format 1
1098
working tree: Working tree format 3
1102
In the working tree:
1110
0 versioned subdirectories
1119
""" % (repo.bzrdir.root_transport.base,
1120
format.get_branch_format().get_format_description(),
1121
format.repository_format.get_format_description(),
1123
self.assertEqual('', err)
1125
def assertCheckoutStatusOutput(self,
1126
command_string, lco_tree, shared_repo=None,
1129
branch_locked=False, repo_locked=False,
1131
light_checkout=True,
1132
checkout_root=None):
1133
"""Check the output of info in a checkout.
1135
This is not quite a mirror of the info code: rather than using the
1136
tree being examined to predict output, it uses a bunch of flags which
1137
allow us, the test writers, to document what *should* be present in
1138
the output. Removing this separation would remove the value of the
1141
:param path: the path to the light checkout.
1142
:param lco_tree: the tree object for the light checkout.
1143
:param shared_repo: A shared repository is in use, expect that in
1145
:param repo_branch: A branch in a shared repository for non light
1147
:param tree_locked: If true, expect the tree to be locked.
1148
:param branch_locked: If true, expect the branch to be locked.
1149
:param repo_locked: If true, expect the repository to be locked.
1150
:param verbose: If true, expect verbose output
1152
if tree_locked and sys.platform == 'win32':
1153
# We expect this to fail because of locking errors. (A write-locked
1154
# file cannot be read-locked in the same process).
1155
# This should be removed when the locking errors are fixed.
1156
args = command_string.split(' ')
1157
self.run_bzr_error([], 'info', *args)
1159
out, err = self.run_bzr('info %s' % command_string)
1161
(True, True): 'Lightweight checkout',
1162
(True, False): 'Repository checkout',
1163
(False, True): 'Lightweight checkout',
1164
(False, False): 'Checkout',
1165
}[(shared_repo is not None, light_checkout)]
1166
format = {True: 'dirstate or dirstate-tags',
1167
False: 'dirstate'}[light_checkout]
1168
if repo_locked or branch_locked or tree_locked:
1169
def locked_message(a_bool):
1174
expected_lock_output = (
1177
" working tree: %s\n"
1179
" repository: %s\n" % (
1180
locked_message(tree_locked),
1181
locked_message(branch_locked),
1182
locked_message(repo_locked)))
1184
expected_lock_output = ''
1188
tree_data = (" light checkout root: %s\n" %
1189
lco_tree.bzrdir.root_transport.base)
1191
if lco_tree.branch.get_bound_location() is not None:
1192
tree_data += ("%s checkout root: %s\n" % (extra_space,
1193
lco_tree.branch.bzrdir.root_transport.base))
1194
if shared_repo is not None:
1196
" checkout of branch: %s\n"
1197
" shared repository: %s\n" %
1198
(repo_branch.bzrdir.root_transport.base,
1199
shared_repo.bzrdir.root_transport.base))
1200
elif repo_branch is not None:
1202
"%s checkout of branch: %s\n" %
1204
repo_branch.bzrdir.root_transport.base))
1206
branch_data = (" checkout of branch: %s\n" %
1207
lco_tree.branch.bzrdir.root_transport.base)
1210
verbose_info = ' 0 committers\n'
1214
self.assertEqualDiff(
1219
control: Meta directory format 1
1224
In the working tree:
1232
0 versioned subdirectories
1244
lco_tree._format.get_format_description(),
1245
lco_tree.branch._format.get_format_description(),
1246
lco_tree.branch.repository._format.get_format_description(),
1247
expected_lock_output,
1250
self.assertEqual('', err)
1252
def test_info_locking(self):
1253
transport = self.get_transport()
1254
# Create shared repository with a branch
1255
repo = self.make_repository('repo', shared=True,
1256
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1257
repo.set_make_working_trees(False)
1258
repo.bzrdir.root_transport.mkdir('branch')
1259
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1260
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1261
# Do a heavy checkout
1262
transport.mkdir('tree')
1263
transport.mkdir('tree/checkout')
1264
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1265
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1266
co_branch.bind(repo_branch)
1267
# Do a light checkout of the heavy one
1268
transport.mkdir('tree/lightcheckout')
1269
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1270
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1271
lco_dir.create_workingtree()
1272
lco_tree = lco_dir.open_workingtree()
1274
# Test all permutations of locking the working tree, branch and repository
1278
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1279
repo_branch=repo_branch,
1280
verbose=True, light_checkout=True)
1282
lco_tree.branch.repository.lock_write()
1284
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1285
lco_tree, repo_branch=repo_branch,
1286
repo_locked=True, verbose=True, light_checkout=True)
1288
lco_tree.branch.repository.unlock()
1290
lco_tree.branch.lock_write()
1292
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1296
repo_branch=repo_branch,
1299
lco_tree.branch.unlock()
1301
lco_tree.lock_write()
1303
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1304
lco_tree, repo_branch=repo_branch,
1312
lco_tree.lock_write()
1313
lco_tree.branch.repository.unlock()
1315
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1316
lco_tree, repo_branch=repo_branch,
1321
lco_tree.branch.repository.lock_write()
1324
lco_tree.lock_write()
1325
lco_tree.branch.unlock()
1327
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1328
lco_tree, repo_branch=repo_branch,
1332
lco_tree.branch.lock_write()
1335
lco_tree.lock_write()
1336
lco_tree.branch.unlock()
1337
lco_tree.branch.repository.lock_write()
1339
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1340
lco_tree, repo_branch=repo_branch,
1345
lco_tree.branch.repository.unlock()
1346
lco_tree.branch.lock_write()
1349
lco_tree.branch.lock_write()
1350
lco_tree.branch.repository.unlock()
1352
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1353
lco_tree, repo_branch=repo_branch,
1357
lco_tree.branch.repository.lock_write()
1358
lco_tree.branch.unlock()
1360
if sys.platform == 'win32':
1361
self.knownFailure('Win32 cannot run "bzr info"'
1362
' when the tree is locked.')
1364
def test_info_locking_oslocks(self):
1365
if sys.platform == "win32":
1366
raise TestSkipped("don't use oslocks on win32 in unix manner")
1368
tree = self.make_branch_and_tree('branch',
1369
format=bzrlib.bzrdir.BzrDirFormat6())
1371
# Test all permutations of locking the working tree, branch and repository
1372
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1373
# implemented by raising NotImplementedError and get_physical_lock_status()
1374
# always returns false. This makes bzr info hide the lock status. (Olaf)
1378
out, err = self.run_bzr('info -v branch')
1379
self.assertEqualDiff(
1380
"""Standalone tree (format: weave)
1385
control: All-in-one format 6
1386
working tree: Working tree format 2
1387
branch: Branch format 4
1390
In the working tree:
1398
0 versioned subdirectories
1407
""" % (tree.bzrdir.root_transport.base,
1408
tree.branch.repository._format.get_format_description(),
1410
self.assertEqual('', err)
1413
out, err = self.run_bzr('info -v branch')
1414
self.assertEqualDiff(
1415
"""Standalone tree (format: weave)
1420
control: All-in-one format 6
1421
working tree: Working tree format 2
1422
branch: Branch format 4
1425
In the working tree:
1433
0 versioned subdirectories
1442
""" % (tree.bzrdir.root_transport.base,
1443
tree.branch.repository._format.get_format_description(),
1445
self.assertEqual('', err)