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
# 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 = 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: 1.6 or 1.6.1-rich-root \
280
or 1.9 or 1.9-rich-root \
281
or dirstate or dirstate-tags or \
282
pack-0.92 or rich-root or rich-root-pack)
284
light checkout root: lightcheckout
285
checkout of branch: standalone
288
control: Meta directory format 1
289
working tree: Working tree format 4
290
branch: Branch format 4
291
repository: Weave repository format 6
301
0 versioned subdirectories
311
""" % (datestring_first, datestring_first,), out)
312
self.assertEqual('', err)
314
# Update initial standalone branch
315
self.build_tree(['standalone/b'])
317
tree1.commit('commit two')
318
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
319
datestring_last = format_date(rev.timestamp, rev.timezone)
321
# Out of date branched standalone branch will not be detected
322
out, err = self.run_bzr('info -v branch')
323
self.assertEqualDiff(
324
"""Standalone tree (format: weave)
329
push branch: standalone
330
parent branch: standalone
333
control: All-in-one format 6
334
working tree: Working tree format 2
335
branch: Branch format 4
336
repository: Weave repository format 6
346
0 versioned subdirectories
356
""" % (datestring_first, datestring_first,
358
self.assertEqual('', err)
360
# Out of date bound branch
361
out, err = self.run_bzr('info -v bound')
362
self.assertEqualDiff(
363
"""Checkout (format: knit)
366
checkout of branch: standalone
369
parent branch: standalone
372
control: Meta directory format 1
373
working tree: Working tree format 3
374
branch: Branch format 5
377
Branch is out of date: missing 1 revision.
387
0 versioned subdirectories
397
""" % (branch3.repository._format.get_format_description(),
398
datestring_first, datestring_first,
400
self.assertEqual('', err)
402
# Out of date checkout
403
out, err = self.run_bzr('info -v checkout')
404
self.assertEqualDiff(
405
"""Checkout (format: knit)
407
checkout root: checkout
408
checkout of branch: standalone
411
control: Meta directory format 1
412
working tree: Working tree format 3
413
branch: Branch format 5
416
Branch is out of date: missing 1 revision.
426
0 versioned subdirectories
436
""" % (branch4.repository._format.get_format_description(),
437
datestring_first, datestring_first,
439
self.assertEqual('', err)
441
# Out of date lightweight checkout
442
out, err = self.run_bzr('info lightcheckout --verbose')
443
self.assertEqualDiff(
444
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
445
1.9 or 1.9-rich-root or \
446
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
478
""" % (datestring_first, datestring_last,), out)
479
self.assertEqual('', err)
481
def test_info_standalone_no_tree(self):
482
# create standalone branch without a working tree
483
format = bzrdir.format_registry.make_bzrdir('default')
484
branch = self.make_branch('branch')
485
repo = branch.repository
486
out, err = self.run_bzr('info branch -v')
487
self.assertEqualDiff(
488
"""Standalone branch (format: %s)
493
control: Meta directory format 1
502
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
503
format.get_branch_format().get_format_description(),
504
format.repository_format.get_format_description(),
506
self.assertEqual('', err)
508
def test_info_shared_repository(self):
509
format = bzrdir.format_registry.make_bzrdir('knit')
510
transport = self.get_transport()
512
# Create shared repository
513
repo = self.make_repository('repo', shared=True, format=format)
514
repo.set_make_working_trees(False)
515
out, err = self.run_bzr('info -v repo')
516
self.assertEqualDiff(
517
"""Shared repository (format: dirstate or dirstate-tags or knit)
519
shared repository: %s
522
control: Meta directory format 1
527
""" % ('repo', format.repository_format.get_format_description(),
529
self.assertEqual('', err)
531
# Create branch inside shared repository
532
repo.bzrdir.root_transport.mkdir('branch')
533
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
535
out, err = self.run_bzr('info -v repo/branch')
536
self.assertEqualDiff(
537
"""Repository branch (format: dirstate or knit)
539
shared repository: repo
540
repository branch: repo/branch
543
control: Meta directory format 1
552
""" % (format.get_branch_format().get_format_description(),
553
format.repository_format.get_format_description(),
555
self.assertEqual('', err)
557
# Create lightweight checkout
558
transport.mkdir('tree')
559
transport.mkdir('tree/lightcheckout')
560
tree2 = branch1.create_checkout('tree/lightcheckout',
562
branch2 = tree2.branch
563
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
564
shared_repo=repo, repo_branch=branch1, verbose=True)
566
# Create normal checkout
567
tree3 = branch1.create_checkout('tree/checkout')
568
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
570
light_checkout=False, repo_branch=branch1)
571
# Update lightweight checkout
572
self.build_tree(['tree/lightcheckout/a'])
574
tree2.commit('commit one')
575
rev = repo.get_revision(branch2.revision_history()[0])
576
datestring_first = format_date(rev.timestamp, rev.timezone)
577
out, err = self.run_bzr('info tree/lightcheckout --verbose')
578
self.assertEqualDiff(
579
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
580
1.9 or 1.9-rich-root or \
581
dirstate or dirstate-tags or \
582
pack-0.92 or rich-root or rich-root-pack)
584
light checkout root: tree/lightcheckout
585
checkout of branch: repo/branch
586
shared repository: repo
589
control: Meta directory format 1
590
working tree: Working tree format 4
602
0 versioned subdirectories
612
""" % (format.get_branch_format().get_format_description(),
613
format.repository_format.get_format_description(),
614
datestring_first, datestring_first,
616
self.assertEqual('', err)
618
# Out of date checkout
619
out, err = self.run_bzr('info -v tree/checkout')
620
self.assertEqualDiff(
621
"""Checkout (format: dirstate)
623
checkout root: tree/checkout
624
checkout of branch: repo/branch
627
control: Meta directory format 1
628
working tree: Working tree format 4
632
Branch is out of date: missing 1 revision.
642
0 versioned subdirectories
649
""" % (format.get_branch_format().get_format_description(),
650
format.repository_format.get_format_description(),
652
self.assertEqual('', err)
656
self.build_tree(['tree/checkout/b'])
658
out, err = self.run_bzr('info tree/checkout --verbose')
659
self.assertEqualDiff(
660
"""Checkout (format: dirstate)
662
checkout root: tree/checkout
663
checkout of branch: repo/branch
666
control: Meta directory format 1
667
working tree: Working tree format 4
679
0 versioned subdirectories
689
""" % (format.get_branch_format().get_format_description(),
690
format.repository_format.get_format_description(),
691
datestring_first, datestring_first,
693
self.assertEqual('', err)
694
tree3.commit('commit two')
696
# Out of date lightweight checkout
697
rev = repo.get_revision(branch1.revision_history()[-1])
698
datestring_last = format_date(rev.timestamp, rev.timezone)
699
out, err = self.run_bzr('info tree/lightcheckout --verbose')
700
self.assertEqualDiff(
701
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
702
1.9 or 1.9-rich-root or \
703
dirstate or dirstate-tags or \
704
pack-0.92 or rich-root or rich-root-pack)
706
light checkout root: tree/lightcheckout
707
checkout of branch: repo/branch
708
shared repository: repo
711
control: Meta directory format 1
712
working tree: Working tree format 4
716
Working tree is out of date: missing 1 revision.
726
0 versioned subdirectories
736
""" % (format.get_branch_format().get_format_description(),
737
format.repository_format.get_format_description(),
738
datestring_first, datestring_last,
740
self.assertEqual('', err)
742
# Show info about shared branch
743
out, err = self.run_bzr('info repo/branch --verbose')
744
self.assertEqualDiff(
745
"""Repository branch (format: dirstate or knit)
747
shared repository: repo
748
repository branch: repo/branch
751
control: Meta directory format 1
763
""" % (format.get_branch_format().get_format_description(),
764
format.repository_format.get_format_description(),
765
datestring_first, datestring_last,
767
self.assertEqual('', err)
769
# Show info about repository with revisions
770
out, err = self.run_bzr('info -v repo')
771
self.assertEqualDiff(
772
"""Shared repository (format: dirstate or dirstate-tags or knit)
774
shared repository: repo
777
control: Meta directory format 1
782
""" % (format.repository_format.get_format_description(),
784
self.assertEqual('', err)
786
def test_info_shared_repository_with_trees(self):
787
format = bzrdir.format_registry.make_bzrdir('knit')
788
transport = self.get_transport()
790
# Create shared repository with working trees
791
repo = self.make_repository('repo', shared=True, format=format)
792
repo.set_make_working_trees(True)
793
out, err = self.run_bzr('info -v repo')
794
self.assertEqualDiff(
795
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
797
shared repository: repo
800
control: Meta directory format 1
803
Create working tree for new branches inside the repository.
807
""" % (format.repository_format.get_format_description(),
809
self.assertEqual('', err)
811
# Create two branches
812
repo.bzrdir.root_transport.mkdir('branch1')
813
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
815
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
818
out, err = self.run_bzr('info repo/branch1 --verbose')
819
self.assertEqualDiff(
820
"""Repository tree (format: knit)
822
shared repository: repo
823
repository branch: repo/branch1
826
control: Meta directory format 1
827
working tree: Working tree format 3
839
0 versioned subdirectories
846
""" % (format.get_branch_format().get_format_description(),
847
format.repository_format.get_format_description(),
849
self.assertEqual('', err)
851
# Update first branch
852
self.build_tree(['repo/branch1/a'])
853
tree1 = branch1.bzrdir.open_workingtree()
855
tree1.commit('commit one')
856
rev = repo.get_revision(branch1.revision_history()[0])
857
datestring_first = format_date(rev.timestamp, rev.timezone)
858
out, err = self.run_bzr('info -v repo/branch1')
859
self.assertEqualDiff(
860
"""Repository tree (format: knit)
862
shared repository: repo
863
repository branch: repo/branch1
866
control: Meta directory format 1
867
working tree: Working tree format 3
879
0 versioned subdirectories
889
""" % (format.get_branch_format().get_format_description(),
890
format.repository_format.get_format_description(),
891
datestring_first, datestring_first,
893
self.assertEqual('', err)
895
# Out of date second branch
896
out, err = self.run_bzr('info repo/branch2 --verbose')
897
self.assertEqualDiff(
898
"""Repository tree (format: knit)
900
shared repository: repo
901
repository branch: repo/branch2
904
parent branch: repo/branch1
907
control: Meta directory format 1
908
working tree: Working tree format 3
920
0 versioned subdirectories
927
""" % (format.get_branch_format().get_format_description(),
928
format.repository_format.get_format_description(),
930
self.assertEqual('', err)
932
# Update second branch
933
tree2 = branch2.bzrdir.open_workingtree()
935
out, err = self.run_bzr('info -v repo/branch2')
936
self.assertEqualDiff(
937
"""Repository tree (format: knit)
939
shared repository: repo
940
repository branch: repo/branch2
943
parent branch: repo/branch1
946
control: Meta directory format 1
947
working tree: Working tree format 3
959
0 versioned subdirectories
969
""" % (format.get_branch_format().get_format_description(),
970
format.repository_format.get_format_description(),
971
datestring_first, datestring_first,
973
self.assertEqual('', err)
975
# Show info about repository with revisions
976
out, err = self.run_bzr('info -v repo')
977
self.assertEqualDiff(
978
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
980
shared repository: repo
983
control: Meta directory format 1
986
Create working tree for new branches inside the repository.
990
""" % (format.repository_format.get_format_description(),
993
self.assertEqual('', err)
995
def test_info_shared_repository_with_tree_in_root(self):
996
format = bzrdir.format_registry.make_bzrdir('knit')
997
transport = self.get_transport()
999
# Create shared repository with working trees
1000
repo = self.make_repository('repo', shared=True, format=format)
1001
repo.set_make_working_trees(True)
1002
out, err = self.run_bzr('info -v repo')
1003
self.assertEqualDiff(
1004
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1006
shared repository: repo
1009
control: Meta directory format 1
1012
Create working tree for new branches inside the repository.
1016
""" % (format.repository_format.get_format_description(),
1018
self.assertEqual('', err)
1020
# Create branch in root of repository
1021
control = repo.bzrdir
1022
branch = control.create_branch()
1023
control.create_workingtree()
1024
out, err = self.run_bzr('info -v repo')
1025
self.assertEqualDiff(
1026
"""Repository tree (format: knit)
1028
shared repository: repo
1029
repository branch: repo
1032
control: Meta directory format 1
1033
working tree: Working tree format 3
1037
In the working tree:
1045
0 versioned subdirectories
1052
""" % (format.get_branch_format().get_format_description(),
1053
format.repository_format.get_format_description(),
1055
self.assertEqual('', err)
1057
def assertCheckoutStatusOutput(self,
1058
command_string, lco_tree, shared_repo=None,
1061
branch_locked=False, repo_locked=False,
1063
light_checkout=True,
1064
checkout_root=None):
1065
"""Check the output of info in a checkout.
1067
This is not quite a mirror of the info code: rather than using the
1068
tree being examined to predict output, it uses a bunch of flags which
1069
allow us, the test writers, to document what *should* be present in
1070
the output. Removing this separation would remove the value of the
1073
:param path: the path to the light checkout.
1074
:param lco_tree: the tree object for the light checkout.
1075
:param shared_repo: A shared repository is in use, expect that in
1077
:param repo_branch: A branch in a shared repository for non light
1079
:param tree_locked: If true, expect the tree to be locked.
1080
:param branch_locked: If true, expect the branch to be locked.
1081
:param repo_locked: If true, expect the repository to be locked.
1082
Note that the lco_tree.branch.repository is inspected, and if is not
1083
actually locked then this parameter is overridden. This is because
1084
pack repositories do not have any public API for obtaining an
1085
exclusive repository wide lock.
1086
:param verbose: verbosity level: 2 or higher to show committers
1088
def friendly_location(url):
1089
path = urlutils.unescape_for_display(url, 'ascii')
1091
return osutils.relpath(osutils.getcwd(), path)
1092
except errors.PathNotChild:
1096
# We expect this to fail because of locking errors.
1097
# (A write-locked file cannot be read-locked
1098
# in the different process -- either on win32 or on linux).
1099
# This should be removed when the locking errors are fixed.
1100
self.expectFailure('OS locks are exclusive '
1101
'for different processes (Bug #174055)',
1102
self.run_bzr_subprocess,
1103
'info ' + command_string)
1104
out, err = self.run_bzr('info %s' % command_string)
1106
(True, True): 'Lightweight checkout',
1107
(True, False): 'Repository checkout',
1108
(False, True): 'Lightweight checkout',
1109
(False, False): 'Checkout',
1110
}[(shared_repo is not None, light_checkout)]
1111
format = {True: '1.6 or 1.6.1-rich-root'
1112
' or 1.9 or 1.9-rich-root'
1113
' or dirstate or dirstate-tags or pack-0.92'
1114
' or rich-root or rich-root-pack',
1115
False: 'dirstate'}[light_checkout]
1117
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1118
if repo_locked or branch_locked or tree_locked:
1119
def locked_message(a_bool):
1124
expected_lock_output = (
1127
" working tree: %s\n"
1129
" repository: %s\n" % (
1130
locked_message(tree_locked),
1131
locked_message(branch_locked),
1132
locked_message(repo_locked)))
1134
expected_lock_output = ''
1138
tree_data = (" light checkout root: %s\n" %
1139
friendly_location(lco_tree.bzrdir.root_transport.base))
1141
if lco_tree.branch.get_bound_location() is not None:
1142
tree_data += ("%s checkout root: %s\n" % (extra_space,
1143
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1144
if shared_repo is not None:
1146
" checkout of branch: %s\n"
1147
" shared repository: %s\n" %
1148
(friendly_location(repo_branch.bzrdir.root_transport.base),
1149
friendly_location(shared_repo.bzrdir.root_transport.base)))
1150
elif repo_branch is not None:
1152
"%s checkout of branch: %s\n" %
1154
friendly_location(repo_branch.bzrdir.root_transport.base)))
1156
branch_data = (" checkout of branch: %s\n" %
1157
lco_tree.branch.bzrdir.root_transport.base)
1160
verbose_info = ' 0 committers\n'
1164
self.assertEqualDiff(
1169
control: Meta directory format 1
1174
In the working tree:
1182
0 versioned subdirectories
1193
lco_tree._format.get_format_description(),
1194
lco_tree.branch._format.get_format_description(),
1195
lco_tree.branch.repository._format.get_format_description(),
1196
expected_lock_output,
1199
self.assertEqual('', err)
1201
def test_info_locking(self):
1202
transport = self.get_transport()
1203
# Create shared repository with a branch
1204
repo = self.make_repository('repo', shared=True,
1205
format=bzrdir.BzrDirMetaFormat1())
1206
repo.set_make_working_trees(False)
1207
repo.bzrdir.root_transport.mkdir('branch')
1208
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1209
format=bzrdir.BzrDirMetaFormat1())
1210
# Do a heavy checkout
1211
transport.mkdir('tree')
1212
transport.mkdir('tree/checkout')
1213
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1214
format=bzrdir.BzrDirMetaFormat1())
1215
co_branch.bind(repo_branch)
1216
# Do a light checkout of the heavy one
1217
transport.mkdir('tree/lightcheckout')
1218
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1219
branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1220
lco_dir.create_workingtree()
1221
lco_tree = lco_dir.open_workingtree()
1223
# Test all permutations of locking the working tree, branch and repository
1227
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1228
repo_branch=repo_branch,
1229
verbose=True, light_checkout=True)
1231
lco_tree.branch.repository.lock_write()
1233
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1234
lco_tree, repo_branch=repo_branch,
1235
repo_locked=True, verbose=True, light_checkout=True)
1237
lco_tree.branch.repository.unlock()
1239
lco_tree.branch.lock_write()
1241
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1245
repo_branch=repo_branch,
1248
lco_tree.branch.unlock()
1250
lco_tree.lock_write()
1252
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1253
lco_tree, repo_branch=repo_branch,
1261
lco_tree.lock_write()
1262
lco_tree.branch.repository.unlock()
1264
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1265
lco_tree, repo_branch=repo_branch,
1270
lco_tree.branch.repository.lock_write()
1273
lco_tree.lock_write()
1274
lco_tree.branch.unlock()
1276
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1277
lco_tree, repo_branch=repo_branch,
1281
lco_tree.branch.lock_write()
1284
lco_tree.lock_write()
1285
lco_tree.branch.unlock()
1286
lco_tree.branch.repository.lock_write()
1288
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1289
lco_tree, repo_branch=repo_branch,
1294
lco_tree.branch.repository.unlock()
1295
lco_tree.branch.lock_write()
1298
lco_tree.branch.lock_write()
1299
lco_tree.branch.repository.unlock()
1301
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1302
lco_tree, repo_branch=repo_branch,
1306
lco_tree.branch.repository.lock_write()
1307
lco_tree.branch.unlock()
1309
if sys.platform == 'win32':
1310
self.knownFailure('Win32 cannot run "bzr info"'
1311
' when the tree is locked.')
1313
def test_info_locking_oslocks(self):
1314
if sys.platform == "win32":
1315
raise TestSkipped("don't use oslocks on win32 in unix manner")
1317
tree = self.make_branch_and_tree('branch',
1318
format=bzrdir.BzrDirFormat6())
1320
# Test all permutations of locking the working tree, branch and repository
1321
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1322
# implemented by raising NotImplementedError and get_physical_lock_status()
1323
# always returns false. This makes bzr info hide the lock status. (Olaf)
1327
out, err = self.run_bzr('info -v branch')
1328
self.assertEqualDiff(
1329
"""Standalone tree (format: weave)
1334
control: All-in-one format 6
1335
working tree: Working tree format 2
1336
branch: Branch format 4
1339
In the working tree:
1347
0 versioned subdirectories
1354
""" % ('branch', tree.branch.repository._format.get_format_description(),
1356
self.assertEqual('', err)
1359
out, err = self.run_bzr('info -v branch')
1360
self.assertEqualDiff(
1361
"""Standalone tree (format: weave)
1366
control: All-in-one format 6
1367
working tree: Working tree format 2
1368
branch: Branch format 4
1371
In the working tree:
1379
0 versioned subdirectories
1386
""" % ('branch', tree.branch.repository._format.get_format_description(),
1388
self.assertEqual('', err)
1391
def test_info_stacked(self):
1392
# We have a mainline
1393
trunk_tree = self.make_branch_and_tree('mainline',
1395
trunk_tree.commit('mainline')
1396
# and a branch from it which is stacked
1397
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1398
out, err = self.run_bzr('info newbranch')
1400
"""Standalone tree (format: 1.6)
1402
branch root: newbranch
1405
parent branch: mainline
1406
stacked on: mainline
1408
self.assertEqual("", err)