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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
"""Tests for the info command of bzr."""
31
from bzrlib.osutils import format_date
32
from bzrlib.tests import TestSkipped, MemoryServer
33
from bzrlib.tests.blackbox import ExternalBase
36
class TestInfo(ExternalBase):
39
ExternalBase.setUp(self)
40
self._repo_strings = "2a"
42
def test_info_non_existing(self):
43
self.vfs_transport_factory = MemoryServer
44
location = self.get_url()
45
out, err = self.run_bzr('info '+location, retcode=3)
46
self.assertEqual(out, '')
47
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
49
def test_info_standalone(self):
50
transport = self.get_transport()
52
# Create initial standalone branch
53
tree1 = self.make_branch_and_tree('standalone', 'weave')
54
self.build_tree(['standalone/a'])
56
branch1 = tree1.branch
58
out, err = self.run_bzr('info standalone')
60
"""Standalone tree (format: weave)
62
branch root: standalone
64
self.assertEqual('', err)
66
# Standalone branch - verbose mode
67
out, err = self.run_bzr('info standalone -v')
69
"""Standalone tree (format: weave)
71
branch root: standalone
74
control: All-in-one format 6
75
working tree: Working tree format 2
76
branch: Branch format 4
77
repository: Weave repository format 6
87
0 versioned subdirectories
95
self.assertEqual('', err)
97
# Standalone branch - really verbose mode
98
out, err = self.run_bzr('info standalone -vv')
100
"""Standalone tree (format: weave)
102
branch root: standalone
105
control: All-in-one format 6
106
working tree: Working tree format 2
107
branch: Branch format 4
108
repository: Weave repository format 6
118
0 versioned subdirectories
127
self.assertEqual('', err)
128
tree1.commit('commit one')
129
rev = branch1.repository.get_revision(branch1.revision_history()[0])
130
datestring_first = format_date(rev.timestamp, rev.timezone)
132
# Branch standalone with push location
133
branch2 = branch1.bzrdir.sprout('branch').open_branch()
134
branch2.set_push_location(branch1.bzrdir.root_transport.base)
136
out, err = self.run_bzr('info branch')
137
self.assertEqualDiff(
138
"""Standalone tree (format: weave)
143
push branch: standalone
144
parent branch: standalone
146
self.assertEqual('', err)
148
out, err = self.run_bzr('info branch --verbose')
149
self.assertEqualDiff(
150
"""Standalone tree (format: weave)
155
push branch: standalone
156
parent branch: standalone
159
control: All-in-one format 6
160
working tree: Working tree format 2
161
branch: Branch format 4
162
repository: Weave repository format 6
172
0 versioned subdirectories
182
""" % (datestring_first, datestring_first,
184
self.assertEqual('', err)
186
# Branch and bind to standalone, needs upgrade to metadir
187
# (creates backup as unknown)
188
branch1.bzrdir.sprout('bound')
189
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
190
upgrade.upgrade('bound', knit1_format)
191
branch3 = bzrdir.BzrDir.open('bound').open_branch()
192
branch3.bind(branch1)
193
bound_tree = branch3.bzrdir.open_workingtree()
194
out, err = self.run_bzr('info -v bound')
195
self.assertEqualDiff(
196
"""Checkout (format: knit)
199
checkout of branch: standalone
202
parent branch: standalone
205
control: Meta directory format 1
218
0 versioned subdirectories
228
""" % (bound_tree._format.get_format_description(),
229
branch3._format.get_format_description(),
230
branch3.repository._format.get_format_description(),
231
datestring_first, datestring_first,
233
self.assertEqual('', err)
235
# Checkout standalone (same as above, but does not have parent set)
236
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
238
branch4.bind(branch1)
239
branch4.bzrdir.open_workingtree().update()
240
out, err = self.run_bzr('info checkout --verbose')
241
self.assertEqualDiff(
242
"""Checkout (format: knit)
244
checkout root: checkout
245
checkout of branch: standalone
248
control: Meta directory format 1
249
working tree: Working tree format 3
250
branch: Branch format 5
261
0 versioned subdirectories
271
""" % (branch4.repository._format.get_format_description(),
272
datestring_first, datestring_first,
274
self.assertEqual('', err)
276
# Lightweight checkout (same as above, different branch and repository)
277
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
278
branch5 = tree5.branch
279
out, err = self.run_bzr('info -v lightcheckout')
280
self.assertEqualDiff(
281
"""Lightweight checkout (format: %s)
283
light checkout root: lightcheckout
284
checkout of branch: standalone
287
control: Meta directory format 1
288
working tree: Working tree format 6
289
branch: Branch format 4
290
repository: Weave repository format 6
300
0 versioned subdirectories
310
""" % (self._repo_strings, datestring_first, datestring_first,), out)
311
self.assertEqual('', err)
313
# Update initial standalone branch
314
self.build_tree(['standalone/b'])
316
tree1.commit('commit two')
317
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
318
datestring_last = format_date(rev.timestamp, rev.timezone)
320
# Out of date branched standalone branch will not be detected
321
out, err = self.run_bzr('info -v branch')
322
self.assertEqualDiff(
323
"""Standalone tree (format: weave)
328
push branch: standalone
329
parent branch: standalone
332
control: All-in-one format 6
333
working tree: Working tree format 2
334
branch: Branch format 4
335
repository: Weave repository format 6
345
0 versioned subdirectories
355
""" % (datestring_first, datestring_first,
357
self.assertEqual('', err)
359
# Out of date bound branch
360
out, err = self.run_bzr('info -v bound')
361
self.assertEqualDiff(
362
"""Checkout (format: knit)
365
checkout of branch: standalone
368
parent branch: standalone
371
control: Meta directory format 1
372
working tree: Working tree format 3
373
branch: Branch format 5
376
Branch is out of date: missing 1 revision.
386
0 versioned subdirectories
396
""" % (branch3.repository._format.get_format_description(),
397
datestring_first, datestring_first,
399
self.assertEqual('', err)
401
# Out of date checkout
402
out, err = self.run_bzr('info -v checkout')
403
self.assertEqualDiff(
404
"""Checkout (format: knit)
406
checkout root: checkout
407
checkout of branch: standalone
410
control: Meta directory format 1
411
working tree: Working tree format 3
412
branch: Branch format 5
415
Branch is out of date: missing 1 revision.
425
0 versioned subdirectories
435
""" % (branch4.repository._format.get_format_description(),
436
datestring_first, datestring_first,
438
self.assertEqual('', err)
440
# Out of date lightweight checkout
441
out, err = self.run_bzr('info lightcheckout --verbose')
442
self.assertEqualDiff(
443
"""Lightweight checkout (format: %s)
445
light checkout root: lightcheckout
446
checkout of branch: standalone
449
control: Meta directory format 1
450
working tree: Working tree format 6
451
branch: Branch format 4
452
repository: Weave repository format 6
454
Working tree is out of date: missing 1 revision.
464
0 versioned subdirectories
474
""" % (self._repo_strings, datestring_first, datestring_last,), out)
475
self.assertEqual('', err)
477
def test_info_standalone_no_tree(self):
478
# create standalone branch without a working tree
479
format = bzrdir.format_registry.make_bzrdir('default')
480
branch = self.make_branch('branch')
481
repo = branch.repository
482
out, err = self.run_bzr('info branch -v')
483
self.assertEqualDiff(
484
"""Standalone branch (format: %s)
489
control: Meta directory format 1
498
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
499
format.get_branch_format().get_format_description(),
500
format.repository_format.get_format_description(),
502
self.assertEqual('', err)
504
def test_info_shared_repository(self):
505
format = bzrdir.format_registry.make_bzrdir('knit')
506
transport = self.get_transport()
508
# Create shared repository
509
repo = self.make_repository('repo', shared=True, format=format)
510
repo.set_make_working_trees(False)
511
out, err = self.run_bzr('info -v repo')
512
self.assertEqualDiff(
513
"""Shared repository (format: dirstate or dirstate-tags or knit)
515
shared repository: %s
518
control: Meta directory format 1
523
""" % ('repo', format.repository_format.get_format_description(),
525
self.assertEqual('', err)
527
# Create branch inside shared repository
528
repo.bzrdir.root_transport.mkdir('branch')
529
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
531
out, err = self.run_bzr('info -v repo/branch')
532
self.assertEqualDiff(
533
"""Repository branch (format: dirstate or knit)
535
shared repository: repo
536
repository branch: repo/branch
539
control: Meta directory format 1
548
""" % (format.get_branch_format().get_format_description(),
549
format.repository_format.get_format_description(),
551
self.assertEqual('', err)
553
# Create lightweight checkout
554
transport.mkdir('tree')
555
transport.mkdir('tree/lightcheckout')
556
tree2 = branch1.create_checkout('tree/lightcheckout',
558
branch2 = tree2.branch
559
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
560
shared_repo=repo, repo_branch=branch1, verbose=True)
562
# Create normal checkout
563
tree3 = branch1.create_checkout('tree/checkout')
564
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
566
light_checkout=False, repo_branch=branch1)
567
# Update lightweight checkout
568
self.build_tree(['tree/lightcheckout/a'])
570
tree2.commit('commit one')
571
rev = repo.get_revision(branch2.revision_history()[0])
572
datestring_first = format_date(rev.timestamp, rev.timezone)
573
out, err = self.run_bzr('info tree/lightcheckout --verbose')
574
self.assertEqualDiff(
575
"""Lightweight checkout (format: %s)
577
light checkout root: tree/lightcheckout
578
checkout of branch: repo/branch
579
shared repository: repo
582
control: Meta directory format 1
583
working tree: Working tree format 6
595
0 versioned subdirectories
605
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
606
format.repository_format.get_format_description(),
607
datestring_first, datestring_first,
609
self.assertEqual('', err)
611
# Out of date checkout
612
out, err = self.run_bzr('info -v tree/checkout')
613
self.assertEqualDiff(
614
"""Checkout (format: unnamed)
616
checkout root: tree/checkout
617
checkout of branch: repo/branch
620
control: Meta directory format 1
621
working tree: Working tree format 6
625
Branch is out of date: missing 1 revision.
635
0 versioned subdirectories
642
""" % (format.get_branch_format().get_format_description(),
643
format.repository_format.get_format_description(),
645
self.assertEqual('', err)
649
self.build_tree(['tree/checkout/b'])
651
out, err = self.run_bzr('info tree/checkout --verbose')
652
self.assertEqualDiff(
653
"""Checkout (format: unnamed)
655
checkout root: tree/checkout
656
checkout of branch: repo/branch
659
control: Meta directory format 1
660
working tree: Working tree format 6
672
0 versioned subdirectories
682
""" % (format.get_branch_format().get_format_description(),
683
format.repository_format.get_format_description(),
684
datestring_first, datestring_first,
686
self.assertEqual('', err)
687
tree3.commit('commit two')
689
# Out of date lightweight checkout
690
rev = repo.get_revision(branch1.revision_history()[-1])
691
datestring_last = format_date(rev.timestamp, rev.timezone)
692
out, err = self.run_bzr('info tree/lightcheckout --verbose')
693
self.assertEqualDiff(
694
"""Lightweight checkout (format: %s)
696
light checkout root: tree/lightcheckout
697
checkout of branch: repo/branch
698
shared repository: repo
701
control: Meta directory format 1
702
working tree: Working tree format 6
706
Working tree is out of date: missing 1 revision.
716
0 versioned subdirectories
726
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
727
format.repository_format.get_format_description(),
728
datestring_first, datestring_last,
730
self.assertEqual('', err)
732
# Show info about shared branch
733
out, err = self.run_bzr('info repo/branch --verbose')
734
self.assertEqualDiff(
735
"""Repository branch (format: dirstate or knit)
737
shared repository: repo
738
repository branch: repo/branch
741
control: Meta directory format 1
753
""" % (format.get_branch_format().get_format_description(),
754
format.repository_format.get_format_description(),
755
datestring_first, datestring_last,
757
self.assertEqual('', err)
759
# Show info about repository with revisions
760
out, err = self.run_bzr('info -v repo')
761
self.assertEqualDiff(
762
"""Shared repository (format: dirstate or dirstate-tags or knit)
764
shared repository: repo
767
control: Meta directory format 1
772
""" % (format.repository_format.get_format_description(),
774
self.assertEqual('', err)
776
def test_info_shared_repository_with_trees(self):
777
format = bzrdir.format_registry.make_bzrdir('knit')
778
transport = self.get_transport()
780
# Create shared repository with working trees
781
repo = self.make_repository('repo', shared=True, format=format)
782
repo.set_make_working_trees(True)
783
out, err = self.run_bzr('info -v repo')
784
self.assertEqualDiff(
785
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
787
shared repository: repo
790
control: Meta directory format 1
793
Create working tree for new branches inside the repository.
797
""" % (format.repository_format.get_format_description(),
799
self.assertEqual('', err)
801
# Create two branches
802
repo.bzrdir.root_transport.mkdir('branch1')
803
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
805
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
808
out, err = self.run_bzr('info repo/branch1 --verbose')
809
self.assertEqualDiff(
810
"""Repository tree (format: knit)
812
shared repository: repo
813
repository branch: repo/branch1
816
control: Meta directory format 1
817
working tree: Working tree format 3
829
0 versioned subdirectories
836
""" % (format.get_branch_format().get_format_description(),
837
format.repository_format.get_format_description(),
839
self.assertEqual('', err)
841
# Update first branch
842
self.build_tree(['repo/branch1/a'])
843
tree1 = branch1.bzrdir.open_workingtree()
845
tree1.commit('commit one')
846
rev = repo.get_revision(branch1.revision_history()[0])
847
datestring_first = format_date(rev.timestamp, rev.timezone)
848
out, err = self.run_bzr('info -v repo/branch1')
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
879
""" % (format.get_branch_format().get_format_description(),
880
format.repository_format.get_format_description(),
881
datestring_first, datestring_first,
883
self.assertEqual('', err)
885
# Out of date second branch
886
out, err = self.run_bzr('info repo/branch2 --verbose')
887
self.assertEqualDiff(
888
"""Repository tree (format: knit)
890
shared repository: repo
891
repository branch: repo/branch2
894
parent branch: repo/branch1
897
control: Meta directory format 1
898
working tree: Working tree format 3
910
0 versioned subdirectories
917
""" % (format.get_branch_format().get_format_description(),
918
format.repository_format.get_format_description(),
920
self.assertEqual('', err)
922
# Update second branch
923
tree2 = branch2.bzrdir.open_workingtree()
925
out, err = self.run_bzr('info -v repo/branch2')
926
self.assertEqualDiff(
927
"""Repository tree (format: knit)
929
shared repository: repo
930
repository branch: repo/branch2
933
parent branch: repo/branch1
936
control: Meta directory format 1
937
working tree: Working tree format 3
949
0 versioned subdirectories
959
""" % (format.get_branch_format().get_format_description(),
960
format.repository_format.get_format_description(),
961
datestring_first, datestring_first,
963
self.assertEqual('', err)
965
# Show info about repository with revisions
966
out, err = self.run_bzr('info -v repo')
967
self.assertEqualDiff(
968
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
970
shared repository: repo
973
control: Meta directory format 1
976
Create working tree for new branches inside the repository.
980
""" % (format.repository_format.get_format_description(),
983
self.assertEqual('', err)
985
def test_info_shared_repository_with_tree_in_root(self):
986
format = bzrdir.format_registry.make_bzrdir('knit')
987
transport = self.get_transport()
989
# Create shared repository with working trees
990
repo = self.make_repository('repo', shared=True, format=format)
991
repo.set_make_working_trees(True)
992
out, err = self.run_bzr('info -v repo')
993
self.assertEqualDiff(
994
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
996
shared repository: repo
999
control: Meta directory format 1
1002
Create working tree for new branches inside the repository.
1006
""" % (format.repository_format.get_format_description(),
1008
self.assertEqual('', err)
1010
# Create branch in root of repository
1011
control = repo.bzrdir
1012
branch = control.create_branch()
1013
control.create_workingtree()
1014
out, err = self.run_bzr('info -v repo')
1015
self.assertEqualDiff(
1016
"""Repository tree (format: knit)
1018
shared repository: repo
1019
repository branch: repo
1022
control: Meta directory format 1
1023
working tree: Working tree format 3
1027
In the working tree:
1035
0 versioned subdirectories
1042
""" % (format.get_branch_format().get_format_description(),
1043
format.repository_format.get_format_description(),
1045
self.assertEqual('', err)
1047
def test_info_repository_hook(self):
1048
format = bzrdir.format_registry.make_bzrdir('knit')
1049
def repo_info(repo, stats, outf):
1050
outf.write("more info\n")
1051
info.hooks.install_named_hook('repository', repo_info, None)
1052
# Create shared repository with working trees
1053
repo = self.make_repository('repo', shared=True, format=format)
1054
out, err = self.run_bzr('info -v repo')
1055
self.assertEqualDiff(
1056
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1058
shared repository: repo
1061
control: Meta directory format 1
1064
Create working tree for new branches inside the repository.
1069
""" % (format.repository_format.get_format_description(),
1071
self.assertEqual('', err)
1073
def assertCheckoutStatusOutput(self,
1074
command_string, lco_tree, shared_repo=None,
1077
branch_locked=False, repo_locked=False,
1079
light_checkout=True,
1080
checkout_root=None):
1081
"""Check the output of info in a checkout.
1083
This is not quite a mirror of the info code: rather than using the
1084
tree being examined to predict output, it uses a bunch of flags which
1085
allow us, the test writers, to document what *should* be present in
1086
the output. Removing this separation would remove the value of the
1089
:param path: the path to the light checkout.
1090
:param lco_tree: the tree object for the light checkout.
1091
:param shared_repo: A shared repository is in use, expect that in
1093
:param repo_branch: A branch in a shared repository for non light
1095
:param tree_locked: If true, expect the tree to be locked.
1096
:param branch_locked: If true, expect the branch to be locked.
1097
:param repo_locked: If true, expect the repository to be locked.
1098
Note that the lco_tree.branch.repository is inspected, and if is not
1099
actually locked then this parameter is overridden. This is because
1100
pack repositories do not have any public API for obtaining an
1101
exclusive repository wide lock.
1102
:param verbose: verbosity level: 2 or higher to show committers
1104
def friendly_location(url):
1105
path = urlutils.unescape_for_display(url, 'ascii')
1107
return osutils.relpath(osutils.getcwd(), path)
1108
except errors.PathNotChild:
1112
# We expect this to fail because of locking errors.
1113
# (A write-locked file cannot be read-locked
1114
# in the different process -- either on win32 or on linux).
1115
# This should be removed when the locking errors are fixed.
1116
self.expectFailure('OS locks are exclusive '
1117
'for different processes (Bug #174055)',
1118
self.run_bzr_subprocess,
1119
'info ' + command_string)
1120
out, err = self.run_bzr('info %s' % command_string)
1122
(True, True): 'Lightweight checkout',
1123
(True, False): 'Repository checkout',
1124
(False, True): 'Lightweight checkout',
1125
(False, False): 'Checkout',
1126
}[(shared_repo is not None, light_checkout)]
1127
format = {True: self._repo_strings,
1128
False: 'unnamed'}[light_checkout]
1130
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1131
if repo_locked or branch_locked or tree_locked:
1132
def locked_message(a_bool):
1137
expected_lock_output = (
1140
" working tree: %s\n"
1142
" repository: %s\n" % (
1143
locked_message(tree_locked),
1144
locked_message(branch_locked),
1145
locked_message(repo_locked)))
1147
expected_lock_output = ''
1151
tree_data = (" light checkout root: %s\n" %
1152
friendly_location(lco_tree.bzrdir.root_transport.base))
1154
if lco_tree.branch.get_bound_location() is not None:
1155
tree_data += ("%s checkout root: %s\n" % (extra_space,
1156
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1157
if shared_repo is not None:
1159
" checkout of branch: %s\n"
1160
" shared repository: %s\n" %
1161
(friendly_location(repo_branch.bzrdir.root_transport.base),
1162
friendly_location(shared_repo.bzrdir.root_transport.base)))
1163
elif repo_branch is not None:
1165
"%s checkout of branch: %s\n" %
1167
friendly_location(repo_branch.bzrdir.root_transport.base)))
1169
branch_data = (" checkout of branch: %s\n" %
1170
lco_tree.branch.bzrdir.root_transport.base)
1173
verbose_info = ' 0 committers\n'
1177
self.assertEqualDiff(
1182
control: Meta directory format 1
1187
In the working tree:
1195
0 versioned subdirectories
1206
lco_tree._format.get_format_description(),
1207
lco_tree.branch._format.get_format_description(),
1208
lco_tree.branch.repository._format.get_format_description(),
1209
expected_lock_output,
1212
self.assertEqual('', err)
1214
def test_info_locking(self):
1215
transport = self.get_transport()
1216
# Create shared repository with a branch
1217
repo = self.make_repository('repo', shared=True,
1218
format=bzrdir.BzrDirMetaFormat1())
1219
repo.set_make_working_trees(False)
1220
repo.bzrdir.root_transport.mkdir('branch')
1221
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1222
format=bzrdir.BzrDirMetaFormat1())
1223
# Do a heavy checkout
1224
transport.mkdir('tree')
1225
transport.mkdir('tree/checkout')
1226
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1227
format=bzrdir.BzrDirMetaFormat1())
1228
co_branch.bind(repo_branch)
1229
# Do a light checkout of the heavy one
1230
transport.mkdir('tree/lightcheckout')
1231
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1232
branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1233
lco_dir.create_workingtree()
1234
lco_tree = lco_dir.open_workingtree()
1236
# Test all permutations of locking the working tree, branch and repository
1240
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1241
repo_branch=repo_branch,
1242
verbose=True, light_checkout=True)
1244
lco_tree.branch.repository.lock_write()
1246
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1247
lco_tree, repo_branch=repo_branch,
1248
repo_locked=True, verbose=True, light_checkout=True)
1250
lco_tree.branch.repository.unlock()
1252
lco_tree.branch.lock_write()
1254
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1258
repo_branch=repo_branch,
1261
lco_tree.branch.unlock()
1263
lco_tree.lock_write()
1265
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1266
lco_tree, repo_branch=repo_branch,
1274
lco_tree.lock_write()
1275
lco_tree.branch.repository.unlock()
1277
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1278
lco_tree, repo_branch=repo_branch,
1283
lco_tree.branch.repository.lock_write()
1286
lco_tree.lock_write()
1287
lco_tree.branch.unlock()
1289
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1290
lco_tree, repo_branch=repo_branch,
1294
lco_tree.branch.lock_write()
1297
lco_tree.lock_write()
1298
lco_tree.branch.unlock()
1299
lco_tree.branch.repository.lock_write()
1301
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1302
lco_tree, repo_branch=repo_branch,
1307
lco_tree.branch.repository.unlock()
1308
lco_tree.branch.lock_write()
1311
lco_tree.branch.lock_write()
1312
lco_tree.branch.repository.unlock()
1314
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1315
lco_tree, repo_branch=repo_branch,
1319
lco_tree.branch.repository.lock_write()
1320
lco_tree.branch.unlock()
1322
if sys.platform == 'win32':
1323
self.knownFailure('Win32 cannot run "bzr info"'
1324
' when the tree is locked.')
1326
def test_info_locking_oslocks(self):
1327
if sys.platform == "win32":
1328
raise TestSkipped("don't use oslocks on win32 in unix manner")
1329
# This test tests old (all-in-one, OS lock using) behaviour which
1330
# simply cannot work on windows (and is indeed why we changed our
1331
# design. As such, don't try to remove the thisFailsStrictLockCheck
1333
self.thisFailsStrictLockCheck()
1335
tree = self.make_branch_and_tree('branch',
1336
format=bzrdir.BzrDirFormat6())
1338
# Test all permutations of locking the working tree, branch and repository
1339
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1340
# implemented by raising NotImplementedError and get_physical_lock_status()
1341
# always returns false. This makes bzr info hide the lock status. (Olaf)
1345
out, err = self.run_bzr('info -v branch')
1346
self.assertEqualDiff(
1347
"""Standalone tree (format: weave)
1352
control: All-in-one format 6
1353
working tree: Working tree format 2
1354
branch: Branch format 4
1357
In the working tree:
1365
0 versioned subdirectories
1372
""" % ('branch', tree.branch.repository._format.get_format_description(),
1374
self.assertEqual('', err)
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
1404
""" % ('branch', tree.branch.repository._format.get_format_description(),
1406
self.assertEqual('', err)
1409
def test_info_stacked(self):
1410
# We have a mainline
1411
trunk_tree = self.make_branch_and_tree('mainline',
1413
trunk_tree.commit('mainline')
1414
# and a branch from it which is stacked
1415
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1416
out, err = self.run_bzr('info newbranch')
1418
"""Standalone tree (format: 1.6)
1420
branch root: newbranch
1423
parent branch: mainline
1424
stacked on: mainline
1426
self.assertEqual("", err)