1
# Copyright (C) 2006-2010 Canonical Ltd
1
# Copyright (C) 2006 by Canonical Ltd
2
# -*- coding: utf-8 -*-
3
4
# This program is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
5
6
# the Free Software Foundation; either version 2 of the License, or
6
7
# (at your option) any later version.
8
9
# This program is distributed in the hope that it will be useful,
9
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
12
# GNU General Public License for more details.
13
14
# You should have received a copy of the GNU General Public License
14
15
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19
"""Tests for the info command of bzr."""
32
from bzrlib.transport import memory
35
class TestInfo(tests.TestCaseWithTransport):
38
super(TestInfo, self).setUp()
39
self._repo_strings = "2a"
41
def test_info_non_existing(self):
42
self.vfs_transport_factory = memory.MemoryServer
43
location = self.get_url()
44
out, err = self.run_bzr('info '+location, retcode=3)
45
self.assertEqual(out, '')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
48
def test_info_standalone(self):
49
transport = self.get_transport()
51
# Create initial standalone branch
52
tree1 = self.make_branch_and_tree('standalone', 'knit')
53
self.build_tree(['standalone/a'])
55
branch1 = tree1.branch
57
out, err = self.run_bzr('info standalone')
59
"""Standalone tree (format: knit)
61
branch root: standalone
63
self.assertEqual('', err)
65
# Standalone branch - verbose mode
66
out, err = self.run_bzr('info standalone -v')
68
"""Standalone tree (format: knit)
70
branch root: standalone
73
control: Meta directory format 1
74
working tree: Working tree format 3
75
branch: Branch format 5
76
repository: Knit repository format 1
86
0 versioned subdirectories
94
self.assertEqual('', err)
96
# Standalone branch - really verbose mode
97
out, err = self.run_bzr('info standalone -vv')
99
"""Standalone tree (format: knit)
101
branch root: standalone
104
control: Meta directory format 1
105
working tree: Working tree format 3
106
branch: Branch format 5
107
repository: Knit repository format 1
117
0 versioned subdirectories
126
self.assertEqual('', err)
127
tree1.commit('commit one')
128
rev = branch1.repository.get_revision(branch1.revision_history()[0])
129
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
131
# Branch standalone with push location
132
branch2 = branch1.bzrdir.sprout('branch').open_branch()
133
branch2.set_push_location(branch1.bzrdir.root_transport.base)
135
out, err = self.run_bzr('info branch')
136
self.assertEqualDiff(
137
"""Standalone tree (format: knit)
142
push branch: standalone
143
parent branch: standalone
145
self.assertEqual('', err)
147
out, err = self.run_bzr('info branch --verbose')
148
self.assertEqualDiff(
149
"""Standalone tree (format: knit)
154
push branch: standalone
155
parent branch: standalone
158
control: Meta directory format 1
159
working tree: Working tree format 3
160
branch: Branch format 5
161
repository: Knit repository format 1
171
0 versioned subdirectories
181
""" % (datestring_first, datestring_first,
183
self.assertEqual('', err)
185
# Branch and bind to standalone, needs upgrade to metadir
186
# (creates backup as unknown)
187
branch1.bzrdir.sprout('bound')
188
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
189
upgrade.upgrade('bound', knit1_format)
190
branch3 = bzrdir.BzrDir.open('bound').open_branch()
191
branch3.bind(branch1)
192
bound_tree = branch3.bzrdir.open_workingtree()
193
out, err = self.run_bzr('info -v bound')
194
self.assertEqualDiff(
195
"""Checkout (format: knit)
198
checkout of branch: standalone
201
parent branch: standalone
204
control: Meta directory format 1
217
0 versioned subdirectories
227
""" % (bound_tree._format.get_format_description(),
228
branch3._format.get_format_description(),
229
branch3.repository._format.get_format_description(),
230
datestring_first, datestring_first,
232
self.assertEqual('', err)
234
# Checkout standalone (same as above, but does not have parent set)
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
237
branch4.bind(branch1)
238
branch4.bzrdir.open_workingtree().update()
239
out, err = self.run_bzr('info checkout --verbose')
240
self.assertEqualDiff(
241
"""Checkout (format: knit)
243
checkout root: checkout
244
checkout of branch: standalone
247
control: Meta directory format 1
248
working tree: Working tree format 3
249
branch: Branch format 5
260
0 versioned subdirectories
270
""" % (branch4.repository._format.get_format_description(),
271
datestring_first, datestring_first,
273
self.assertEqual('', err)
275
# Lightweight checkout (same as above, different branch and repository)
276
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
277
branch5 = tree5.branch
278
out, err = self.run_bzr('info -v lightcheckout')
279
if "metaweave" in bzrdir.format_registry:
280
format_description = "knit or metaweave"
282
format_description = "knit"
283
self.assertEqualDiff(
284
"""Lightweight checkout (format: %s)
286
light checkout root: lightcheckout
287
checkout of branch: standalone
290
control: Meta directory format 1
291
working tree: Working tree format 3
292
branch: Branch format 5
293
repository: Knit repository format 1
303
0 versioned subdirectories
313
""" % (format_description, datestring_first, datestring_first,), out)
314
self.assertEqual('', err)
316
# Update initial standalone branch
317
self.build_tree(['standalone/b'])
319
tree1.commit('commit two')
320
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
321
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
323
# Out of date branched standalone branch will not be detected
324
out, err = self.run_bzr('info -v branch')
325
self.assertEqualDiff(
326
"""Standalone tree (format: knit)
331
push branch: standalone
332
parent branch: standalone
335
control: Meta directory format 1
336
working tree: Working tree format 3
337
branch: Branch format 5
338
repository: Knit repository format 1
348
0 versioned subdirectories
358
""" % (datestring_first, datestring_first,
360
self.assertEqual('', err)
362
# Out of date bound branch
363
out, err = self.run_bzr('info -v bound')
364
self.assertEqualDiff(
365
"""Checkout (format: knit)
368
checkout of branch: standalone
371
parent branch: standalone
374
control: Meta directory format 1
375
working tree: Working tree format 3
376
branch: Branch format 5
379
Branch is out of date: missing 1 revision.
389
0 versioned subdirectories
399
""" % (branch3.repository._format.get_format_description(),
400
datestring_first, datestring_first,
402
self.assertEqual('', err)
404
# Out of date checkout
405
out, err = self.run_bzr('info -v checkout')
406
self.assertEqualDiff(
407
"""Checkout (format: knit)
409
checkout root: checkout
410
checkout of branch: standalone
413
control: Meta directory format 1
414
working tree: Working tree format 3
415
branch: Branch format 5
418
Branch is out of date: missing 1 revision.
428
0 versioned subdirectories
438
""" % (branch4.repository._format.get_format_description(),
439
datestring_first, datestring_first,
441
self.assertEqual('', err)
443
# Out of date lightweight checkout
444
out, err = self.run_bzr('info lightcheckout --verbose')
445
self.assertEqualDiff(
446
"""Lightweight checkout (format: %s)
448
light checkout root: lightcheckout
449
checkout of branch: standalone
452
control: Meta directory format 1
453
working tree: Working tree format 3
454
branch: Branch format 5
455
repository: Knit repository format 1
457
Working tree is out of date: missing 1 revision.
467
0 versioned subdirectories
477
""" % (format_description, datestring_first, datestring_last,), out)
478
self.assertEqual('', err)
480
def test_info_standalone_no_tree(self):
481
# create standalone branch without a working tree
482
format = bzrdir.format_registry.make_bzrdir('default')
483
branch = self.make_branch('branch')
484
repo = branch.repository
485
out, err = self.run_bzr('info branch -v')
486
self.assertEqualDiff(
487
"""Standalone branch (format: %s)
492
control: Meta directory format 1
501
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
502
format.get_branch_format().get_format_description(),
503
format.repository_format.get_format_description(),
505
self.assertEqual('', err)
507
def test_info_shared_repository(self):
508
format = bzrdir.format_registry.make_bzrdir('knit')
509
transport = self.get_transport()
511
# Create shared repository
512
repo = self.make_repository('repo', shared=True, format=format)
513
repo.set_make_working_trees(False)
514
out, err = self.run_bzr('info -v repo')
515
self.assertEqualDiff(
516
"""Shared repository (format: dirstate or dirstate-tags or knit)
518
shared repository: %s
521
control: Meta directory format 1
526
""" % ('repo', format.repository_format.get_format_description(),
528
self.assertEqual('', err)
530
# Create branch inside shared repository
531
repo.bzrdir.root_transport.mkdir('branch')
532
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
534
out, err = self.run_bzr('info -v repo/branch')
535
self.assertEqualDiff(
536
"""Repository branch (format: dirstate or knit)
538
shared repository: repo
539
repository branch: repo/branch
542
control: Meta directory format 1
551
""" % (format.get_branch_format().get_format_description(),
552
format.repository_format.get_format_description(),
554
self.assertEqual('', err)
556
# Create lightweight checkout
557
transport.mkdir('tree')
558
transport.mkdir('tree/lightcheckout')
559
tree2 = branch1.create_checkout('tree/lightcheckout',
561
branch2 = tree2.branch
562
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
563
shared_repo=repo, repo_branch=branch1, verbose=True)
565
# Create normal checkout
566
tree3 = branch1.create_checkout('tree/checkout')
567
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
569
light_checkout=False, repo_branch=branch1)
570
# Update lightweight checkout
571
self.build_tree(['tree/lightcheckout/a'])
573
tree2.commit('commit one')
574
rev = repo.get_revision(branch2.revision_history()[0])
575
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
576
out, err = self.run_bzr('info tree/lightcheckout --verbose')
577
self.assertEqualDiff(
578
"""Lightweight checkout (format: %s)
580
light checkout root: tree/lightcheckout
581
checkout of branch: repo/branch
582
shared repository: repo
585
control: Meta directory format 1
586
working tree: Working tree format 6
598
0 versioned subdirectories
608
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
609
format.repository_format.get_format_description(),
610
datestring_first, datestring_first,
612
self.assertEqual('', err)
614
# Out of date checkout
615
out, err = self.run_bzr('info -v tree/checkout')
616
self.assertEqualDiff(
617
"""Checkout (format: unnamed)
619
checkout root: tree/checkout
620
checkout of branch: repo/branch
623
control: Meta directory format 1
624
working tree: Working tree format 6
628
Branch is out of date: missing 1 revision.
638
0 versioned subdirectories
645
""" % (format.get_branch_format().get_format_description(),
646
format.repository_format.get_format_description(),
648
self.assertEqual('', err)
652
self.build_tree(['tree/checkout/b'])
654
out, err = self.run_bzr('info tree/checkout --verbose')
655
self.assertEqualDiff(
656
"""Checkout (format: unnamed)
658
checkout root: tree/checkout
659
checkout of branch: repo/branch
662
control: Meta directory format 1
663
working tree: Working tree format 6
675
0 versioned subdirectories
685
""" % (format.get_branch_format().get_format_description(),
686
format.repository_format.get_format_description(),
687
datestring_first, datestring_first,
689
self.assertEqual('', err)
690
tree3.commit('commit two')
692
# Out of date lightweight checkout
693
rev = repo.get_revision(branch1.revision_history()[-1])
694
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
695
out, err = self.run_bzr('info tree/lightcheckout --verbose')
696
self.assertEqualDiff(
697
"""Lightweight checkout (format: %s)
699
light checkout root: tree/lightcheckout
700
checkout of branch: repo/branch
701
shared repository: repo
704
control: Meta directory format 1
705
working tree: Working tree format 6
709
Working tree is out of date: missing 1 revision.
719
0 versioned subdirectories
729
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
730
format.repository_format.get_format_description(),
731
datestring_first, datestring_last,
733
self.assertEqual('', err)
735
# Show info about shared branch
736
out, err = self.run_bzr('info repo/branch --verbose')
737
self.assertEqualDiff(
738
"""Repository branch (format: dirstate or knit)
740
shared repository: repo
741
repository branch: repo/branch
744
control: Meta directory format 1
756
""" % (format.get_branch_format().get_format_description(),
757
format.repository_format.get_format_description(),
758
datestring_first, datestring_last,
760
self.assertEqual('', err)
762
# Show info about repository with revisions
763
out, err = self.run_bzr('info -v repo')
764
self.assertEqualDiff(
765
"""Shared repository (format: dirstate or dirstate-tags or knit)
767
shared repository: repo
770
control: Meta directory format 1
775
""" % (format.repository_format.get_format_description(),
777
self.assertEqual('', err)
779
def test_info_shared_repository_with_trees(self):
780
format = bzrdir.format_registry.make_bzrdir('knit')
781
transport = self.get_transport()
783
# Create shared repository with working trees
784
repo = self.make_repository('repo', shared=True, format=format)
785
repo.set_make_working_trees(True)
786
out, err = self.run_bzr('info -v repo')
787
self.assertEqualDiff(
788
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
790
shared repository: repo
793
control: Meta directory format 1
796
Create working tree for new branches inside the repository.
800
""" % (format.repository_format.get_format_description(),
802
self.assertEqual('', err)
804
# Create two branches
805
repo.bzrdir.root_transport.mkdir('branch1')
806
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
808
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
811
out, err = self.run_bzr('info repo/branch1 --verbose')
812
self.assertEqualDiff(
813
"""Repository tree (format: knit)
815
shared repository: repo
816
repository branch: repo/branch1
819
control: Meta directory format 1
820
working tree: Working tree format 3
832
0 versioned subdirectories
839
""" % (format.get_branch_format().get_format_description(),
840
format.repository_format.get_format_description(),
842
self.assertEqual('', err)
844
# Update first branch
845
self.build_tree(['repo/branch1/a'])
846
tree1 = branch1.bzrdir.open_workingtree()
848
tree1.commit('commit one')
849
rev = repo.get_revision(branch1.revision_history()[0])
850
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
851
out, err = self.run_bzr('info -v repo/branch1')
852
self.assertEqualDiff(
853
"""Repository tree (format: knit)
855
shared repository: repo
856
repository branch: repo/branch1
859
control: Meta directory format 1
860
working tree: Working tree format 3
872
0 versioned subdirectories
882
""" % (format.get_branch_format().get_format_description(),
883
format.repository_format.get_format_description(),
884
datestring_first, datestring_first,
886
self.assertEqual('', err)
888
# Out of date second branch
889
out, err = self.run_bzr('info repo/branch2 --verbose')
890
self.assertEqualDiff(
891
"""Repository tree (format: knit)
893
shared repository: repo
894
repository branch: repo/branch2
897
parent branch: repo/branch1
900
control: Meta directory format 1
901
working tree: Working tree format 3
913
0 versioned subdirectories
920
""" % (format.get_branch_format().get_format_description(),
921
format.repository_format.get_format_description(),
923
self.assertEqual('', err)
925
# Update second branch
926
tree2 = branch2.bzrdir.open_workingtree()
928
out, err = self.run_bzr('info -v repo/branch2')
929
self.assertEqualDiff(
930
"""Repository tree (format: knit)
932
shared repository: repo
933
repository branch: repo/branch2
936
parent branch: repo/branch1
939
control: Meta directory format 1
940
working tree: Working tree format 3
952
0 versioned subdirectories
962
""" % (format.get_branch_format().get_format_description(),
963
format.repository_format.get_format_description(),
964
datestring_first, datestring_first,
966
self.assertEqual('', err)
968
# Show info about repository with revisions
969
out, err = self.run_bzr('info -v repo')
970
self.assertEqualDiff(
971
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
973
shared repository: repo
976
control: Meta directory format 1
979
Create working tree for new branches inside the repository.
983
""" % (format.repository_format.get_format_description(),
22
from bzrlib.osutils import format_date
23
from bzrlib.tests import TestSkipped
24
from bzrlib.tests.blackbox import ExternalBase
27
class TestInfo(ExternalBase):
29
def test_info_standalone_trivial(self):
31
out, err = self.runbzr('info')
33
"""branch format: Bazaar-NG branch, format 6
43
0 versioned subdirectories
54
self.assertEqual('', err)
56
def test_info_up_to_date_checkout(self):
57
a_branch = self.make_branch_and_tree('branch')
58
self.runbzr('checkout branch checkout')
59
out, err = self.runbzr('info checkout')
61
"""working tree format: Bazaar-NG Working Tree format 3
63
branch format: Bazaar-NG branch, format 6
73
0 versioned subdirectories
82
""" % a_branch.bzrdir.root_transport.base,
84
self.assertEqual('', err)
86
def test_info_out_of_date_standalone_tree(self):
87
# FIXME the default format has to change for this to pass
88
# because it currently uses the branch last-revision marker.
89
raise TestSkipped('default format too old')
90
self.make_branch_and_tree('branch')
92
self.runbzr('checkout branch checkout')
93
self.build_tree(['checkout/file'])
94
self.runbzr('add checkout/file')
95
self.runbzr('commit -m add-file checkout')
96
# now branch should be out of date
97
out,err = self.runbzr('update branch')
99
"""branch format: Bazaar-NG branch, format 6
101
Working tree is out of date: missing 1 revision.
110
0 versioned subdirectories
119
""" % a_branch.bzrdir.root_transport.base,
121
self.assertEqual('', err)
123
def test_info_out_of_date_checkout(self):
124
# note this deliberately uses a checkout at 'None' to
125
# test the out of date message with a revision notin the
127
a_branch = self.make_branch('branch')
129
self.runbzr('checkout branch checkout')
130
self.runbzr('checkout branch checkout2')
131
self.build_tree(['checkout/file'])
132
self.runbzr('add checkout/file')
133
self.runbzr('commit -m add-file checkout')
134
# now checkout2 should be out of date
135
out,err = self.runbzr('info checkout2')
136
rev = a_branch.repository.get_revision(a_branch.revision_history()[0])
137
datestring = format_date(rev.timestamp, rev.timezone)
138
self.assertEqualDiff(
139
"""working tree format: Bazaar-NG Working Tree format 3
141
branch format: Bazaar-NG branch, format 6
143
Working tree is out of date: missing 1 revision.
152
0 versioned subdirectories
164
""" % (a_branch.bzrdir.root_transport.base,
986
self.assertEqual('', err)
988
def test_info_shared_repository_with_tree_in_root(self):
989
format = bzrdir.format_registry.make_bzrdir('knit')
990
transport = self.get_transport()
992
# Create shared repository with working trees
993
repo = self.make_repository('repo', shared=True, format=format)
994
repo.set_make_working_trees(True)
995
out, err = self.run_bzr('info -v repo')
996
self.assertEqualDiff(
997
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
999
shared repository: repo
1002
control: Meta directory format 1
1005
Create working tree for new branches inside the repository.
1009
""" % (format.repository_format.get_format_description(),
1011
self.assertEqual('', err)
1013
# Create branch in root of repository
1014
control = repo.bzrdir
1015
branch = control.create_branch()
1016
control.create_workingtree()
1017
out, err = self.run_bzr('info -v repo')
1018
self.assertEqualDiff(
1019
"""Repository tree (format: knit)
1021
shared repository: repo
1022
repository branch: repo
1025
control: Meta directory format 1
1026
working tree: Working tree format 3
1030
In the working tree:
1038
0 versioned subdirectories
1045
""" % (format.get_branch_format().get_format_description(),
1046
format.repository_format.get_format_description(),
1048
self.assertEqual('', err)
1050
def test_info_repository_hook(self):
1051
format = bzrdir.format_registry.make_bzrdir('knit')
1052
def repo_info(repo, stats, outf):
1053
outf.write("more info\n")
1054
info.hooks.install_named_hook('repository', repo_info, None)
1055
# Create shared repository with working trees
1056
repo = self.make_repository('repo', shared=True, format=format)
1057
out, err = self.run_bzr('info -v repo')
1058
self.assertEqualDiff(
1059
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1061
shared repository: repo
1064
control: Meta directory format 1
1067
Create working tree for new branches inside the repository.
1072
""" % (format.repository_format.get_format_description(),
1074
self.assertEqual('', err)
1076
def assertCheckoutStatusOutput(self,
1077
command_string, lco_tree, shared_repo=None,
1080
branch_locked=False, repo_locked=False,
1082
light_checkout=True,
1083
checkout_root=None):
1084
"""Check the output of info in a checkout.
1086
This is not quite a mirror of the info code: rather than using the
1087
tree being examined to predict output, it uses a bunch of flags which
1088
allow us, the test writers, to document what *should* be present in
1089
the output. Removing this separation would remove the value of the
1092
:param path: the path to the light checkout.
1093
:param lco_tree: the tree object for the light checkout.
1094
:param shared_repo: A shared repository is in use, expect that in
1096
:param repo_branch: A branch in a shared repository for non light
1098
:param tree_locked: If true, expect the tree to be locked.
1099
:param branch_locked: If true, expect the branch to be locked.
1100
:param repo_locked: If true, expect the repository to be locked.
1101
Note that the lco_tree.branch.repository is inspected, and if is not
1102
actually locked then this parameter is overridden. This is because
1103
pack repositories do not have any public API for obtaining an
1104
exclusive repository wide lock.
1105
:param verbose: verbosity level: 2 or higher to show committers
1107
def friendly_location(url):
1108
path = urlutils.unescape_for_display(url, 'ascii')
1110
return osutils.relpath(osutils.getcwd(), path)
1111
except errors.PathNotChild:
1115
# We expect this to fail because of locking errors.
1116
# (A write-locked file cannot be read-locked
1117
# in the different process -- either on win32 or on linux).
1118
# This should be removed when the locking errors are fixed.
1119
self.expectFailure('OS locks are exclusive '
1120
'for different processes (Bug #174055)',
1121
self.run_bzr_subprocess,
1122
'info ' + command_string)
1123
out, err = self.run_bzr('info %s' % command_string)
1125
(True, True): 'Lightweight checkout',
1126
(True, False): 'Repository checkout',
1127
(False, True): 'Lightweight checkout',
1128
(False, False): 'Checkout',
1129
}[(shared_repo is not None, light_checkout)]
1130
format = {True: self._repo_strings,
1131
False: 'unnamed'}[light_checkout]
1133
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1134
if repo_locked or branch_locked or tree_locked:
1135
def locked_message(a_bool):
1140
expected_lock_output = (
1143
" working tree: %s\n"
1145
" repository: %s\n" % (
1146
locked_message(tree_locked),
1147
locked_message(branch_locked),
1148
locked_message(repo_locked)))
1150
expected_lock_output = ''
1154
tree_data = (" light checkout root: %s\n" %
1155
friendly_location(lco_tree.bzrdir.root_transport.base))
1157
if lco_tree.branch.get_bound_location() is not None:
1158
tree_data += ("%s checkout root: %s\n" % (extra_space,
1159
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1160
if shared_repo is not None:
1162
" checkout of branch: %s\n"
1163
" shared repository: %s\n" %
1164
(friendly_location(repo_branch.bzrdir.root_transport.base),
1165
friendly_location(shared_repo.bzrdir.root_transport.base)))
1166
elif repo_branch is not None:
1168
"%s checkout of branch: %s\n" %
1170
friendly_location(repo_branch.bzrdir.root_transport.base)))
1172
branch_data = (" checkout of branch: %s\n" %
1173
lco_tree.branch.bzrdir.root_transport.base)
1176
verbose_info = ' 0 committers\n'
1180
self.assertEqualDiff(
1185
control: Meta directory format 1
1190
In the working tree:
1198
0 versioned subdirectories
1209
lco_tree._format.get_format_description(),
1210
lco_tree.branch._format.get_format_description(),
1211
lco_tree.branch.repository._format.get_format_description(),
1212
expected_lock_output,
1215
self.assertEqual('', err)
1217
def test_info_locking(self):
1218
transport = self.get_transport()
1219
# Create shared repository with a branch
1220
repo = self.make_repository('repo', shared=True,
1221
format=bzrdir.BzrDirMetaFormat1())
1222
repo.set_make_working_trees(False)
1223
repo.bzrdir.root_transport.mkdir('branch')
1224
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1225
format=bzrdir.BzrDirMetaFormat1())
1226
# Do a heavy checkout
1227
transport.mkdir('tree')
1228
transport.mkdir('tree/checkout')
1229
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1230
format=bzrdir.BzrDirMetaFormat1())
1231
co_branch.bind(repo_branch)
1232
# Do a light checkout of the heavy one
1233
transport.mkdir('tree/lightcheckout')
1234
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1235
branch.BranchReferenceFormat().initialize(lco_dir,
1236
target_branch=co_branch)
1237
lco_dir.create_workingtree()
1238
lco_tree = lco_dir.open_workingtree()
1240
# Test all permutations of locking the working tree, branch and repository
1244
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1245
repo_branch=repo_branch,
1246
verbose=True, light_checkout=True)
1248
lco_tree.branch.repository.lock_write()
1250
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1251
lco_tree, repo_branch=repo_branch,
1252
repo_locked=True, verbose=True, light_checkout=True)
1254
lco_tree.branch.repository.unlock()
1256
lco_tree.branch.lock_write()
1258
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1262
repo_branch=repo_branch,
1265
lco_tree.branch.unlock()
1267
lco_tree.lock_write()
1269
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1270
lco_tree, repo_branch=repo_branch,
1278
lco_tree.lock_write()
1279
lco_tree.branch.repository.unlock()
1281
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1282
lco_tree, repo_branch=repo_branch,
1287
lco_tree.branch.repository.lock_write()
1290
lco_tree.lock_write()
1291
lco_tree.branch.unlock()
1293
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1294
lco_tree, repo_branch=repo_branch,
1298
lco_tree.branch.lock_write()
1301
lco_tree.lock_write()
1302
lco_tree.branch.unlock()
1303
lco_tree.branch.repository.lock_write()
1305
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1306
lco_tree, repo_branch=repo_branch,
1311
lco_tree.branch.repository.unlock()
1312
lco_tree.branch.lock_write()
1315
lco_tree.branch.lock_write()
1316
lco_tree.branch.repository.unlock()
1318
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1319
lco_tree, repo_branch=repo_branch,
1323
lco_tree.branch.repository.lock_write()
1324
lco_tree.branch.unlock()
1326
if sys.platform == 'win32':
1327
self.knownFailure('Win32 cannot run "bzr info"'
1328
' when the tree is locked.')
1330
def test_info_stacked(self):
1331
# We have a mainline
1332
trunk_tree = self.make_branch_and_tree('mainline',
1334
trunk_tree.commit('mainline')
1335
# and a branch from it which is stacked
1336
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1337
out, err = self.run_bzr('info newbranch')
1339
"""Standalone tree (format: 1.6)
1341
branch root: newbranch
1344
parent branch: mainline
1345
stacked on: mainline
1347
self.assertEqual("", err)
169
self.assertEqual('', err)