1
# Copyright (C) 2006, 2007, 2008 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."""
31
from bzrlib.osutils import format_date
32
from bzrlib.tests import TestSkipped
33
from bzrlib.tests.blackbox import ExternalBase
36
class TestInfo(ExternalBase):
38
def test_info_non_existing(self):
39
if sys.platform == "win32":
40
location = "C:/i/do/not/exist/"
42
location = "/i/do/not/exist/"
43
out, err = self.run_bzr('info '+location, retcode=3)
44
self.assertEqual(out, '')
45
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
47
def test_info_standalone(self):
48
transport = self.get_transport()
50
# Create initial standalone branch
51
tree1 = self.make_branch_and_tree('standalone', 'weave')
52
self.build_tree(['standalone/a'])
54
branch1 = tree1.branch
56
out, err = self.run_bzr('info standalone')
58
"""Standalone tree (format: weave)
60
branch root: standalone
62
self.assertEqual('', err)
64
out, err = self.run_bzr('info standalone -v')
66
"""Standalone tree (format: weave)
68
branch root: standalone
71
control: All-in-one format 6
72
working tree: Working tree format 2
73
branch: Branch format 4
74
repository: Weave repository format 6
84
0 versioned subdirectories
93
self.assertEqual('', err)
94
tree1.commit('commit one')
95
rev = branch1.repository.get_revision(branch1.revision_history()[0])
96
datestring_first = format_date(rev.timestamp, rev.timezone)
98
# Branch standalone with push location
99
branch2 = branch1.bzrdir.sprout('branch').open_branch()
100
branch2.set_push_location(branch1.bzrdir.root_transport.base)
102
out, err = self.run_bzr('info branch')
103
self.assertEqualDiff(
104
"""Standalone tree (format: weave)
109
push branch: standalone
110
parent branch: standalone
112
self.assertEqual('', err)
114
out, err = self.run_bzr('info branch --verbose')
115
self.assertEqualDiff(
116
"""Standalone tree (format: weave)
121
push branch: standalone
122
parent branch: standalone
125
control: All-in-one format 6
126
working tree: Working tree format 2
127
branch: Branch format 4
128
repository: Weave repository format 6
138
0 versioned subdirectories
149
""" % (datestring_first, datestring_first,
151
self.assertEqual('', err)
153
# Branch and bind to standalone, needs upgrade to metadir
154
# (creates backup as unknown)
155
branch1.bzrdir.sprout('bound')
156
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
157
upgrade.upgrade('bound', knit1_format)
158
branch3 = bzrdir.BzrDir.open('bound').open_branch()
159
branch3.bind(branch1)
160
bound_tree = branch3.bzrdir.open_workingtree()
161
out, err = self.run_bzr('info -v bound')
162
self.assertEqualDiff(
163
"""Checkout (format: knit)
166
checkout of branch: standalone
169
parent branch: standalone
172
control: Meta directory format 1
185
0 versioned subdirectories
196
""" % (bound_tree._format.get_format_description(),
197
branch3._format.get_format_description(),
198
branch3.repository._format.get_format_description(),
199
datestring_first, datestring_first,
201
self.assertEqual('', err)
203
# Checkout standalone (same as above, but does not have parent set)
204
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
206
branch4.bind(branch1)
207
branch4.bzrdir.open_workingtree().update()
208
out, err = self.run_bzr('info checkout --verbose')
209
self.assertEqualDiff(
210
"""Checkout (format: knit)
212
checkout root: checkout
213
checkout of branch: standalone
216
control: Meta directory format 1
217
working tree: Working tree format 3
218
branch: Branch format 5
229
0 versioned subdirectories
240
""" % (branch4.repository._format.get_format_description(),
241
datestring_first, datestring_first,
243
self.assertEqual('', err)
245
# Lightweight checkout (same as above, different branch and repository)
246
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
247
branch5 = tree5.branch
248
out, err = self.run_bzr('info -v lightcheckout')
249
self.assertEqualDiff(
250
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root \
251
or 1.9 or 1.9-rich-root \
252
or dirstate or dirstate-tags or \
253
pack-0.92 or rich-root or rich-root-pack)
255
light checkout root: lightcheckout
256
checkout of branch: standalone
259
control: Meta directory format 1
260
working tree: Working tree format 4
261
branch: Branch format 4
262
repository: Weave repository format 6
272
0 versioned subdirectories
283
""" % (datestring_first, datestring_first,), out)
284
self.assertEqual('', err)
286
# Update initial standalone branch
287
self.build_tree(['standalone/b'])
289
tree1.commit('commit two')
290
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
291
datestring_last = format_date(rev.timestamp, rev.timezone)
293
# Out of date branched standalone branch will not be detected
294
out, err = self.run_bzr('info -v branch')
295
self.assertEqualDiff(
296
"""Standalone tree (format: weave)
301
push branch: standalone
302
parent branch: standalone
305
control: All-in-one format 6
306
working tree: Working tree format 2
307
branch: Branch format 4
308
repository: Weave repository format 6
318
0 versioned subdirectories
329
""" % (datestring_first, datestring_first,
331
self.assertEqual('', err)
333
# Out of date bound branch
334
out, err = self.run_bzr('info -v bound')
335
self.assertEqualDiff(
336
"""Checkout (format: knit)
339
checkout of branch: standalone
342
parent branch: standalone
345
control: Meta directory format 1
346
working tree: Working tree format 3
347
branch: Branch format 5
350
Branch is out of date: missing 1 revision.
360
0 versioned subdirectories
371
""" % (branch3.repository._format.get_format_description(),
372
datestring_first, datestring_first,
374
self.assertEqual('', err)
376
# Out of date checkout
377
out, err = self.run_bzr('info -v checkout')
378
self.assertEqualDiff(
379
"""Checkout (format: knit)
381
checkout root: checkout
382
checkout of branch: standalone
385
control: Meta directory format 1
386
working tree: Working tree format 3
387
branch: Branch format 5
390
Branch is out of date: missing 1 revision.
400
0 versioned subdirectories
411
""" % (branch4.repository._format.get_format_description(),
412
datestring_first, datestring_first,
414
self.assertEqual('', err)
416
# Out of date lightweight checkout
417
out, err = self.run_bzr('info lightcheckout --verbose')
418
self.assertEqualDiff(
419
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
420
1.9 or 1.9-rich-root or \
421
dirstate or dirstate-tags or \
422
pack-0.92 or rich-root or rich-root-pack)
424
light checkout root: lightcheckout
425
checkout of branch: standalone
428
control: Meta directory format 1
429
working tree: Working tree format 4
430
branch: Branch format 4
431
repository: Weave repository format 6
433
Working tree is out of date: missing 1 revision.
443
0 versioned subdirectories
454
""" % (datestring_first, datestring_last,), out)
455
self.assertEqual('', err)
457
def test_info_standalone_no_tree(self):
458
# create standalone branch without a working tree
459
format = bzrdir.format_registry.make_bzrdir('default')
460
branch = self.make_branch('branch')
461
repo = branch.repository
462
out, err = self.run_bzr('info branch -v')
463
self.assertEqualDiff(
464
"""Standalone branch (format: %s)
469
control: Meta directory format 1
479
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
480
format.get_branch_format().get_format_description(),
481
format.repository_format.get_format_description(),
483
self.assertEqual('', err)
485
def test_info_shared_repository(self):
486
format = bzrdir.format_registry.make_bzrdir('knit')
487
transport = self.get_transport()
489
# Create shared repository
490
repo = self.make_repository('repo', shared=True, format=format)
491
repo.set_make_working_trees(False)
492
out, err = self.run_bzr('info -v repo')
493
self.assertEqualDiff(
494
"""Shared repository (format: dirstate or dirstate-tags or knit)
496
shared repository: %s
499
control: Meta directory format 1
504
""" % ('repo', format.repository_format.get_format_description(),
506
self.assertEqual('', err)
508
# Create branch inside shared repository
509
repo.bzrdir.root_transport.mkdir('branch')
510
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
512
out, err = self.run_bzr('info -v repo/branch')
513
self.assertEqualDiff(
514
"""Repository branch (format: dirstate or knit)
516
shared repository: repo
517
repository branch: repo/branch
520
control: Meta directory format 1
530
""" % (format.get_branch_format().get_format_description(),
531
format.repository_format.get_format_description(),
533
self.assertEqual('', err)
535
# Create lightweight checkout
536
transport.mkdir('tree')
537
transport.mkdir('tree/lightcheckout')
538
tree2 = branch1.create_checkout('tree/lightcheckout',
540
branch2 = tree2.branch
541
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
542
shared_repo=repo, repo_branch=branch1, verbose=True)
544
# Create normal checkout
545
tree3 = branch1.create_checkout('tree/checkout')
546
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
548
light_checkout=False, repo_branch=branch1)
549
# Update lightweight checkout
550
self.build_tree(['tree/lightcheckout/a'])
552
tree2.commit('commit one')
553
rev = repo.get_revision(branch2.revision_history()[0])
554
datestring_first = format_date(rev.timestamp, rev.timezone)
555
out, err = self.run_bzr('info tree/lightcheckout --verbose')
556
self.assertEqualDiff(
557
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
558
1.9 or 1.9-rich-root or \
559
dirstate or dirstate-tags or \
560
pack-0.92 or rich-root or rich-root-pack)
562
light checkout root: tree/lightcheckout
563
checkout of branch: repo/branch
564
shared repository: repo
567
control: Meta directory format 1
568
working tree: Working tree format 4
580
0 versioned subdirectories
591
""" % (format.get_branch_format().get_format_description(),
592
format.repository_format.get_format_description(),
593
datestring_first, datestring_first,
595
self.assertEqual('', err)
597
# Out of date checkout
598
out, err = self.run_bzr('info -v tree/checkout')
599
self.assertEqualDiff(
600
"""Checkout (format: dirstate)
602
checkout root: tree/checkout
603
checkout of branch: repo/branch
606
control: Meta directory format 1
607
working tree: Working tree format 4
611
Branch is out of date: missing 1 revision.
621
0 versioned subdirectories
629
""" % (format.get_branch_format().get_format_description(),
630
format.repository_format.get_format_description(),
632
self.assertEqual('', err)
636
self.build_tree(['tree/checkout/b'])
638
out, err = self.run_bzr('info tree/checkout --verbose')
639
self.assertEqualDiff(
640
"""Checkout (format: dirstate)
642
checkout root: tree/checkout
643
checkout of branch: repo/branch
646
control: Meta directory format 1
647
working tree: Working tree format 4
659
0 versioned subdirectories
670
""" % (format.get_branch_format().get_format_description(),
671
format.repository_format.get_format_description(),
672
datestring_first, datestring_first,
674
self.assertEqual('', err)
675
tree3.commit('commit two')
677
# Out of date lightweight checkout
678
rev = repo.get_revision(branch1.revision_history()[-1])
679
datestring_last = format_date(rev.timestamp, rev.timezone)
680
out, err = self.run_bzr('info tree/lightcheckout --verbose')
681
self.assertEqualDiff(
682
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
683
1.9 or 1.9-rich-root or \
684
dirstate or dirstate-tags or \
685
pack-0.92 or rich-root or rich-root-pack)
687
light checkout root: tree/lightcheckout
688
checkout of branch: repo/branch
689
shared repository: repo
692
control: Meta directory format 1
693
working tree: Working tree format 4
697
Working tree is out of date: missing 1 revision.
707
0 versioned subdirectories
718
""" % (format.get_branch_format().get_format_description(),
719
format.repository_format.get_format_description(),
720
datestring_first, datestring_last,
722
self.assertEqual('', err)
724
# Show info about shared branch
725
out, err = self.run_bzr('info repo/branch --verbose')
726
self.assertEqualDiff(
727
"""Repository branch (format: dirstate or knit)
729
shared repository: repo
730
repository branch: repo/branch
733
control: Meta directory format 1
746
""" % (format.get_branch_format().get_format_description(),
747
format.repository_format.get_format_description(),
748
datestring_first, datestring_last,
750
self.assertEqual('', err)
752
# Show info about repository with revisions
753
out, err = self.run_bzr('info -v repo')
754
self.assertEqualDiff(
755
"""Shared repository (format: dirstate or dirstate-tags or knit)
757
shared repository: repo
760
control: Meta directory format 1
765
""" % (format.repository_format.get_format_description(),
767
self.assertEqual('', err)
769
def test_info_shared_repository_with_trees(self):
770
format = bzrdir.format_registry.make_bzrdir('knit')
771
transport = self.get_transport()
773
# Create shared repository with working trees
774
repo = self.make_repository('repo', shared=True, format=format)
775
repo.set_make_working_trees(True)
776
out, err = self.run_bzr('info -v repo')
777
self.assertEqualDiff(
778
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
780
shared repository: repo
783
control: Meta directory format 1
786
Create working tree for new branches inside the repository.
790
""" % (format.repository_format.get_format_description(),
792
self.assertEqual('', err)
794
# Create two branches
795
repo.bzrdir.root_transport.mkdir('branch1')
796
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
798
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
801
out, err = self.run_bzr('info repo/branch1 --verbose')
802
self.assertEqualDiff(
803
"""Repository tree (format: knit)
805
shared repository: repo
806
repository branch: repo/branch1
809
control: Meta directory format 1
810
working tree: Working tree format 3
822
0 versioned subdirectories
830
""" % (format.get_branch_format().get_format_description(),
831
format.repository_format.get_format_description(),
833
self.assertEqual('', err)
835
# Update first branch
836
self.build_tree(['repo/branch1/a'])
837
tree1 = branch1.bzrdir.open_workingtree()
839
tree1.commit('commit one')
840
rev = repo.get_revision(branch1.revision_history()[0])
841
datestring_first = format_date(rev.timestamp, rev.timezone)
842
out, err = self.run_bzr('info -v repo/branch1')
843
self.assertEqualDiff(
844
"""Repository tree (format: knit)
846
shared repository: repo
847
repository branch: repo/branch1
850
control: Meta directory format 1
851
working tree: Working tree format 3
863
0 versioned subdirectories
874
""" % (format.get_branch_format().get_format_description(),
875
format.repository_format.get_format_description(),
876
datestring_first, datestring_first,
878
self.assertEqual('', err)
880
# Out of date second branch
881
out, err = self.run_bzr('info repo/branch2 --verbose')
882
self.assertEqualDiff(
883
"""Repository tree (format: knit)
885
shared repository: repo
886
repository branch: repo/branch2
889
parent branch: repo/branch1
892
control: Meta directory format 1
893
working tree: Working tree format 3
905
0 versioned subdirectories
913
""" % (format.get_branch_format().get_format_description(),
914
format.repository_format.get_format_description(),
916
self.assertEqual('', err)
918
# Update second branch
919
tree2 = branch2.bzrdir.open_workingtree()
921
out, err = self.run_bzr('info -v repo/branch2')
922
self.assertEqualDiff(
923
"""Repository tree (format: knit)
925
shared repository: repo
926
repository branch: repo/branch2
929
parent branch: repo/branch1
932
control: Meta directory format 1
933
working tree: Working tree format 3
945
0 versioned subdirectories
956
""" % (format.get_branch_format().get_format_description(),
957
format.repository_format.get_format_description(),
958
datestring_first, datestring_first,
960
self.assertEqual('', err)
962
# Show info about repository with revisions
963
out, err = self.run_bzr('info -v repo')
964
self.assertEqualDiff(
965
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
967
shared repository: repo
970
control: Meta directory format 1
973
Create working tree for new branches inside the repository.
977
""" % (format.repository_format.get_format_description(),
980
self.assertEqual('', err)
982
def test_info_shared_repository_with_tree_in_root(self):
983
format = bzrdir.format_registry.make_bzrdir('knit')
984
transport = self.get_transport()
986
# Create shared repository with working trees
987
repo = self.make_repository('repo', shared=True, format=format)
988
repo.set_make_working_trees(True)
989
out, err = self.run_bzr('info -v repo')
990
self.assertEqualDiff(
991
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
993
shared repository: repo
996
control: Meta directory format 1
999
Create working tree for new branches inside the repository.
1003
""" % (format.repository_format.get_format_description(),
1005
self.assertEqual('', err)
1007
# Create branch in root of repository
1008
control = repo.bzrdir
1009
branch = control.create_branch()
1010
control.create_workingtree()
1011
out, err = self.run_bzr('info -v repo')
1012
self.assertEqualDiff(
1013
"""Repository tree (format: knit)
1015
shared repository: repo
1016
repository branch: repo
1019
control: Meta directory format 1
1020
working tree: Working tree format 3
1024
In the working tree:
1032
0 versioned subdirectories
1040
""" % (format.get_branch_format().get_format_description(),
1041
format.repository_format.get_format_description(),
1043
self.assertEqual('', err)
1045
def assertCheckoutStatusOutput(self,
1046
command_string, lco_tree, shared_repo=None,
1049
branch_locked=False, repo_locked=False,
1051
light_checkout=True,
1052
checkout_root=None):
1053
"""Check the output of info in a checkout.
1055
This is not quite a mirror of the info code: rather than using the
1056
tree being examined to predict output, it uses a bunch of flags which
1057
allow us, the test writers, to document what *should* be present in
1058
the output. Removing this separation would remove the value of the
1061
:param path: the path to the light checkout.
1062
:param lco_tree: the tree object for the light checkout.
1063
:param shared_repo: A shared repository is in use, expect that in
1065
:param repo_branch: A branch in a shared repository for non light
1067
:param tree_locked: If true, expect the tree to be locked.
1068
:param branch_locked: If true, expect the branch to be locked.
1069
:param repo_locked: If true, expect the repository to be locked.
1070
Note that the lco_tree.branch.repository is inspected, and if is not
1071
actually locked then this parameter is overridden. This is because
1072
pack repositories do not have any public API for obtaining an
1073
exclusive repository wide lock.
1074
:param verbose: If true, expect verbose output
1076
def friendly_location(url):
1077
path = urlutils.unescape_for_display(url, 'ascii')
1079
return osutils.relpath(osutils.getcwd(), path)
1080
except errors.PathNotChild:
1084
# We expect this to fail because of locking errors.
1085
# (A write-locked file cannot be read-locked
1086
# in the different process -- either on win32 or on linux).
1087
# This should be removed when the locking errors are fixed.
1088
self.expectFailure('OS locks are exclusive '
1089
'for different processes (Bug #174055)',
1090
self.run_bzr_subprocess,
1091
'info ' + command_string)
1092
out, err = self.run_bzr('info %s' % command_string)
1094
(True, True): 'Lightweight checkout',
1095
(True, False): 'Repository checkout',
1096
(False, True): 'Lightweight checkout',
1097
(False, False): 'Checkout',
1098
}[(shared_repo is not None, light_checkout)]
1099
format = {True: '1.6 or 1.6.1-rich-root'
1100
' or 1.9 or 1.9-rich-root'
1101
' or dirstate or dirstate-tags or pack-0.92'
1102
' or rich-root or rich-root-pack',
1103
False: 'dirstate'}[light_checkout]
1105
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1106
if repo_locked or branch_locked or tree_locked:
1107
def locked_message(a_bool):
1112
expected_lock_output = (
1115
" working tree: %s\n"
1117
" repository: %s\n" % (
1118
locked_message(tree_locked),
1119
locked_message(branch_locked),
1120
locked_message(repo_locked)))
1122
expected_lock_output = ''
1126
tree_data = (" light checkout root: %s\n" %
1127
friendly_location(lco_tree.bzrdir.root_transport.base))
1129
if lco_tree.branch.get_bound_location() is not None:
1130
tree_data += ("%s checkout root: %s\n" % (extra_space,
1131
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1132
if shared_repo is not None:
1134
" checkout of branch: %s\n"
1135
" shared repository: %s\n" %
1136
(friendly_location(repo_branch.bzrdir.root_transport.base),
1137
friendly_location(shared_repo.bzrdir.root_transport.base)))
1138
elif repo_branch is not None:
1140
"%s checkout of branch: %s\n" %
1142
friendly_location(repo_branch.bzrdir.root_transport.base)))
1144
branch_data = (" checkout of branch: %s\n" %
1145
lco_tree.branch.bzrdir.root_transport.base)
1148
verbose_info = ' 0 committers\n'
1152
self.assertEqualDiff(
1157
control: Meta directory format 1
1162
In the working tree:
1170
0 versioned subdirectories
1181
lco_tree._format.get_format_description(),
1182
lco_tree.branch._format.get_format_description(),
1183
lco_tree.branch.repository._format.get_format_description(),
1184
expected_lock_output,
1187
self.assertEqual('', err)
1189
def test_info_locking(self):
1190
transport = self.get_transport()
1191
# Create shared repository with a branch
1192
repo = self.make_repository('repo', shared=True,
1193
format=bzrdir.BzrDirMetaFormat1())
1194
repo.set_make_working_trees(False)
1195
repo.bzrdir.root_transport.mkdir('branch')
1196
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1197
format=bzrdir.BzrDirMetaFormat1())
1198
# Do a heavy checkout
1199
transport.mkdir('tree')
1200
transport.mkdir('tree/checkout')
1201
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1202
format=bzrdir.BzrDirMetaFormat1())
1203
co_branch.bind(repo_branch)
1204
# Do a light checkout of the heavy one
1205
transport.mkdir('tree/lightcheckout')
1206
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1207
branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1208
lco_dir.create_workingtree()
1209
lco_tree = lco_dir.open_workingtree()
1211
# Test all permutations of locking the working tree, branch and repository
1215
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1216
repo_branch=repo_branch,
1217
verbose=True, light_checkout=True)
1219
lco_tree.branch.repository.lock_write()
1221
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1222
lco_tree, repo_branch=repo_branch,
1223
repo_locked=True, verbose=True, light_checkout=True)
1225
lco_tree.branch.repository.unlock()
1227
lco_tree.branch.lock_write()
1229
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1233
repo_branch=repo_branch,
1236
lco_tree.branch.unlock()
1238
lco_tree.lock_write()
1240
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1241
lco_tree, repo_branch=repo_branch,
1249
lco_tree.lock_write()
1250
lco_tree.branch.repository.unlock()
1252
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1253
lco_tree, repo_branch=repo_branch,
1258
lco_tree.branch.repository.lock_write()
1261
lco_tree.lock_write()
1262
lco_tree.branch.unlock()
1264
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1265
lco_tree, repo_branch=repo_branch,
1269
lco_tree.branch.lock_write()
1272
lco_tree.lock_write()
1273
lco_tree.branch.unlock()
1274
lco_tree.branch.repository.lock_write()
1276
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1277
lco_tree, repo_branch=repo_branch,
1282
lco_tree.branch.repository.unlock()
1283
lco_tree.branch.lock_write()
1286
lco_tree.branch.lock_write()
1287
lco_tree.branch.repository.unlock()
1289
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1290
lco_tree, repo_branch=repo_branch,
1294
lco_tree.branch.repository.lock_write()
1295
lco_tree.branch.unlock()
1297
if sys.platform == 'win32':
1298
self.knownFailure('Win32 cannot run "bzr info"'
1299
' when the tree is locked.')
1301
def test_info_locking_oslocks(self):
1302
if sys.platform == "win32":
1303
raise TestSkipped("don't use oslocks on win32 in unix manner")
1305
tree = self.make_branch_and_tree('branch',
1306
format=bzrdir.BzrDirFormat6())
1308
# Test all permutations of locking the working tree, branch and repository
1309
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1310
# implemented by raising NotImplementedError and get_physical_lock_status()
1311
# always returns false. This makes bzr info hide the lock status. (Olaf)
1315
out, err = self.run_bzr('info -v branch')
1316
self.assertEqualDiff(
1317
"""Standalone tree (format: weave)
1322
control: All-in-one format 6
1323
working tree: Working tree format 2
1324
branch: Branch format 4
1327
In the working tree:
1335
0 versioned subdirectories
1343
""" % ('branch', tree.branch.repository._format.get_format_description(),
1345
self.assertEqual('', err)
1348
out, err = self.run_bzr('info -v branch')
1349
self.assertEqualDiff(
1350
"""Standalone tree (format: weave)
1355
control: All-in-one format 6
1356
working tree: Working tree format 2
1357
branch: Branch format 4
1360
In the working tree:
1368
0 versioned subdirectories
1376
""" % ('branch', tree.branch.repository._format.get_format_description(),
1378
self.assertEqual('', err)
1381
def test_info_stacked(self):
1382
# We have a mainline
1383
trunk_tree = self.make_branch_and_tree('mainline',
1385
trunk_tree.commit('mainline')
1386
# and a branch from it which is stacked
1387
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1388
out, err = self.run_bzr('info newbranch')
1390
"""Standalone tree (format: 1.6)
1392
branch root: newbranch
1395
parent branch: mainline
1396
stacked on: mainline
1398
self.assertEqual("", err)