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
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 test_info_repository_hook(self):
1058
format = bzrdir.format_registry.make_bzrdir('knit')
1059
def repo_info(repo, stats, outf):
1060
outf.write("more info\n")
1061
info.hooks.install_named_hook('repository', repo_info, None)
1062
# Create shared repository with working trees
1063
repo = self.make_repository('repo', shared=True, format=format)
1064
out, err = self.run_bzr('info -v repo')
1065
self.assertEqualDiff(
1066
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1068
shared repository: repo
1071
control: Meta directory format 1
1074
Create working tree for new branches inside the repository.
1079
""" % (format.repository_format.get_format_description(),
1081
self.assertEqual('', err)
1083
def assertCheckoutStatusOutput(self,
1084
command_string, lco_tree, shared_repo=None,
1087
branch_locked=False, repo_locked=False,
1089
light_checkout=True,
1090
checkout_root=None):
1091
"""Check the output of info in a checkout.
1093
This is not quite a mirror of the info code: rather than using the
1094
tree being examined to predict output, it uses a bunch of flags which
1095
allow us, the test writers, to document what *should* be present in
1096
the output. Removing this separation would remove the value of the
1099
:param path: the path to the light checkout.
1100
:param lco_tree: the tree object for the light checkout.
1101
:param shared_repo: A shared repository is in use, expect that in
1103
:param repo_branch: A branch in a shared repository for non light
1105
:param tree_locked: If true, expect the tree to be locked.
1106
:param branch_locked: If true, expect the branch to be locked.
1107
:param repo_locked: If true, expect the repository to be locked.
1108
Note that the lco_tree.branch.repository is inspected, and if is not
1109
actually locked then this parameter is overridden. This is because
1110
pack repositories do not have any public API for obtaining an
1111
exclusive repository wide lock.
1112
:param verbose: verbosity level: 2 or higher to show committers
1114
def friendly_location(url):
1115
path = urlutils.unescape_for_display(url, 'ascii')
1117
return osutils.relpath(osutils.getcwd(), path)
1118
except errors.PathNotChild:
1122
# We expect this to fail because of locking errors.
1123
# (A write-locked file cannot be read-locked
1124
# in the different process -- either on win32 or on linux).
1125
# This should be removed when the locking errors are fixed.
1126
self.expectFailure('OS locks are exclusive '
1127
'for different processes (Bug #174055)',
1128
self.run_bzr_subprocess,
1129
'info ' + command_string)
1130
out, err = self.run_bzr('info %s' % command_string)
1132
(True, True): 'Lightweight checkout',
1133
(True, False): 'Repository checkout',
1134
(False, True): 'Lightweight checkout',
1135
(False, False): 'Checkout',
1136
}[(shared_repo is not None, light_checkout)]
1137
format = {True: '1.6 or 1.6.1-rich-root'
1138
' or 1.9 or 1.9-rich-root'
1139
' or dirstate or dirstate-tags or pack-0.92'
1140
' or rich-root or rich-root-pack',
1141
False: 'dirstate'}[light_checkout]
1143
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1144
if repo_locked or branch_locked or tree_locked:
1145
def locked_message(a_bool):
1150
expected_lock_output = (
1153
" working tree: %s\n"
1155
" repository: %s\n" % (
1156
locked_message(tree_locked),
1157
locked_message(branch_locked),
1158
locked_message(repo_locked)))
1160
expected_lock_output = ''
1164
tree_data = (" light checkout root: %s\n" %
1165
friendly_location(lco_tree.bzrdir.root_transport.base))
1167
if lco_tree.branch.get_bound_location() is not None:
1168
tree_data += ("%s checkout root: %s\n" % (extra_space,
1169
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1170
if shared_repo is not None:
1172
" checkout of branch: %s\n"
1173
" shared repository: %s\n" %
1174
(friendly_location(repo_branch.bzrdir.root_transport.base),
1175
friendly_location(shared_repo.bzrdir.root_transport.base)))
1176
elif repo_branch is not None:
1178
"%s checkout of branch: %s\n" %
1180
friendly_location(repo_branch.bzrdir.root_transport.base)))
1182
branch_data = (" checkout of branch: %s\n" %
1183
lco_tree.branch.bzrdir.root_transport.base)
1186
verbose_info = ' 0 committers\n'
1190
self.assertEqualDiff(
1195
control: Meta directory format 1
1200
In the working tree:
1208
0 versioned subdirectories
1219
lco_tree._format.get_format_description(),
1220
lco_tree.branch._format.get_format_description(),
1221
lco_tree.branch.repository._format.get_format_description(),
1222
expected_lock_output,
1225
self.assertEqual('', err)
1227
def test_info_locking(self):
1228
transport = self.get_transport()
1229
# Create shared repository with a branch
1230
repo = self.make_repository('repo', shared=True,
1231
format=bzrdir.BzrDirMetaFormat1())
1232
repo.set_make_working_trees(False)
1233
repo.bzrdir.root_transport.mkdir('branch')
1234
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1235
format=bzrdir.BzrDirMetaFormat1())
1236
# Do a heavy checkout
1237
transport.mkdir('tree')
1238
transport.mkdir('tree/checkout')
1239
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1240
format=bzrdir.BzrDirMetaFormat1())
1241
co_branch.bind(repo_branch)
1242
# Do a light checkout of the heavy one
1243
transport.mkdir('tree/lightcheckout')
1244
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1245
branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1246
lco_dir.create_workingtree()
1247
lco_tree = lco_dir.open_workingtree()
1249
# Test all permutations of locking the working tree, branch and repository
1253
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1254
repo_branch=repo_branch,
1255
verbose=True, light_checkout=True)
1257
lco_tree.branch.repository.lock_write()
1259
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1260
lco_tree, repo_branch=repo_branch,
1261
repo_locked=True, verbose=True, light_checkout=True)
1263
lco_tree.branch.repository.unlock()
1265
lco_tree.branch.lock_write()
1267
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1271
repo_branch=repo_branch,
1274
lco_tree.branch.unlock()
1276
lco_tree.lock_write()
1278
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1279
lco_tree, repo_branch=repo_branch,
1287
lco_tree.lock_write()
1288
lco_tree.branch.repository.unlock()
1290
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1291
lco_tree, repo_branch=repo_branch,
1296
lco_tree.branch.repository.lock_write()
1299
lco_tree.lock_write()
1300
lco_tree.branch.unlock()
1302
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1303
lco_tree, repo_branch=repo_branch,
1307
lco_tree.branch.lock_write()
1310
lco_tree.lock_write()
1311
lco_tree.branch.unlock()
1312
lco_tree.branch.repository.lock_write()
1314
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1315
lco_tree, repo_branch=repo_branch,
1320
lco_tree.branch.repository.unlock()
1321
lco_tree.branch.lock_write()
1324
lco_tree.branch.lock_write()
1325
lco_tree.branch.repository.unlock()
1327
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1328
lco_tree, repo_branch=repo_branch,
1332
lco_tree.branch.repository.lock_write()
1333
lco_tree.branch.unlock()
1335
if sys.platform == 'win32':
1336
self.knownFailure('Win32 cannot run "bzr info"'
1337
' when the tree is locked.')
1339
def test_info_locking_oslocks(self):
1340
if sys.platform == "win32":
1341
raise TestSkipped("don't use oslocks on win32 in unix manner")
1343
tree = self.make_branch_and_tree('branch',
1344
format=bzrdir.BzrDirFormat6())
1346
# Test all permutations of locking the working tree, branch and repository
1347
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1348
# implemented by raising NotImplementedError and get_physical_lock_status()
1349
# always returns false. This makes bzr info hide the lock status. (Olaf)
1353
out, err = self.run_bzr('info -v branch')
1354
self.assertEqualDiff(
1355
"""Standalone tree (format: weave)
1360
control: All-in-one format 6
1361
working tree: Working tree format 2
1362
branch: Branch format 4
1365
In the working tree:
1373
0 versioned subdirectories
1380
""" % ('branch', tree.branch.repository._format.get_format_description(),
1382
self.assertEqual('', err)
1385
out, err = self.run_bzr('info -v branch')
1386
self.assertEqualDiff(
1387
"""Standalone tree (format: weave)
1392
control: All-in-one format 6
1393
working tree: Working tree format 2
1394
branch: Branch format 4
1397
In the working tree:
1405
0 versioned subdirectories
1412
""" % ('branch', tree.branch.repository._format.get_format_description(),
1414
self.assertEqual('', err)
1417
def test_info_stacked(self):
1418
# We have a mainline
1419
trunk_tree = self.make_branch_and_tree('mainline',
1421
trunk_tree.commit('mainline')
1422
# and a branch from it which is stacked
1423
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1424
out, err = self.run_bzr('info newbranch')
1426
"""Standalone tree (format: 1.6)
1428
branch root: newbranch
1431
parent branch: mainline
1432
stacked on: mainline
1434
self.assertEqual("", err)