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
52
out, err = self.run_bzr('info standalone')
54
"""Standalone tree (format: weave)
57
""" % branch1.bzrdir.root_transport.base, out)
58
self.assertEqual('', err)
60
out, err = self.run_bzr('info standalone -v')
62
"""Standalone tree (format: weave)
67
control: All-in-one format 6
68
working tree: Working tree format 2
69
branch: Branch format 4
70
repository: Weave repository format 6
80
0 versioned subdirectories
89
""" % branch1.bzrdir.root_transport.base, out)
90
self.assertEqual('', err)
91
tree1.commit('commit one')
92
rev = branch1.repository.get_revision(branch1.revision_history()[0])
93
datestring_first = format_date(rev.timestamp, rev.timezone)
95
# Branch standalone with push location
96
branch2 = branch1.bzrdir.sprout('branch').open_branch()
97
branch2.set_push_location(branch1.bzrdir.root_transport.base)
99
out, err = self.run_bzr('info branch')
100
self.assertEqualDiff(
101
"""Standalone tree (format: weave)
107
publish to branch: %s
108
""" % (branch2.bzrdir.root_transport.base,
109
branch1.bzrdir.root_transport.base,
110
branch1.bzrdir.root_transport.base), out)
111
self.assertEqual('', err)
113
out, err = self.run_bzr('info branch --verbose')
114
self.assertEqualDiff(
115
"""Standalone tree (format: weave)
121
publish to branch: %s
124
control: All-in-one format 6
125
working tree: Working tree format 2
126
branch: Branch format 4
127
repository: Weave repository format 6
137
0 versioned subdirectories
149
""" % (branch2.bzrdir.root_transport.base,
150
branch1.bzrdir.root_transport.base,
151
branch1.bzrdir.root_transport.base,
152
datestring_first, datestring_first,
153
# poking at _revision_store isn't all that clean, but neither is
154
# having the ui test dependent on the exact overhead of a given store.
155
branch2.repository._revision_store.total_size(
156
branch2.repository.get_transaction())[1] / 1024,
158
self.assertEqual('', err)
160
# Branch and bind to standalone, needs upgrade to metadir
161
# (creates backup as unknown)
162
branch1.bzrdir.sprout('bound')
163
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
164
bzrlib.upgrade.upgrade('bound', knit1_format)
165
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
166
branch3.bind(branch1)
167
bound_tree = branch3.bzrdir.open_workingtree()
168
out, err = self.run_bzr('info -v bound')
169
self.assertEqualDiff(
170
"""Checkout (format: knit)
173
checkout of branch: %s
179
control: Meta directory format 1
192
0 versioned subdirectories
204
""" % (branch3.bzrdir.root_transport.base,
205
branch1.bzrdir.root_transport.base,
206
branch1.bzrdir.root_transport.base,
207
bound_tree._format.get_format_description(),
208
branch3._format.get_format_description(),
209
branch3.repository._format.get_format_description(),
210
datestring_first, datestring_first,
211
# poking at _revision_store isn't all that clean, but neither is
212
# having the ui test dependent on the exact overhead of a given store.
213
branch3.repository._revision_store.total_size(
214
branch3.repository.get_transaction())[1] / 1024,
216
self.assertEqual('', err)
218
# Checkout standalone (same as above, but does not have parent set)
219
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
221
branch4.bind(branch1)
222
branch4.bzrdir.open_workingtree().update()
223
out, err = self.run_bzr('info checkout --verbose')
224
self.assertEqualDiff(
225
"""Checkout (format: knit)
228
checkout of branch: %s
231
control: Meta directory format 1
232
working tree: Working tree format 3
233
branch: Branch format 5
244
0 versioned subdirectories
256
""" % (branch4.bzrdir.root_transport.base,
257
branch1.bzrdir.root_transport.base,
258
branch4.repository._format.get_format_description(),
259
datestring_first, datestring_first,
260
# poking at _revision_store isn't all that clean, but neither is
261
# having the ui test dependent on the exact overhead of a given store.
262
branch4.repository._revision_store.total_size(
263
branch4.repository.get_transaction())[1] / 1024,
265
self.assertEqual('', err)
267
# Lightweight checkout (same as above, different branch and repository)
268
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
269
branch5 = tree5.branch
270
out, err = self.run_bzr('info -v lightcheckout')
271
self.assertEqualDiff(
272
"""Lightweight checkout (format: dirstate or dirstate-tags)
274
light checkout root: %s
275
checkout of branch: %s
278
control: Meta directory format 1
279
working tree: Working tree format 4
280
branch: Branch format 4
281
repository: Weave repository format 6
291
0 versioned subdirectories
303
""" % (tree5.bzrdir.root_transport.base,
304
branch1.bzrdir.root_transport.base,
305
datestring_first, datestring_first,
307
self.assertEqual('', err)
309
# Update initial standalone branch
310
self.build_tree(['standalone/b'])
312
tree1.commit('commit two')
313
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
314
datestring_last = format_date(rev.timestamp, rev.timezone)
316
# Out of date branched standalone branch will not be detected
317
out, err = self.run_bzr('info -v branch')
318
self.assertEqualDiff(
319
"""Standalone tree (format: weave)
325
publish to branch: %s
328
control: All-in-one format 6
329
working tree: Working tree format 2
330
branch: Branch format 4
331
repository: Weave repository format 6
341
0 versioned subdirectories
353
""" % (branch2.bzrdir.root_transport.base,
354
branch1.bzrdir.root_transport.base,
355
branch1.bzrdir.root_transport.base,
356
datestring_first, datestring_first,
358
self.assertEqual('', err)
360
# Out of date bound branch
361
out, err = self.run_bzr('info -v bound')
362
self.assertEqualDiff(
363
"""Checkout (format: knit)
366
checkout of branch: %s
372
control: Meta directory format 1
373
working tree: Working tree format 3
374
branch: Branch format 5
377
Branch is out of date: missing 1 revision.
387
0 versioned subdirectories
399
""" % (branch3.bzrdir.root_transport.base,
400
branch1.bzrdir.root_transport.base,
401
branch1.bzrdir.root_transport.base,
402
branch3.repository._format.get_format_description(),
403
datestring_first, datestring_first,
404
# poking at _revision_store isn't all that clean, but neither is
405
# having the ui test dependent on the exact overhead of a given store.
406
branch3.repository._revision_store.total_size(
407
branch3.repository.get_transaction())[1] / 1024,
409
self.assertEqual('', err)
411
# Out of date checkout
412
out, err = self.run_bzr('info -v checkout')
413
self.assertEqualDiff(
414
"""Checkout (format: knit)
417
checkout of branch: %s
420
control: Meta directory format 1
421
working tree: Working tree format 3
422
branch: Branch format 5
425
Branch is out of date: missing 1 revision.
435
0 versioned subdirectories
447
""" % (branch4.bzrdir.root_transport.base,
448
branch1.bzrdir.root_transport.base,
449
branch4.repository._format.get_format_description(),
450
datestring_first, datestring_first,
451
# poking at _revision_store isn't all that clean, but neither is
452
# having the ui test dependent on the exact overhead of a given store.
453
branch4.repository._revision_store.total_size(
454
branch4.repository.get_transaction())[1] / 1024,
456
self.assertEqual('', err)
458
# Out of date lightweight checkout
459
out, err = self.run_bzr('info lightcheckout --verbose')
460
self.assertEqualDiff(
461
"""Lightweight checkout (format: dirstate or dirstate-tags)
463
light checkout root: %s
464
checkout of branch: %s
467
control: Meta directory format 1
468
working tree: Working tree format 4
469
branch: Branch format 4
470
repository: Weave repository format 6
472
Working tree is out of date: missing 1 revision.
482
0 versioned subdirectories
494
""" % (tree5.bzrdir.root_transport.base,
495
branch1.bzrdir.root_transport.base,
496
datestring_first, datestring_last,
498
self.assertEqual('', err)
500
def test_info_standalone_no_tree(self):
501
# create standalone branch without a working tree
502
format = bzrdir.format_registry.make_bzrdir('default')
503
branch = self.make_branch('branch')
504
repo = branch.repository
505
out, err = self.run_bzr('info branch -v')
506
self.assertEqualDiff(
507
"""Standalone branch (format: dirstate or knit)
512
control: Meta directory format 1
523
""" % (branch.bzrdir.root_transport.base,
524
format.get_branch_format().get_format_description(),
525
format.repository_format.get_format_description(),
527
self.assertEqual('', err)
529
def test_info_shared_repository(self):
530
format = bzrdir.format_registry.make_bzrdir('knit')
531
transport = self.get_transport()
533
# Create shared repository
534
repo = self.make_repository('repo', shared=True, format=format)
535
repo.set_make_working_trees(False)
536
out, err = self.run_bzr('info -v repo')
537
self.assertEqualDiff(
538
"""Shared repository (format: dirstate or dirstate-tags or knit)
540
shared repository: %s
543
control: Meta directory format 1
549
""" % (repo.bzrdir.root_transport.base,
550
format.repository_format.get_format_description(),
552
self.assertEqual('', err)
554
# Create branch inside shared repository
555
repo.bzrdir.root_transport.mkdir('branch')
556
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
558
out, err = self.run_bzr('info -v repo/branch')
559
self.assertEqualDiff(
560
"""Repository branch (format: dirstate or knit)
562
shared repository: %s
563
repository branch: branch
566
control: Meta directory format 1
577
""" % (repo.bzrdir.root_transport.base,
578
format.get_branch_format().get_format_description(),
579
format.repository_format.get_format_description(),
581
self.assertEqual('', err)
583
# Create lightweight checkout
584
transport.mkdir('tree')
585
transport.mkdir('tree/lightcheckout')
586
tree2 = branch1.create_checkout('tree/lightcheckout',
588
branch2 = tree2.branch
589
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
590
shared_repo=repo, repo_branch=branch1, verbose=True)
592
# Create normal checkout
593
tree3 = branch1.create_checkout('tree/checkout')
594
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
596
light_checkout=False, repo_branch=branch1)
597
# Update lightweight checkout
598
self.build_tree(['tree/lightcheckout/a'])
600
tree2.commit('commit one')
601
rev = repo.get_revision(branch2.revision_history()[0])
602
datestring_first = format_date(rev.timestamp, rev.timezone)
603
out, err = self.run_bzr('info tree/lightcheckout --verbose')
604
self.assertEqualDiff(
605
"""Lightweight checkout (format: dirstate or dirstate-tags)
607
light checkout root: %s
608
checkout of branch: %s
609
shared repository: %s
612
control: Meta directory format 1
613
working tree: Working tree format 4
625
0 versioned subdirectories
637
""" % (tree2.bzrdir.root_transport.base,
638
tree2.branch.bzrdir.root_transport.base,
639
repo.bzrdir.root_transport.base,
640
format.get_branch_format().get_format_description(),
641
format.repository_format.get_format_description(),
642
datestring_first, datestring_first,
643
# poking at _revision_store isn't all that clean, but neither is
644
# having the ui test dependent on the exact overhead of a given store.
645
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
647
self.assertEqual('', err)
649
# Out of date checkout
650
out, err = self.run_bzr('info -v tree/checkout')
651
self.assertEqualDiff(
652
"""Checkout (format: dirstate)
655
checkout of branch: %s
658
control: Meta directory format 1
659
working tree: Working tree format 4
663
Branch is out of date: missing 1 revision.
673
0 versioned subdirectories
682
""" % (tree3.bzrdir.root_transport.base,
683
branch1.bzrdir.root_transport.base,
684
format.get_branch_format().get_format_description(),
685
format.repository_format.get_format_description(),
687
self.assertEqual('', err)
691
self.build_tree(['tree/checkout/b'])
693
out, err = self.run_bzr('info tree/checkout --verbose')
694
self.assertEqualDiff(
695
"""Checkout (format: dirstate)
698
checkout of branch: %s
701
control: Meta directory format 1
702
working tree: Working tree format 4
714
0 versioned subdirectories
726
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
727
format.get_branch_format().get_format_description(),
728
format.repository_format.get_format_description(),
729
datestring_first, datestring_first,
730
# poking at _revision_store isn't all that clean, but neither is
731
# having the ui test dependent on the exact overhead of a given store.
732
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
734
self.assertEqual('', err)
735
tree3.commit('commit two')
737
# Out of date lightweight checkout
738
rev = repo.get_revision(branch1.revision_history()[-1])
739
datestring_last = format_date(rev.timestamp, rev.timezone)
740
out, err = self.run_bzr('info tree/lightcheckout --verbose')
741
self.assertEqualDiff(
742
"""Lightweight checkout (format: dirstate or dirstate-tags)
744
light checkout root: %s
745
checkout of branch: %s
746
shared repository: %s
749
control: Meta directory format 1
750
working tree: Working tree format 4
754
Working tree is out of date: missing 1 revision.
764
0 versioned subdirectories
776
""" % (tree2.bzrdir.root_transport.base,
777
tree2.branch.bzrdir.root_transport.base,
778
repo.bzrdir.root_transport.base,
779
format.get_branch_format().get_format_description(),
780
format.repository_format.get_format_description(),
781
datestring_first, datestring_last,
782
# poking at _revision_store isn't all that clean, but neither is
783
# having the ui test dependent on the exact overhead of a given store.
784
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
786
self.assertEqual('', err)
788
# Show info about shared branch
789
out, err = self.run_bzr('info repo/branch --verbose')
790
self.assertEqualDiff(
791
"""Repository branch (format: dirstate or knit)
793
shared repository: %s
794
repository branch: branch
797
control: Meta directory format 1
811
""" % (repo.bzrdir.root_transport.base,
812
format.get_branch_format().get_format_description(),
813
format.repository_format.get_format_description(),
814
datestring_first, datestring_last,
815
# poking at _revision_store isn't all that clean, but neither is
816
# having the ui test dependent on the exact overhead of a given store.
817
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
819
self.assertEqual('', err)
821
# Show info about repository with revisions
822
out, err = self.run_bzr('info -v repo')
823
self.assertEqualDiff(
824
"""Shared repository (format: dirstate or dirstate-tags or knit)
826
shared repository: %s
829
control: Meta directory format 1
835
""" % (repo.bzrdir.root_transport.base,
836
format.repository_format.get_format_description(),
837
# poking at _revision_store isn't all that clean, but neither is
838
# having the ui test dependent on the exact overhead of a given store.
839
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
841
self.assertEqual('', err)
843
def test_info_shared_repository_with_trees(self):
844
format = bzrdir.format_registry.make_bzrdir('knit')
845
transport = self.get_transport()
847
# Create shared repository with working trees
848
repo = self.make_repository('repo', shared=True, format=format)
849
repo.set_make_working_trees(True)
850
out, err = self.run_bzr('info -v repo')
851
self.assertEqualDiff(
852
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
854
shared repository: %s
857
control: Meta directory format 1
860
Create working tree for new branches inside the repository.
865
""" % (repo.bzrdir.root_transport.base,
866
format.repository_format.get_format_description(),
868
self.assertEqual('', err)
870
# Create two branches
871
repo.bzrdir.root_transport.mkdir('branch1')
872
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
874
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
877
out, err = self.run_bzr('info repo/branch1 --verbose')
878
self.assertEqualDiff(
879
"""Repository tree (format: knit)
881
shared repository: %s
882
repository branch: branch1
885
control: Meta directory format 1
886
working tree: Working tree format 3
898
0 versioned subdirectories
907
""" % (repo.bzrdir.root_transport.base,
908
format.get_branch_format().get_format_description(),
909
format.repository_format.get_format_description(),
911
self.assertEqual('', err)
913
# Update first branch
914
self.build_tree(['repo/branch1/a'])
915
tree1 = branch1.bzrdir.open_workingtree()
917
tree1.commit('commit one')
918
rev = repo.get_revision(branch1.revision_history()[0])
919
datestring_first = format_date(rev.timestamp, rev.timezone)
920
out, err = self.run_bzr('info -v repo/branch1')
921
self.assertEqualDiff(
922
"""Repository tree (format: knit)
924
shared repository: %s
925
repository branch: branch1
928
control: Meta directory format 1
929
working tree: Working tree format 3
941
0 versioned subdirectories
953
""" % (repo.bzrdir.root_transport.base,
954
format.get_branch_format().get_format_description(),
955
format.repository_format.get_format_description(),
956
datestring_first, datestring_first,
957
# poking at _revision_store isn't all that clean, but neither is
958
# having the ui test dependent on the exact overhead of a given store.
959
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
961
self.assertEqual('', err)
963
# Out of date second branch
964
out, err = self.run_bzr('info repo/branch2 --verbose')
965
self.assertEqualDiff(
966
"""Repository tree (format: knit)
968
shared repository: %s
969
repository branch: branch2
975
control: Meta directory format 1
976
working tree: Working tree format 3
988
0 versioned subdirectories
997
""" % (repo.bzrdir.root_transport.base,
998
branch1.bzrdir.root_transport.base,
999
format.get_branch_format().get_format_description(),
1000
format.repository_format.get_format_description(),
1001
# poking at _revision_store isn't all that clean, but neither is
1002
# having the ui test dependent on the exact overhead of a given store.
1003
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1005
self.assertEqual('', err)
1007
# Update second branch
1008
tree2 = branch2.bzrdir.open_workingtree()
1010
out, err = self.run_bzr('info -v repo/branch2')
1011
self.assertEqualDiff(
1012
"""Repository tree (format: knit)
1014
shared repository: %s
1015
repository branch: branch2
1021
control: Meta directory format 1
1022
working tree: Working tree format 3
1026
In the working tree:
1034
0 versioned subdirectories
1046
""" % (repo.bzrdir.root_transport.base,
1047
branch1.bzrdir.root_transport.base,
1048
format.get_branch_format().get_format_description(),
1049
format.repository_format.get_format_description(),
1050
datestring_first, datestring_first,
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,
1055
self.assertEqual('', err)
1057
# Show info about repository with revisions
1058
out, err = self.run_bzr('info -v repo')
1059
self.assertEqualDiff(
1060
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1062
shared repository: %s
1065
control: Meta directory format 1
1068
Create working tree for new branches inside the repository.
1073
""" % (repo.bzrdir.root_transport.base,
1074
format.repository_format.get_format_description(),
1075
# poking at _revision_store isn't all that clean, but neither is
1076
# having the ui test dependent on the exact overhead of a given store.
1077
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1080
self.assertEqual('', err)
1082
def test_info_shared_repository_with_tree_in_root(self):
1083
format = bzrdir.format_registry.make_bzrdir('knit')
1084
transport = self.get_transport()
1086
# Create shared repository with working trees
1087
repo = self.make_repository('repo', shared=True, format=format)
1088
repo.set_make_working_trees(True)
1089
out, err = self.run_bzr('info -v repo')
1090
self.assertEqualDiff(
1091
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1093
shared repository: %s
1096
control: Meta directory format 1
1099
Create working tree for new branches inside the repository.
1104
""" % (repo.bzrdir.root_transport.base,
1105
format.repository_format.get_format_description(),
1107
self.assertEqual('', err)
1109
# Create branch in root of repository
1110
control = repo.bzrdir
1111
branch = control.create_branch()
1112
control.create_workingtree()
1113
out, err = self.run_bzr('info -v repo')
1114
self.assertEqualDiff(
1115
"""Repository tree (format: knit)
1117
shared repository: %s
1118
repository branch: .
1121
control: Meta directory format 1
1122
working tree: Working tree format 3
1126
In the working tree:
1134
0 versioned subdirectories
1143
""" % (repo.bzrdir.root_transport.base,
1144
format.get_branch_format().get_format_description(),
1145
format.repository_format.get_format_description(),
1147
self.assertEqual('', err)
1149
def assertCheckoutStatusOutput(self,
1150
command_string, lco_tree, shared_repo=None,
1153
branch_locked=False, repo_locked=False,
1155
light_checkout=True,
1156
checkout_root=None):
1157
"""Check the output of info in a checkout.
1159
This is not quite a mirror of the info code: rather than using the
1160
tree being examined to predict output, it uses a bunch of flags which
1161
allow us, the test writers, to document what *should* be present in
1162
the output. Removing this separation would remove the value of the
1165
:param path: the path to the light checkout.
1166
:param lco_tree: the tree object for the light checkout.
1167
:param shared_repo: A shared repository is in use, expect that in
1169
:param repo_branch: A branch in a shared repository for non light
1171
:param tree_locked: If true, expect the tree to be locked.
1172
:param branch_locked: If true, expect the branch to be locked.
1173
:param repo_locked: If true, expect the repository to be locked.
1174
:param verbose: If true, expect verbose output
1176
if tree_locked and sys.platform == 'win32':
1177
# We expect this to fail because of locking errors. (A write-locked
1178
# file cannot be read-locked in the same process).
1179
# This should be removed when the locking errors are fixed.
1180
args = command_string.split(' ')
1181
self.run_bzr_error([], 'info', *args)
1183
out, err = self.run_bzr('info %s' % command_string)
1185
(True, True): 'Lightweight checkout',
1186
(True, False): 'Repository checkout',
1187
(False, True): 'Lightweight checkout',
1188
(False, False): 'Checkout',
1189
}[(shared_repo is not None, light_checkout)]
1190
format = {True: 'dirstate or dirstate-tags',
1191
False: 'dirstate'}[light_checkout]
1192
if repo_locked or branch_locked or tree_locked:
1193
def locked_message(a_bool):
1198
expected_lock_output = (
1201
" working tree: %s\n"
1203
" repository: %s\n" % (
1204
locked_message(tree_locked),
1205
locked_message(branch_locked),
1206
locked_message(repo_locked)))
1208
expected_lock_output = ''
1212
tree_data = (" light checkout root: %s\n" %
1213
lco_tree.bzrdir.root_transport.base)
1215
if lco_tree.branch.get_bound_location() is not None:
1216
tree_data += ("%s checkout root: %s\n" % (extra_space,
1217
lco_tree.branch.bzrdir.root_transport.base))
1218
if shared_repo is not None:
1220
" checkout of branch: %s\n"
1221
" shared repository: %s\n" %
1222
(repo_branch.bzrdir.root_transport.base,
1223
shared_repo.bzrdir.root_transport.base))
1224
elif repo_branch is not None:
1226
"%s checkout of branch: %s\n" %
1228
repo_branch.bzrdir.root_transport.base))
1230
branch_data = (" checkout of branch: %s\n" %
1231
lco_tree.branch.bzrdir.root_transport.base)
1234
verbose_info = ' 0 committers\n'
1238
self.assertEqualDiff(
1243
control: Meta directory format 1
1248
In the working tree:
1256
0 versioned subdirectories
1268
lco_tree._format.get_format_description(),
1269
lco_tree.branch._format.get_format_description(),
1270
lco_tree.branch.repository._format.get_format_description(),
1271
expected_lock_output,
1274
self.assertEqual('', err)
1276
def test_info_locking(self):
1277
transport = self.get_transport()
1278
# Create shared repository with a branch
1279
repo = self.make_repository('repo', shared=True,
1280
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1281
repo.set_make_working_trees(False)
1282
repo.bzrdir.root_transport.mkdir('branch')
1283
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1284
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1285
# Do a heavy checkout
1286
transport.mkdir('tree')
1287
transport.mkdir('tree/checkout')
1288
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1289
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1290
co_branch.bind(repo_branch)
1291
# Do a light checkout of the heavy one
1292
transport.mkdir('tree/lightcheckout')
1293
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1294
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1295
lco_dir.create_workingtree()
1296
lco_tree = lco_dir.open_workingtree()
1298
# Test all permutations of locking the working tree, branch and repository
1302
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1303
repo_branch=repo_branch,
1304
verbose=True, light_checkout=True)
1306
lco_tree.branch.repository.lock_write()
1308
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1309
lco_tree, repo_branch=repo_branch,
1310
repo_locked=True, verbose=True, light_checkout=True)
1312
lco_tree.branch.repository.unlock()
1314
lco_tree.branch.lock_write()
1316
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1320
repo_branch=repo_branch,
1323
lco_tree.branch.unlock()
1325
lco_tree.lock_write()
1327
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1328
lco_tree, repo_branch=repo_branch,
1336
lco_tree.lock_write()
1337
lco_tree.branch.repository.unlock()
1339
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1340
lco_tree, repo_branch=repo_branch,
1345
lco_tree.branch.repository.lock_write()
1348
lco_tree.lock_write()
1349
lco_tree.branch.unlock()
1351
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1352
lco_tree, repo_branch=repo_branch,
1356
lco_tree.branch.lock_write()
1359
lco_tree.lock_write()
1360
lco_tree.branch.unlock()
1361
lco_tree.branch.repository.lock_write()
1363
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1364
lco_tree, repo_branch=repo_branch,
1369
lco_tree.branch.repository.unlock()
1370
lco_tree.branch.lock_write()
1373
lco_tree.branch.lock_write()
1374
lco_tree.branch.repository.unlock()
1376
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1377
lco_tree, repo_branch=repo_branch,
1381
lco_tree.branch.repository.lock_write()
1382
lco_tree.branch.unlock()
1384
if sys.platform == 'win32':
1385
self.knownFailure('Win32 cannot run "bzr info"'
1386
' when the tree is locked.')
1388
def test_info_locking_oslocks(self):
1389
if sys.platform == "win32":
1390
raise TestSkipped("don't use oslocks on win32 in unix manner")
1392
tree = self.make_branch_and_tree('branch',
1393
format=bzrlib.bzrdir.BzrDirFormat6())
1395
# Test all permutations of locking the working tree, branch and repository
1396
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1397
# implemented by raising NotImplementedError and get_physical_lock_status()
1398
# always returns false. This makes bzr info hide the lock status. (Olaf)
1402
out, err = self.run_bzr('info -v branch')
1403
self.assertEqualDiff(
1404
"""Standalone tree (format: weave)
1409
control: All-in-one format 6
1410
working tree: Working tree format 2
1411
branch: Branch format 4
1414
In the working tree:
1422
0 versioned subdirectories
1431
""" % (tree.bzrdir.root_transport.base,
1432
tree.branch.repository._format.get_format_description(),
1434
self.assertEqual('', err)
1437
out, err = self.run_bzr('info -v branch')
1438
self.assertEqualDiff(
1439
"""Standalone tree (format: weave)
1444
control: All-in-one format 6
1445
working tree: Working tree format 2
1446
branch: Branch format 4
1449
In the working tree:
1457
0 versioned subdirectories
1466
""" % (tree.bzrdir.root_transport.base,
1467
tree.branch.repository._format.get_format_description(),
1469
self.assertEqual('', err)