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."""
32
from bzrlib.transport import memory
34
class TestInfo(tests.TestCaseWithTransport):
37
super(TestInfo, self).setUp()
38
self._repo_strings = "2a"
40
def test_info_non_existing(self):
41
self.vfs_transport_factory = memory.MemoryServer
42
location = self.get_url()
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
# Standalone branch - verbose mode
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
93
self.assertEqual('', err)
95
# Standalone branch - really verbose mode
96
out, err = self.run_bzr('info standalone -vv')
98
"""Standalone tree (format: weave)
100
branch root: standalone
103
control: All-in-one format 6
104
working tree: Working tree format 2
105
branch: Branch format 4
106
repository: Weave repository format 6
116
0 versioned subdirectories
125
self.assertEqual('', err)
126
tree1.commit('commit one')
127
rev = branch1.repository.get_revision(branch1.revision_history()[0])
128
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
130
# Branch standalone with push location
131
branch2 = branch1.bzrdir.sprout('branch').open_branch()
132
branch2.set_push_location(branch1.bzrdir.root_transport.base)
134
out, err = self.run_bzr('info branch')
135
self.assertEqualDiff(
136
"""Standalone tree (format: weave)
141
push branch: standalone
142
parent branch: standalone
144
self.assertEqual('', err)
146
out, err = self.run_bzr('info branch --verbose')
147
self.assertEqualDiff(
148
"""Standalone tree (format: weave)
153
push branch: standalone
154
parent branch: standalone
157
control: All-in-one format 6
158
working tree: Working tree format 2
159
branch: Branch format 4
160
repository: Weave repository format 6
170
0 versioned subdirectories
180
""" % (datestring_first, datestring_first,
182
self.assertEqual('', err)
184
# Branch and bind to standalone, needs upgrade to metadir
185
# (creates backup as unknown)
186
branch1.bzrdir.sprout('bound')
187
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
188
upgrade.upgrade('bound', knit1_format)
189
branch3 = bzrdir.BzrDir.open('bound').open_branch()
190
branch3.bind(branch1)
191
bound_tree = branch3.bzrdir.open_workingtree()
192
out, err = self.run_bzr('info -v bound')
193
self.assertEqualDiff(
194
"""Checkout (format: knit)
197
checkout of branch: standalone
200
parent branch: standalone
203
control: Meta directory format 1
216
0 versioned subdirectories
226
""" % (bound_tree._format.get_format_description(),
227
branch3._format.get_format_description(),
228
branch3.repository._format.get_format_description(),
229
datestring_first, datestring_first,
231
self.assertEqual('', err)
233
# Checkout standalone (same as above, but does not have parent set)
234
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
236
branch4.bind(branch1)
237
branch4.bzrdir.open_workingtree().update()
238
out, err = self.run_bzr('info checkout --verbose')
239
self.assertEqualDiff(
240
"""Checkout (format: knit)
242
checkout root: checkout
243
checkout of branch: standalone
246
control: Meta directory format 1
247
working tree: Working tree format 3
248
branch: Branch format 5
259
0 versioned subdirectories
269
""" % (branch4.repository._format.get_format_description(),
270
datestring_first, datestring_first,
272
self.assertEqual('', err)
274
# Lightweight checkout (same as above, different branch and repository)
275
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
276
branch5 = tree5.branch
277
out, err = self.run_bzr('info -v lightcheckout')
278
self.assertEqualDiff(
279
"""Lightweight checkout (format: %s)
281
light checkout root: lightcheckout
282
checkout of branch: standalone
285
control: Meta directory format 1
286
working tree: Working tree format 6
287
branch: Branch format 4
288
repository: Weave repository format 6
298
0 versioned subdirectories
308
""" % (self._repo_strings, datestring_first, datestring_first,), out)
309
self.assertEqual('', err)
311
# Update initial standalone branch
312
self.build_tree(['standalone/b'])
314
tree1.commit('commit two')
315
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
316
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
318
# Out of date branched standalone branch will not be detected
319
out, err = self.run_bzr('info -v branch')
320
self.assertEqualDiff(
321
"""Standalone tree (format: weave)
326
push branch: standalone
327
parent branch: standalone
330
control: All-in-one format 6
331
working tree: Working tree format 2
332
branch: Branch format 4
333
repository: Weave repository format 6
343
0 versioned subdirectories
353
""" % (datestring_first, datestring_first,
355
self.assertEqual('', err)
357
# Out of date bound branch
358
out, err = self.run_bzr('info -v bound')
359
self.assertEqualDiff(
360
"""Checkout (format: knit)
363
checkout of branch: standalone
366
parent branch: standalone
369
control: Meta directory format 1
370
working tree: Working tree format 3
371
branch: Branch format 5
374
Branch is out of date: missing 1 revision.
384
0 versioned subdirectories
394
""" % (branch3.repository._format.get_format_description(),
395
datestring_first, datestring_first,
397
self.assertEqual('', err)
399
# Out of date checkout
400
out, err = self.run_bzr('info -v checkout')
401
self.assertEqualDiff(
402
"""Checkout (format: knit)
404
checkout root: checkout
405
checkout of branch: standalone
408
control: Meta directory format 1
409
working tree: Working tree format 3
410
branch: Branch format 5
413
Branch is out of date: missing 1 revision.
423
0 versioned subdirectories
433
""" % (branch4.repository._format.get_format_description(),
434
datestring_first, datestring_first,
436
self.assertEqual('', err)
438
# Out of date lightweight checkout
439
out, err = self.run_bzr('info lightcheckout --verbose')
440
self.assertEqualDiff(
441
"""Lightweight checkout (format: %s)
443
light checkout root: lightcheckout
444
checkout of branch: standalone
447
control: Meta directory format 1
448
working tree: Working tree format 6
449
branch: Branch format 4
450
repository: Weave repository format 6
452
Working tree is out of date: missing 1 revision.
462
0 versioned subdirectories
472
""" % (self._repo_strings, datestring_first, datestring_last,), out)
473
self.assertEqual('', err)
475
def test_info_standalone_no_tree(self):
476
# create standalone branch without a working tree
477
format = bzrdir.format_registry.make_bzrdir('default')
478
branch = self.make_branch('branch')
479
repo = branch.repository
480
out, err = self.run_bzr('info branch -v')
481
self.assertEqualDiff(
482
"""Standalone branch (format: %s)
487
control: Meta directory format 1
496
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
497
format.get_branch_format().get_format_description(),
498
format.repository_format.get_format_description(),
500
self.assertEqual('', err)
502
def test_info_shared_repository(self):
503
format = bzrdir.format_registry.make_bzrdir('knit')
504
transport = self.get_transport()
506
# Create shared repository
507
repo = self.make_repository('repo', shared=True, format=format)
508
repo.set_make_working_trees(False)
509
out, err = self.run_bzr('info -v repo')
510
self.assertEqualDiff(
511
"""Shared repository (format: dirstate or dirstate-tags or knit)
513
shared repository: %s
516
control: Meta directory format 1
521
""" % ('repo', format.repository_format.get_format_description(),
523
self.assertEqual('', err)
525
# Create branch inside shared repository
526
repo.bzrdir.root_transport.mkdir('branch')
527
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
529
out, err = self.run_bzr('info -v repo/branch')
530
self.assertEqualDiff(
531
"""Repository branch (format: dirstate or knit)
533
shared repository: repo
534
repository branch: repo/branch
537
control: Meta directory format 1
546
""" % (format.get_branch_format().get_format_description(),
547
format.repository_format.get_format_description(),
549
self.assertEqual('', err)
551
# Create lightweight checkout
552
transport.mkdir('tree')
553
transport.mkdir('tree/lightcheckout')
554
tree2 = branch1.create_checkout('tree/lightcheckout',
556
branch2 = tree2.branch
557
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
558
shared_repo=repo, repo_branch=branch1, verbose=True)
560
# Create normal checkout
561
tree3 = branch1.create_checkout('tree/checkout')
562
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
564
light_checkout=False, repo_branch=branch1)
565
# Update lightweight checkout
566
self.build_tree(['tree/lightcheckout/a'])
568
tree2.commit('commit one')
569
rev = repo.get_revision(branch2.revision_history()[0])
570
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
571
out, err = self.run_bzr('info tree/lightcheckout --verbose')
572
self.assertEqualDiff(
573
"""Lightweight checkout (format: %s)
575
light checkout root: tree/lightcheckout
576
checkout of branch: repo/branch
577
shared repository: repo
580
control: Meta directory format 1
581
working tree: Working tree format 6
593
0 versioned subdirectories
603
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
604
format.repository_format.get_format_description(),
605
datestring_first, datestring_first,
607
self.assertEqual('', err)
609
# Out of date checkout
610
out, err = self.run_bzr('info -v tree/checkout')
611
self.assertEqualDiff(
612
"""Checkout (format: unnamed)
614
checkout root: tree/checkout
615
checkout of branch: repo/branch
618
control: Meta directory format 1
619
working tree: Working tree format 6
623
Branch is out of date: missing 1 revision.
633
0 versioned subdirectories
640
""" % (format.get_branch_format().get_format_description(),
641
format.repository_format.get_format_description(),
643
self.assertEqual('', err)
647
self.build_tree(['tree/checkout/b'])
649
out, err = self.run_bzr('info tree/checkout --verbose')
650
self.assertEqualDiff(
651
"""Checkout (format: unnamed)
653
checkout root: tree/checkout
654
checkout of branch: repo/branch
657
control: Meta directory format 1
658
working tree: Working tree format 6
670
0 versioned subdirectories
680
""" % (format.get_branch_format().get_format_description(),
681
format.repository_format.get_format_description(),
682
datestring_first, datestring_first,
684
self.assertEqual('', err)
685
tree3.commit('commit two')
687
# Out of date lightweight checkout
688
rev = repo.get_revision(branch1.revision_history()[-1])
689
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
690
out, err = self.run_bzr('info tree/lightcheckout --verbose')
691
self.assertEqualDiff(
692
"""Lightweight checkout (format: %s)
694
light checkout root: tree/lightcheckout
695
checkout of branch: repo/branch
696
shared repository: repo
699
control: Meta directory format 1
700
working tree: Working tree format 6
704
Working tree is out of date: missing 1 revision.
714
0 versioned subdirectories
724
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
725
format.repository_format.get_format_description(),
726
datestring_first, datestring_last,
728
self.assertEqual('', err)
730
# Show info about shared branch
731
out, err = self.run_bzr('info repo/branch --verbose')
732
self.assertEqualDiff(
733
"""Repository branch (format: dirstate or knit)
735
shared repository: repo
736
repository branch: repo/branch
739
control: Meta directory format 1
751
""" % (format.get_branch_format().get_format_description(),
752
format.repository_format.get_format_description(),
753
datestring_first, datestring_last,
755
self.assertEqual('', err)
757
# Show info about repository with revisions
758
out, err = self.run_bzr('info -v repo')
759
self.assertEqualDiff(
760
"""Shared repository (format: dirstate or dirstate-tags or knit)
762
shared repository: repo
765
control: Meta directory format 1
770
""" % (format.repository_format.get_format_description(),
772
self.assertEqual('', err)
774
def test_info_shared_repository_with_trees(self):
775
format = bzrdir.format_registry.make_bzrdir('knit')
776
transport = self.get_transport()
778
# Create shared repository with working trees
779
repo = self.make_repository('repo', shared=True, format=format)
780
repo.set_make_working_trees(True)
781
out, err = self.run_bzr('info -v repo')
782
self.assertEqualDiff(
783
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
785
shared repository: repo
788
control: Meta directory format 1
791
Create working tree for new branches inside the repository.
795
""" % (format.repository_format.get_format_description(),
797
self.assertEqual('', err)
799
# Create two branches
800
repo.bzrdir.root_transport.mkdir('branch1')
801
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
803
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
806
out, err = self.run_bzr('info repo/branch1 --verbose')
807
self.assertEqualDiff(
808
"""Repository tree (format: knit)
810
shared repository: repo
811
repository branch: repo/branch1
814
control: Meta directory format 1
815
working tree: Working tree format 3
827
0 versioned subdirectories
834
""" % (format.get_branch_format().get_format_description(),
835
format.repository_format.get_format_description(),
837
self.assertEqual('', err)
839
# Update first branch
840
self.build_tree(['repo/branch1/a'])
841
tree1 = branch1.bzrdir.open_workingtree()
843
tree1.commit('commit one')
844
rev = repo.get_revision(branch1.revision_history()[0])
845
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
846
out, err = self.run_bzr('info -v repo/branch1')
847
self.assertEqualDiff(
848
"""Repository tree (format: knit)
850
shared repository: repo
851
repository branch: repo/branch1
854
control: Meta directory format 1
855
working tree: Working tree format 3
867
0 versioned subdirectories
877
""" % (format.get_branch_format().get_format_description(),
878
format.repository_format.get_format_description(),
879
datestring_first, datestring_first,
881
self.assertEqual('', err)
883
# Out of date second branch
884
out, err = self.run_bzr('info repo/branch2 --verbose')
885
self.assertEqualDiff(
886
"""Repository tree (format: knit)
888
shared repository: repo
889
repository branch: repo/branch2
892
parent branch: repo/branch1
895
control: Meta directory format 1
896
working tree: Working tree format 3
908
0 versioned subdirectories
915
""" % (format.get_branch_format().get_format_description(),
916
format.repository_format.get_format_description(),
918
self.assertEqual('', err)
920
# Update second branch
921
tree2 = branch2.bzrdir.open_workingtree()
923
out, err = self.run_bzr('info -v repo/branch2')
924
self.assertEqualDiff(
925
"""Repository tree (format: knit)
927
shared repository: repo
928
repository branch: repo/branch2
931
parent branch: repo/branch1
934
control: Meta directory format 1
935
working tree: Working tree format 3
947
0 versioned subdirectories
957
""" % (format.get_branch_format().get_format_description(),
958
format.repository_format.get_format_description(),
959
datestring_first, datestring_first,
961
self.assertEqual('', err)
963
# Show info about repository with revisions
964
out, err = self.run_bzr('info -v repo')
965
self.assertEqualDiff(
966
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
968
shared repository: repo
971
control: Meta directory format 1
974
Create working tree for new branches inside the repository.
978
""" % (format.repository_format.get_format_description(),
981
self.assertEqual('', err)
983
def test_info_shared_repository_with_tree_in_root(self):
984
format = bzrdir.format_registry.make_bzrdir('knit')
985
transport = self.get_transport()
987
# Create shared repository with working trees
988
repo = self.make_repository('repo', shared=True, format=format)
989
repo.set_make_working_trees(True)
990
out, err = self.run_bzr('info -v repo')
991
self.assertEqualDiff(
992
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
994
shared repository: repo
997
control: Meta directory format 1
1000
Create working tree for new branches inside the repository.
1004
""" % (format.repository_format.get_format_description(),
1006
self.assertEqual('', err)
1008
# Create branch in root of repository
1009
control = repo.bzrdir
1010
branch = control.create_branch()
1011
control.create_workingtree()
1012
out, err = self.run_bzr('info -v repo')
1013
self.assertEqualDiff(
1014
"""Repository tree (format: knit)
1016
shared repository: repo
1017
repository branch: repo
1020
control: Meta directory format 1
1021
working tree: Working tree format 3
1025
In the working tree:
1033
0 versioned subdirectories
1040
""" % (format.get_branch_format().get_format_description(),
1041
format.repository_format.get_format_description(),
1043
self.assertEqual('', err)
1045
def test_info_repository_hook(self):
1046
format = bzrdir.format_registry.make_bzrdir('knit')
1047
def repo_info(repo, stats, outf):
1048
outf.write("more info\n")
1049
info.hooks.install_named_hook('repository', repo_info, None)
1050
# Create shared repository with working trees
1051
repo = self.make_repository('repo', shared=True, format=format)
1052
out, err = self.run_bzr('info -v repo')
1053
self.assertEqualDiff(
1054
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1056
shared repository: repo
1059
control: Meta directory format 1
1062
Create working tree for new branches inside the repository.
1067
""" % (format.repository_format.get_format_description(),
1069
self.assertEqual('', err)
1071
def assertCheckoutStatusOutput(self,
1072
command_string, lco_tree, shared_repo=None,
1075
branch_locked=False, repo_locked=False,
1077
light_checkout=True,
1078
checkout_root=None):
1079
"""Check the output of info in a checkout.
1081
This is not quite a mirror of the info code: rather than using the
1082
tree being examined to predict output, it uses a bunch of flags which
1083
allow us, the test writers, to document what *should* be present in
1084
the output. Removing this separation would remove the value of the
1087
:param path: the path to the light checkout.
1088
:param lco_tree: the tree object for the light checkout.
1089
:param shared_repo: A shared repository is in use, expect that in
1091
:param repo_branch: A branch in a shared repository for non light
1093
:param tree_locked: If true, expect the tree to be locked.
1094
:param branch_locked: If true, expect the branch to be locked.
1095
:param repo_locked: If true, expect the repository to be locked.
1096
Note that the lco_tree.branch.repository is inspected, and if is not
1097
actually locked then this parameter is overridden. This is because
1098
pack repositories do not have any public API for obtaining an
1099
exclusive repository wide lock.
1100
:param verbose: verbosity level: 2 or higher to show committers
1102
def friendly_location(url):
1103
path = urlutils.unescape_for_display(url, 'ascii')
1105
return osutils.relpath(osutils.getcwd(), path)
1106
except errors.PathNotChild:
1110
# We expect this to fail because of locking errors.
1111
# (A write-locked file cannot be read-locked
1112
# in the different process -- either on win32 or on linux).
1113
# This should be removed when the locking errors are fixed.
1114
self.expectFailure('OS locks are exclusive '
1115
'for different processes (Bug #174055)',
1116
self.run_bzr_subprocess,
1117
'info ' + command_string)
1118
out, err = self.run_bzr('info %s' % command_string)
1120
(True, True): 'Lightweight checkout',
1121
(True, False): 'Repository checkout',
1122
(False, True): 'Lightweight checkout',
1123
(False, False): 'Checkout',
1124
}[(shared_repo is not None, light_checkout)]
1125
format = {True: self._repo_strings,
1126
False: 'unnamed'}[light_checkout]
1128
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1129
if repo_locked or branch_locked or tree_locked:
1130
def locked_message(a_bool):
1135
expected_lock_output = (
1138
" working tree: %s\n"
1140
" repository: %s\n" % (
1141
locked_message(tree_locked),
1142
locked_message(branch_locked),
1143
locked_message(repo_locked)))
1145
expected_lock_output = ''
1149
tree_data = (" light checkout root: %s\n" %
1150
friendly_location(lco_tree.bzrdir.root_transport.base))
1152
if lco_tree.branch.get_bound_location() is not None:
1153
tree_data += ("%s checkout root: %s\n" % (extra_space,
1154
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1155
if shared_repo is not None:
1157
" checkout of branch: %s\n"
1158
" shared repository: %s\n" %
1159
(friendly_location(repo_branch.bzrdir.root_transport.base),
1160
friendly_location(shared_repo.bzrdir.root_transport.base)))
1161
elif repo_branch is not None:
1163
"%s checkout of branch: %s\n" %
1165
friendly_location(repo_branch.bzrdir.root_transport.base)))
1167
branch_data = (" checkout of branch: %s\n" %
1168
lco_tree.branch.bzrdir.root_transport.base)
1171
verbose_info = ' 0 committers\n'
1175
self.assertEqualDiff(
1180
control: Meta directory format 1
1185
In the working tree:
1193
0 versioned subdirectories
1204
lco_tree._format.get_format_description(),
1205
lco_tree.branch._format.get_format_description(),
1206
lco_tree.branch.repository._format.get_format_description(),
1207
expected_lock_output,
1210
self.assertEqual('', err)
1212
def test_info_locking(self):
1213
transport = self.get_transport()
1214
# Create shared repository with a branch
1215
repo = self.make_repository('repo', shared=True,
1216
format=bzrdir.BzrDirMetaFormat1())
1217
repo.set_make_working_trees(False)
1218
repo.bzrdir.root_transport.mkdir('branch')
1219
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1220
format=bzrdir.BzrDirMetaFormat1())
1221
# Do a heavy checkout
1222
transport.mkdir('tree')
1223
transport.mkdir('tree/checkout')
1224
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1225
format=bzrdir.BzrDirMetaFormat1())
1226
co_branch.bind(repo_branch)
1227
# Do a light checkout of the heavy one
1228
transport.mkdir('tree/lightcheckout')
1229
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1230
branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1231
lco_dir.create_workingtree()
1232
lco_tree = lco_dir.open_workingtree()
1234
# Test all permutations of locking the working tree, branch and repository
1238
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1239
repo_branch=repo_branch,
1240
verbose=True, light_checkout=True)
1242
lco_tree.branch.repository.lock_write()
1244
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1245
lco_tree, repo_branch=repo_branch,
1246
repo_locked=True, verbose=True, light_checkout=True)
1248
lco_tree.branch.repository.unlock()
1250
lco_tree.branch.lock_write()
1252
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1256
repo_branch=repo_branch,
1259
lco_tree.branch.unlock()
1261
lco_tree.lock_write()
1263
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1264
lco_tree, repo_branch=repo_branch,
1272
lco_tree.lock_write()
1273
lco_tree.branch.repository.unlock()
1275
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1276
lco_tree, repo_branch=repo_branch,
1281
lco_tree.branch.repository.lock_write()
1284
lco_tree.lock_write()
1285
lco_tree.branch.unlock()
1287
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1288
lco_tree, repo_branch=repo_branch,
1292
lco_tree.branch.lock_write()
1295
lco_tree.lock_write()
1296
lco_tree.branch.unlock()
1297
lco_tree.branch.repository.lock_write()
1299
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1300
lco_tree, repo_branch=repo_branch,
1305
lco_tree.branch.repository.unlock()
1306
lco_tree.branch.lock_write()
1309
lco_tree.branch.lock_write()
1310
lco_tree.branch.repository.unlock()
1312
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1313
lco_tree, repo_branch=repo_branch,
1317
lco_tree.branch.repository.lock_write()
1318
lco_tree.branch.unlock()
1320
if sys.platform == 'win32':
1321
self.knownFailure('Win32 cannot run "bzr info"'
1322
' when the tree is locked.')
1324
def test_info_locking_oslocks(self):
1325
if sys.platform == "win32":
1326
raise TestSkipped("don't use oslocks on win32 in unix manner")
1327
# This test tests old (all-in-one, OS lock using) behaviour which
1328
# simply cannot work on windows (and is indeed why we changed our
1329
# design. As such, don't try to remove the thisFailsStrictLockCheck
1331
self.thisFailsStrictLockCheck()
1333
tree = self.make_branch_and_tree('branch',
1334
format=bzrdir.BzrDirFormat6())
1336
# Test all permutations of locking the working tree, branch and repository
1337
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1338
# implemented by raising NotImplementedError and get_physical_lock_status()
1339
# always returns false. This makes bzr info hide the lock status. (Olaf)
1343
out, err = self.run_bzr('info -v branch')
1344
self.assertEqualDiff(
1345
"""Standalone tree (format: weave)
1350
control: All-in-one format 6
1351
working tree: Working tree format 2
1352
branch: Branch format 4
1355
In the working tree:
1363
0 versioned subdirectories
1370
""" % ('branch', tree.branch.repository._format.get_format_description(),
1372
self.assertEqual('', err)
1375
out, err = self.run_bzr('info -v branch')
1376
self.assertEqualDiff(
1377
"""Standalone tree (format: weave)
1382
control: All-in-one format 6
1383
working tree: Working tree format 2
1384
branch: Branch format 4
1387
In the working tree:
1395
0 versioned subdirectories
1402
""" % ('branch', tree.branch.repository._format.get_format_description(),
1404
self.assertEqual('', err)
1407
def test_info_stacked(self):
1408
# We have a mainline
1409
trunk_tree = self.make_branch_and_tree('mainline',
1411
trunk_tree.commit('mainline')
1412
# and a branch from it which is stacked
1413
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1414
out, err = self.run_bzr('info newbranch')
1416
"""Standalone tree (format: 1.6)
1418
branch root: newbranch
1421
parent branch: mainline
1422
stacked on: mainline
1424
self.assertEqual("", err)