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."""
32
from bzrlib.osutils import format_date
33
from bzrlib.tests import TestSkipped
34
from bzrlib.tests.blackbox import ExternalBase
37
class TestInfo(ExternalBase):
39
def test_info_non_existing(self):
40
if sys.platform == "win32":
41
location = "C:/i/do/not/exist/"
43
location = "/i/do/not/exist/"
44
out, err = self.run_bzr('info '+location, retcode=3)
45
self.assertEqual(out, '')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
48
def test_info_standalone(self):
49
transport = self.get_transport()
51
# Create initial standalone branch
52
tree1 = self.make_branch_and_tree('standalone', 'weave')
53
self.build_tree(['standalone/a'])
55
branch1 = tree1.branch
57
out, err = self.run_bzr('info standalone')
59
"""Standalone tree (format: weave)
61
branch root: standalone
63
self.assertEqual('', err)
65
out, err = self.run_bzr('info standalone -v')
67
"""Standalone tree (format: weave)
69
branch root: standalone
72
control: All-in-one format 6
73
working tree: Working tree format 2
74
branch: Branch format 4
75
repository: Weave repository format 6
85
0 versioned subdirectories
95
self.assertEqual('', err)
96
tree1.commit('commit one')
97
rev = branch1.repository.get_revision(branch1.revision_history()[0])
98
datestring_first = format_date(rev.timestamp, rev.timezone)
100
# Branch standalone with push location
101
branch2 = branch1.bzrdir.sprout('branch').open_branch()
102
branch2.set_push_location(branch1.bzrdir.root_transport.base)
104
out, err = self.run_bzr('info branch')
105
self.assertEqualDiff(
106
"""Standalone tree (format: weave)
111
push branch: standalone
112
parent branch: standalone
114
self.assertEqual('', err)
116
out, err = self.run_bzr('info branch --verbose')
117
self.assertEqualDiff(
118
"""Standalone tree (format: weave)
123
push branch: standalone
124
parent branch: standalone
127
control: All-in-one format 6
128
working tree: Working tree format 2
129
branch: Branch format 4
130
repository: Weave repository format 6
140
0 versioned subdirectories
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: standalone
176
parent branch: standalone
179
control: Meta directory format 1
192
0 versioned subdirectories
204
""" % (bound_tree._format.get_format_description(),
205
branch3._format.get_format_description(),
206
branch3.repository._format.get_format_description(),
207
datestring_first, datestring_first,
208
# poking at _revision_store isn't all that clean, but neither is
209
# having the ui test dependent on the exact overhead of a given store.
210
branch3.repository._revision_store.total_size(
211
branch3.repository.get_transaction())[1] / 1024,
213
self.assertEqual('', err)
215
# Checkout standalone (same as above, but does not have parent set)
216
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
218
branch4.bind(branch1)
219
branch4.bzrdir.open_workingtree().update()
220
out, err = self.run_bzr('info checkout --verbose')
221
self.assertEqualDiff(
222
"""Checkout (format: knit)
224
checkout root: checkout
225
checkout of branch: standalone
228
control: Meta directory format 1
229
working tree: Working tree format 3
230
branch: Branch format 5
241
0 versioned subdirectories
253
""" % (branch4.repository._format.get_format_description(),
254
datestring_first, datestring_first,
255
# poking at _revision_store isn't all that clean, but neither is
256
# having the ui test dependent on the exact overhead of a given store.
257
branch4.repository._revision_store.total_size(
258
branch4.repository.get_transaction())[1] / 1024,
260
self.assertEqual('', err)
262
# Lightweight checkout (same as above, different branch and repository)
263
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
264
branch5 = tree5.branch
265
out, err = self.run_bzr('info -v lightcheckout')
266
self.assertEqualDiff(
267
"""Lightweight checkout (format: dirstate or dirstate-tags or \
268
pack-0.92 or rich-root or rich-root-pack)
270
light checkout root: lightcheckout
271
checkout of branch: standalone
274
control: Meta directory format 1
275
working tree: Working tree format 4
276
branch: Branch format 4
277
repository: Weave repository format 6
287
0 versioned subdirectories
299
""" % (datestring_first, datestring_first,), out)
300
self.assertEqual('', err)
302
# Update initial standalone branch
303
self.build_tree(['standalone/b'])
305
tree1.commit('commit two')
306
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
307
datestring_last = format_date(rev.timestamp, rev.timezone)
309
# Out of date branched standalone branch will not be detected
310
out, err = self.run_bzr('info -v branch')
311
self.assertEqualDiff(
312
"""Standalone tree (format: weave)
317
push branch: standalone
318
parent branch: standalone
321
control: All-in-one format 6
322
working tree: Working tree format 2
323
branch: Branch format 4
324
repository: Weave repository format 6
334
0 versioned subdirectories
346
""" % (datestring_first, datestring_first,
348
self.assertEqual('', err)
350
# Out of date bound branch
351
out, err = self.run_bzr('info -v bound')
352
self.assertEqualDiff(
353
"""Checkout (format: knit)
356
checkout of branch: standalone
359
parent branch: standalone
362
control: Meta directory format 1
363
working tree: Working tree format 3
364
branch: Branch format 5
367
Branch is out of date: missing 1 revision.
377
0 versioned subdirectories
389
""" % (branch3.repository._format.get_format_description(),
390
datestring_first, datestring_first,
391
# poking at _revision_store isn't all that clean, but neither is
392
# having the ui test dependent on the exact overhead of a given store.
393
branch3.repository._revision_store.total_size(
394
branch3.repository.get_transaction())[1] / 1024,
396
self.assertEqual('', err)
398
# Out of date checkout
399
out, err = self.run_bzr('info -v checkout')
400
self.assertEqualDiff(
401
"""Checkout (format: knit)
403
checkout root: checkout
404
checkout of branch: standalone
407
control: Meta directory format 1
408
working tree: Working tree format 3
409
branch: Branch format 5
412
Branch is out of date: missing 1 revision.
422
0 versioned subdirectories
434
""" % (branch4.repository._format.get_format_description(),
435
datestring_first, datestring_first,
436
# poking at _revision_store isn't all that clean, but neither is
437
# having the ui test dependent on the exact overhead of a given store.
438
branch4.repository._revision_store.total_size(
439
branch4.repository.get_transaction())[1] / 1024,
441
self.assertEqual('', err)
443
# Out of date lightweight checkout
444
out, err = self.run_bzr('info lightcheckout --verbose')
445
self.assertEqualDiff(
446
"""Lightweight checkout (format: dirstate or dirstate-tags or \
447
pack-0.92 or rich-root or rich-root-pack)
449
light checkout root: lightcheckout
450
checkout of branch: standalone
453
control: Meta directory format 1
454
working tree: Working tree format 4
455
branch: Branch format 4
456
repository: Weave repository format 6
458
Working tree is out of date: missing 1 revision.
468
0 versioned subdirectories
480
""" % (datestring_first, datestring_last,), out)
481
self.assertEqual('', err)
483
def test_info_standalone_no_tree(self):
484
# create standalone branch without a working tree
485
format = bzrdir.format_registry.make_bzrdir('default')
486
branch = self.make_branch('branch')
487
repo = branch.repository
488
out, err = self.run_bzr('info branch -v')
489
self.assertEqualDiff(
490
"""Standalone branch (format: %s)
495
control: Meta directory format 1
506
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
507
format.get_branch_format().get_format_description(),
508
format.repository_format.get_format_description(),
510
self.assertEqual('', err)
512
def test_info_shared_repository(self):
513
format = bzrdir.format_registry.make_bzrdir('knit')
514
transport = self.get_transport()
516
# Create shared repository
517
repo = self.make_repository('repo', shared=True, format=format)
518
repo.set_make_working_trees(False)
519
out, err = self.run_bzr('info -v repo')
520
self.assertEqualDiff(
521
"""Shared repository (format: dirstate or dirstate-tags or knit)
523
shared repository: %s
526
control: Meta directory format 1
532
""" % ('repo', format.repository_format.get_format_description(),
534
self.assertEqual('', err)
536
# Create branch inside shared repository
537
repo.bzrdir.root_transport.mkdir('branch')
538
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
540
out, err = self.run_bzr('info -v repo/branch')
541
self.assertEqualDiff(
542
"""Repository branch (format: dirstate or knit)
544
shared repository: repo
545
repository branch: repo/branch
548
control: Meta directory format 1
559
""" % (format.get_branch_format().get_format_description(),
560
format.repository_format.get_format_description(),
562
self.assertEqual('', err)
564
# Create lightweight checkout
565
transport.mkdir('tree')
566
transport.mkdir('tree/lightcheckout')
567
tree2 = branch1.create_checkout('tree/lightcheckout',
569
branch2 = tree2.branch
570
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
571
shared_repo=repo, repo_branch=branch1, verbose=True)
573
# Create normal checkout
574
tree3 = branch1.create_checkout('tree/checkout')
575
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
577
light_checkout=False, repo_branch=branch1)
578
# Update lightweight checkout
579
self.build_tree(['tree/lightcheckout/a'])
581
tree2.commit('commit one')
582
rev = repo.get_revision(branch2.revision_history()[0])
583
datestring_first = format_date(rev.timestamp, rev.timezone)
584
out, err = self.run_bzr('info tree/lightcheckout --verbose')
585
self.assertEqualDiff(
586
"""Lightweight checkout (format: dirstate or dirstate-tags or \
587
pack-0.92 or rich-root or rich-root-pack)
589
light checkout root: tree/lightcheckout
590
checkout of branch: repo/branch
591
shared repository: repo
594
control: Meta directory format 1
595
working tree: Working tree format 4
607
0 versioned subdirectories
619
""" % (format.get_branch_format().get_format_description(),
620
format.repository_format.get_format_description(),
621
datestring_first, datestring_first,
622
# poking at _revision_store isn't all that clean, but neither is
623
# having the ui test dependent on the exact overhead of a given store.
624
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
626
self.assertEqual('', err)
628
# Out of date checkout
629
out, err = self.run_bzr('info -v tree/checkout')
630
self.assertEqualDiff(
631
"""Checkout (format: dirstate)
633
checkout root: tree/checkout
634
checkout of branch: repo/branch
637
control: Meta directory format 1
638
working tree: Working tree format 4
642
Branch is out of date: missing 1 revision.
652
0 versioned subdirectories
661
""" % (format.get_branch_format().get_format_description(),
662
format.repository_format.get_format_description(),
664
self.assertEqual('', err)
668
self.build_tree(['tree/checkout/b'])
670
out, err = self.run_bzr('info tree/checkout --verbose')
671
self.assertEqualDiff(
672
"""Checkout (format: dirstate)
674
checkout root: tree/checkout
675
checkout of branch: repo/branch
678
control: Meta directory format 1
679
working tree: Working tree format 4
691
0 versioned subdirectories
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 or \
719
pack-0.92 or rich-root or rich-root-pack)
721
light checkout root: tree/lightcheckout
722
checkout of branch: repo/branch
723
shared repository: repo
726
control: Meta directory format 1
727
working tree: Working tree format 4
731
Working tree is out of date: missing 1 revision.
741
0 versioned subdirectories
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.run_bzr('info repo/branch --verbose')
764
self.assertEqualDiff(
765
"""Repository branch (format: dirstate or knit)
767
shared repository: repo
768
repository branch: repo/branch
771
control: Meta directory format 1
785
""" % (format.get_branch_format().get_format_description(),
786
format.repository_format.get_format_description(),
787
datestring_first, datestring_last,
788
# poking at _revision_store isn't all that clean, but neither is
789
# having the ui test dependent on the exact overhead of a given store.
790
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
792
self.assertEqual('', err)
794
# Show info about repository with revisions
795
out, err = self.run_bzr('info -v repo')
796
self.assertEqualDiff(
797
"""Shared repository (format: dirstate or dirstate-tags or knit)
799
shared repository: repo
802
control: Meta directory format 1
808
""" % (format.repository_format.get_format_description(),
809
# poking at _revision_store isn't all that clean, but neither is
810
# having the ui test dependent on the exact overhead of a given store.
811
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
813
self.assertEqual('', err)
815
def test_info_shared_repository_with_trees(self):
816
format = bzrdir.format_registry.make_bzrdir('knit')
817
transport = self.get_transport()
819
# Create shared repository with working trees
820
repo = self.make_repository('repo', shared=True, format=format)
821
repo.set_make_working_trees(True)
822
out, err = self.run_bzr('info -v repo')
823
self.assertEqualDiff(
824
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
826
shared repository: repo
829
control: Meta directory format 1
832
Create working tree for new branches inside the repository.
837
""" % (format.repository_format.get_format_description(),
839
self.assertEqual('', err)
841
# Create two branches
842
repo.bzrdir.root_transport.mkdir('branch1')
843
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
845
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
848
out, err = self.run_bzr('info repo/branch1 --verbose')
849
self.assertEqualDiff(
850
"""Repository tree (format: knit)
852
shared repository: repo
853
repository branch: repo/branch1
856
control: Meta directory format 1
857
working tree: Working tree format 3
869
0 versioned subdirectories
878
""" % (format.get_branch_format().get_format_description(),
879
format.repository_format.get_format_description(),
881
self.assertEqual('', err)
883
# Update first branch
884
self.build_tree(['repo/branch1/a'])
885
tree1 = branch1.bzrdir.open_workingtree()
887
tree1.commit('commit one')
888
rev = repo.get_revision(branch1.revision_history()[0])
889
datestring_first = format_date(rev.timestamp, rev.timezone)
890
out, err = self.run_bzr('info -v repo/branch1')
891
self.assertEqualDiff(
892
"""Repository tree (format: knit)
894
shared repository: repo
895
repository branch: repo/branch1
898
control: Meta directory format 1
899
working tree: Working tree format 3
911
0 versioned subdirectories
923
""" % (format.get_branch_format().get_format_description(),
924
format.repository_format.get_format_description(),
925
datestring_first, datestring_first,
926
# poking at _revision_store isn't all that clean, but neither is
927
# having the ui test dependent on the exact overhead of a given store.
928
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
930
self.assertEqual('', err)
932
# Out of date second branch
933
out, err = self.run_bzr('info repo/branch2 --verbose')
934
self.assertEqualDiff(
935
"""Repository tree (format: knit)
937
shared repository: repo
938
repository branch: repo/branch2
941
parent branch: repo/branch1
944
control: Meta directory format 1
945
working tree: Working tree format 3
957
0 versioned subdirectories
966
""" % (format.get_branch_format().get_format_description(),
967
format.repository_format.get_format_description(),
968
# poking at _revision_store isn't all that clean, but neither is
969
# having the ui test dependent on the exact overhead of a given store.
970
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
972
self.assertEqual('', err)
974
# Update second branch
975
tree2 = branch2.bzrdir.open_workingtree()
977
out, err = self.run_bzr('info -v repo/branch2')
978
self.assertEqualDiff(
979
"""Repository tree (format: knit)
981
shared repository: repo
982
repository branch: repo/branch2
985
parent branch: repo/branch1
988
control: Meta directory format 1
989
working tree: Working tree format 3
1001
0 versioned subdirectories
1013
""" % (format.get_branch_format().get_format_description(),
1014
format.repository_format.get_format_description(),
1015
datestring_first, datestring_first,
1016
# poking at _revision_store isn't all that clean, but neither is
1017
# having the ui test dependent on the exact overhead of a given store.
1018
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1020
self.assertEqual('', err)
1022
# Show info about repository with revisions
1023
out, err = self.run_bzr('info -v repo')
1024
self.assertEqualDiff(
1025
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1027
shared repository: repo
1030
control: Meta directory format 1
1033
Create working tree for new branches inside the repository.
1038
""" % (format.repository_format.get_format_description(),
1039
# poking at _revision_store isn't all that clean, but neither is
1040
# having the ui test dependent on the exact overhead of a given store.
1041
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1044
self.assertEqual('', err)
1046
def test_info_shared_repository_with_tree_in_root(self):
1047
format = bzrdir.format_registry.make_bzrdir('knit')
1048
transport = self.get_transport()
1050
# Create shared repository with working trees
1051
repo = self.make_repository('repo', shared=True, format=format)
1052
repo.set_make_working_trees(True)
1053
out, err = self.run_bzr('info -v repo')
1054
self.assertEqualDiff(
1055
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1057
shared repository: repo
1060
control: Meta directory format 1
1063
Create working tree for new branches inside the repository.
1068
""" % (format.repository_format.get_format_description(),
1070
self.assertEqual('', err)
1072
# Create branch in root of repository
1073
control = repo.bzrdir
1074
branch = control.create_branch()
1075
control.create_workingtree()
1076
out, err = self.run_bzr('info -v repo')
1077
self.assertEqualDiff(
1078
"""Repository tree (format: knit)
1080
shared repository: repo
1081
repository branch: repo
1084
control: Meta directory format 1
1085
working tree: Working tree format 3
1089
In the working tree:
1097
0 versioned subdirectories
1106
""" % (format.get_branch_format().get_format_description(),
1107
format.repository_format.get_format_description(),
1109
self.assertEqual('', err)
1111
def assertCheckoutStatusOutput(self,
1112
command_string, lco_tree, shared_repo=None,
1115
branch_locked=False, repo_locked=False,
1117
light_checkout=True,
1118
checkout_root=None):
1119
"""Check the output of info in a checkout.
1121
This is not quite a mirror of the info code: rather than using the
1122
tree being examined to predict output, it uses a bunch of flags which
1123
allow us, the test writers, to document what *should* be present in
1124
the output. Removing this separation would remove the value of the
1127
:param path: the path to the light checkout.
1128
:param lco_tree: the tree object for the light checkout.
1129
:param shared_repo: A shared repository is in use, expect that in
1131
:param repo_branch: A branch in a shared repository for non light
1133
:param tree_locked: If true, expect the tree to be locked.
1134
:param branch_locked: If true, expect the branch to be locked.
1135
:param repo_locked: If true, expect the repository to be locked.
1136
Note that the lco_tree.branch.repository is inspected, and if is not
1137
actually locked then this parameter is overridden. This is because
1138
pack repositories do not have any public API for obtaining an
1139
exclusive repository wide lock.
1140
:param verbose: If true, expect verbose output
1142
def friendly_location(url):
1143
path = urlutils.unescape_for_display(url, 'ascii')
1145
return osutils.relpath(osutils.getcwd(), path)
1146
except errors.PathNotChild:
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
self.run_bzr_error([], 'info ' + command_string)
1155
out, err = self.run_bzr('info %s' % command_string)
1157
(True, True): 'Lightweight checkout',
1158
(True, False): 'Repository checkout',
1159
(False, True): 'Lightweight checkout',
1160
(False, False): 'Checkout',
1161
}[(shared_repo is not None, light_checkout)]
1162
format = {True: 'dirstate or dirstate-tags or pack-0.92'
1163
' or rich-root or rich-root-pack',
1164
False: 'dirstate'}[light_checkout]
1166
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1167
if repo_locked or branch_locked or tree_locked:
1168
def locked_message(a_bool):
1173
expected_lock_output = (
1176
" working tree: %s\n"
1178
" repository: %s\n" % (
1179
locked_message(tree_locked),
1180
locked_message(branch_locked),
1181
locked_message(repo_locked)))
1183
expected_lock_output = ''
1187
tree_data = (" light checkout root: %s\n" %
1188
friendly_location(lco_tree.bzrdir.root_transport.base))
1190
if lco_tree.branch.get_bound_location() is not None:
1191
tree_data += ("%s checkout root: %s\n" % (extra_space,
1192
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1193
if shared_repo is not None:
1195
" checkout of branch: %s\n"
1196
" shared repository: %s\n" %
1197
(friendly_location(repo_branch.bzrdir.root_transport.base),
1198
friendly_location(shared_repo.bzrdir.root_transport.base)))
1199
elif repo_branch is not None:
1201
"%s checkout of branch: %s\n" %
1203
friendly_location(repo_branch.bzrdir.root_transport.base)))
1205
branch_data = (" checkout of branch: %s\n" %
1206
lco_tree.branch.bzrdir.root_transport.base)
1209
verbose_info = ' 0 committers\n'
1213
self.assertEqualDiff(
1218
control: Meta directory format 1
1223
In the working tree:
1231
0 versioned subdirectories
1243
lco_tree._format.get_format_description(),
1244
lco_tree.branch._format.get_format_description(),
1245
lco_tree.branch.repository._format.get_format_description(),
1246
expected_lock_output,
1249
self.assertEqual('', err)
1251
def test_info_locking(self):
1252
transport = self.get_transport()
1253
# Create shared repository with a branch
1254
repo = self.make_repository('repo', shared=True,
1255
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1256
repo.set_make_working_trees(False)
1257
repo.bzrdir.root_transport.mkdir('branch')
1258
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1259
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1260
# Do a heavy checkout
1261
transport.mkdir('tree')
1262
transport.mkdir('tree/checkout')
1263
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1264
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1265
co_branch.bind(repo_branch)
1266
# Do a light checkout of the heavy one
1267
transport.mkdir('tree/lightcheckout')
1268
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1269
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1270
lco_dir.create_workingtree()
1271
lco_tree = lco_dir.open_workingtree()
1273
# Test all permutations of locking the working tree, branch and repository
1277
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1278
repo_branch=repo_branch,
1279
verbose=True, light_checkout=True)
1281
lco_tree.branch.repository.lock_write()
1283
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1284
lco_tree, repo_branch=repo_branch,
1285
repo_locked=True, verbose=True, light_checkout=True)
1287
lco_tree.branch.repository.unlock()
1289
lco_tree.branch.lock_write()
1291
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1295
repo_branch=repo_branch,
1298
lco_tree.branch.unlock()
1300
lco_tree.lock_write()
1302
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1303
lco_tree, repo_branch=repo_branch,
1311
lco_tree.lock_write()
1312
lco_tree.branch.repository.unlock()
1314
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1315
lco_tree, repo_branch=repo_branch,
1320
lco_tree.branch.repository.lock_write()
1323
lco_tree.lock_write()
1324
lco_tree.branch.unlock()
1326
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1327
lco_tree, repo_branch=repo_branch,
1331
lco_tree.branch.lock_write()
1334
lco_tree.lock_write()
1335
lco_tree.branch.unlock()
1336
lco_tree.branch.repository.lock_write()
1338
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1339
lco_tree, repo_branch=repo_branch,
1344
lco_tree.branch.repository.unlock()
1345
lco_tree.branch.lock_write()
1348
lco_tree.branch.lock_write()
1349
lco_tree.branch.repository.unlock()
1351
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1352
lco_tree, repo_branch=repo_branch,
1356
lco_tree.branch.repository.lock_write()
1357
lco_tree.branch.unlock()
1359
if sys.platform == 'win32':
1360
self.knownFailure('Win32 cannot run "bzr info"'
1361
' when the tree is locked.')
1363
def test_info_locking_oslocks(self):
1364
if sys.platform == "win32":
1365
raise TestSkipped("don't use oslocks on win32 in unix manner")
1367
tree = self.make_branch_and_tree('branch',
1368
format=bzrlib.bzrdir.BzrDirFormat6())
1370
# Test all permutations of locking the working tree, branch and repository
1371
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1372
# implemented by raising NotImplementedError and get_physical_lock_status()
1373
# always returns false. This makes bzr info hide the lock status. (Olaf)
1377
out, err = self.run_bzr('info -v branch')
1378
self.assertEqualDiff(
1379
"""Standalone tree (format: weave)
1384
control: All-in-one format 6
1385
working tree: Working tree format 2
1386
branch: Branch format 4
1389
In the working tree:
1397
0 versioned subdirectories
1406
""" % ('branch', tree.branch.repository._format.get_format_description(),
1408
self.assertEqual('', err)
1411
out, err = self.run_bzr('info -v branch')
1412
self.assertEqualDiff(
1413
"""Standalone tree (format: weave)
1418
control: All-in-one format 6
1419
working tree: Working tree format 2
1420
branch: Branch format 4
1423
In the working tree:
1431
0 versioned subdirectories
1440
""" % ('branch', tree.branch.repository._format.get_format_description(),
1442
self.assertEqual('', err)