13
13
# You should have received a copy of the GNU General Public License
14
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
18
"""Tests for the info command of bzr."""
22
23
from bzrlib import (
32
from bzrlib.transport import memory
35
class TestInfo(tests.TestCaseWithTransport):
38
super(TestInfo, self).setUp()
39
self._repo_strings = "2a"
27
from bzrlib.osutils import format_date
28
from bzrlib.tests import TestSkipped
29
from bzrlib.tests.blackbox import ExternalBase
32
class TestInfo(ExternalBase):
41
34
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)
35
if sys.platform == "win32":
36
location = "C:/i/do/not/exist/"
38
location = "/i/do/not/exist/"
39
out, err = self.runbzr('info '+location, retcode=3)
45
40
self.assertEqual(out, '')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
41
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
48
43
def test_info_standalone(self):
49
44
transport = self.get_transport()
51
46
# Create initial standalone branch
52
tree1 = self.make_branch_and_tree('standalone', 'knit')
47
tree1 = self.make_branch_and_tree('standalone', 'weave')
53
48
self.build_tree(['standalone/a'])
55
50
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
51
out, err = self.runbzr('info standalone')
57
control: All-in-one format 6
58
working tree: Working tree format 2
59
branch: Branch format 4
60
repository: Weave repository format 6
70
0 versioned subdirectories
78
""" % branch1.bzrdir.root_transport.base, out)
126
79
self.assertEqual('', err)
127
80
tree1.commit('commit one')
128
81
rev = branch1.repository.get_revision(branch1.revision_history()[0])
129
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
82
datestring_first = format_date(rev.timestamp, rev.timezone)
131
84
# Branch standalone with push location
132
85
branch2 = branch1.bzrdir.sprout('branch').open_branch()
133
86
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
87
out, err = self.runbzr('info branch --verbose')
158
control: Meta directory format 1
159
working tree: Working tree format 3
160
branch: Branch format 5
161
repository: Knit repository format 1
97
control: All-in-one format 6
98
working tree: Working tree format 2
99
branch: Branch format 4
100
repository: Weave repository format 6
163
102
In the working tree:
186
134
# (creates backup as unknown)
187
135
branch1.bzrdir.sprout('bound')
188
136
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
189
upgrade.upgrade('bound', knit1_format)
190
branch3 = bzrdir.BzrDir.open('bound').open_branch()
137
bzrlib.upgrade.upgrade('bound', knit1_format)
138
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
191
139
branch3.bind(branch1)
192
140
bound_tree = branch3.bzrdir.open_workingtree()
193
out, err = self.run_bzr('info -v bound')
141
out, err = self.runbzr('info bound')
194
142
self.assertEqualDiff(
195
"""Checkout (format: knit)
198
checkout of branch: standalone
145
checkout of branch: %s
200
147
Related branches:
201
parent branch: standalone
204
151
control: Meta directory format 1
227
""" % (bound_tree._format.get_format_description(),
175
""" % (branch3.bzrdir.root_transport.base,
176
branch1.bzrdir.root_transport.base,
177
branch1.bzrdir.root_transport.base,
178
bound_tree._format.get_format_description(),
228
179
branch3._format.get_format_description(),
229
180
branch3.repository._format.get_format_description(),
230
181
datestring_first, datestring_first,
182
# poking at _revision_store isn't all that clean, but neither is
183
# having the ui test dependent on the exact overhead of a given store.
184
branch3.repository._revision_store.total_size(
185
branch3.repository.get_transaction())[1] / 1024,
232
187
self.assertEqual('', err)
234
189
# Checkout standalone (same as above, but does not have parent set)
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
190
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
236
191
format=knit1_format)
237
192
branch4.bind(branch1)
238
193
branch4.bzrdir.open_workingtree().update()
239
out, err = self.run_bzr('info checkout --verbose')
194
out, err = self.runbzr('info checkout --verbose')
240
195
self.assertEqualDiff(
241
"""Checkout (format: knit)
243
checkout root: checkout
244
checkout of branch: standalone
198
checkout of branch: %s
247
201
control: Meta directory format 1
265
220
first revision: %s
266
221
latest revision: %s
270
""" % (branch4.repository._format.get_format_description(),
226
""" % (branch4.bzrdir.root_transport.base,
227
branch1.bzrdir.root_transport.base,
228
branch4.repository._format.get_format_description(),
271
229
datestring_first, datestring_first,
230
# poking at _revision_store isn't all that clean, but neither is
231
# having the ui test dependent on the exact overhead of a given store.
232
branch4.repository._revision_store.total_size(
233
branch4.repository.get_transaction())[1] / 1024,
273
235
self.assertEqual('', err)
275
237
# Lightweight checkout (same as above, different branch and repository)
276
238
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
277
239
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"
240
out, err = self.runbzr('info lightcheckout')
283
241
self.assertEqualDiff(
284
"""Lightweight checkout (format: %s)
286
light checkout root: lightcheckout
287
checkout of branch: standalone
243
light checkout root: %s
244
checkout of branch: %s
290
247
control: Meta directory format 1
291
working tree: Working tree format 3
292
branch: Branch format 5
293
repository: Knit repository format 1
248
working tree: Working tree format 4
249
branch: Branch format 4
250
repository: Weave repository format 6
295
252
In the working tree:
319
280
tree1.commit('commit two')
320
281
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
321
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
282
datestring_last = format_date(rev.timestamp, rev.timezone)
323
284
# Out of date branched standalone branch will not be detected
324
out, err = self.run_bzr('info -v branch')
285
out, err = self.runbzr('info branch')
325
286
self.assertEqualDiff(
326
"""Standalone tree (format: knit)
330
290
Related branches:
331
push branch: standalone
332
parent branch: standalone
292
publish to branch: %s
335
control: Meta directory format 1
336
working tree: Working tree format 3
337
branch: Branch format 5
338
repository: Knit repository format 1
295
control: All-in-one format 6
296
working tree: Working tree format 2
297
branch: Branch format 4
298
repository: Weave repository format 6
340
300
In the working tree:
358
""" % (datestring_first, datestring_first,
319
""" % (branch2.bzrdir.root_transport.base,
320
branch1.bzrdir.root_transport.base,
321
branch1.bzrdir.root_transport.base,
322
datestring_first, datestring_first,
360
324
self.assertEqual('', err)
362
326
# Out of date bound branch
363
out, err = self.run_bzr('info -v bound')
327
out, err = self.runbzr('info bound')
364
328
self.assertEqualDiff(
365
"""Checkout (format: knit)
368
checkout of branch: standalone
331
checkout of branch: %s
370
333
Related branches:
371
parent branch: standalone
374
337
control: Meta directory format 1
399
""" % (branch3.repository._format.get_format_description(),
363
""" % (branch3.bzrdir.root_transport.base,
364
branch1.bzrdir.root_transport.base,
365
branch1.bzrdir.root_transport.base,
366
branch3.repository._format.get_format_description(),
400
367
datestring_first, datestring_first,
368
# poking at _revision_store isn't all that clean, but neither is
369
# having the ui test dependent on the exact overhead of a given store.
370
branch3.repository._revision_store.total_size(
371
branch3.repository.get_transaction())[1] / 1024,
402
373
self.assertEqual('', err)
404
375
# Out of date checkout
405
out, err = self.run_bzr('info -v checkout')
376
out, err = self.runbzr('info checkout')
406
377
self.assertEqualDiff(
407
"""Checkout (format: knit)
409
checkout root: checkout
410
checkout of branch: standalone
380
checkout of branch: %s
413
383
control: Meta directory format 1
438
""" % (branch4.repository._format.get_format_description(),
409
""" % (branch4.bzrdir.root_transport.base,
410
branch1.bzrdir.root_transport.base,
411
branch4.repository._format.get_format_description(),
439
412
datestring_first, datestring_first,
413
# poking at _revision_store isn't all that clean, but neither is
414
# having the ui test dependent on the exact overhead of a given store.
415
branch4.repository._revision_store.total_size(
416
branch4.repository.get_transaction())[1] / 1024,
441
418
self.assertEqual('', err)
443
420
# Out of date lightweight checkout
444
out, err = self.run_bzr('info lightcheckout --verbose')
421
out, err = self.runbzr('info lightcheckout --verbose')
445
422
self.assertEqualDiff(
446
"""Lightweight checkout (format: %s)
448
light checkout root: lightcheckout
449
checkout of branch: standalone
424
light checkout root: %s
425
checkout of branch: %s
452
428
control: Meta directory format 1
453
working tree: Working tree format 3
454
branch: Branch format 5
455
repository: Knit repository format 1
429
working tree: Working tree format 4
430
branch: Branch format 4
431
repository: Weave repository format 6
457
433
Working tree is out of date: missing 1 revision.
573
556
tree2.commit('commit one')
574
557
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')
558
datestring_first = format_date(rev.timestamp, rev.timezone)
559
out, err = self.runbzr('info tree/lightcheckout --verbose')
577
560
self.assertEqualDiff(
578
"""Lightweight checkout (format: %s)
580
light checkout root: tree/lightcheckout
581
checkout of branch: repo/branch
582
shared repository: repo
562
light checkout root: %s
563
shared repository: %s
564
repository branch: branch
585
567
control: Meta directory format 1
586
working tree: Working tree format 6
568
working tree: Working tree format 4
603
586
first revision: %s
604
587
latest revision: %s
608
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
592
""" % (tree2.bzrdir.root_transport.base,
593
repo.bzrdir.root_transport.base,
594
format.get_branch_format().get_format_description(),
609
595
format.repository_format.get_format_description(),
610
596
datestring_first, datestring_first,
597
# poking at _revision_store isn't all that clean, but neither is
598
# having the ui test dependent on the exact overhead of a given store.
599
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
612
601
self.assertEqual('', err)
614
603
# Out of date checkout
615
out, err = self.run_bzr('info -v tree/checkout')
604
out, err = self.runbzr('info tree/checkout')
616
605
self.assertEqualDiff(
617
"""Checkout (format: unnamed)
619
checkout root: tree/checkout
620
checkout of branch: repo/branch
608
checkout of branch: %s
623
611
control: Meta directory format 1
624
working tree: Working tree format 6
612
working tree: Working tree format 4
680
671
first revision: %s
681
672
latest revision: %s
685
""" % (format.get_branch_format().get_format_description(),
677
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
678
format.get_branch_format().get_format_description(),
686
679
format.repository_format.get_format_description(),
687
680
datestring_first, datestring_first,
681
# poking at _revision_store isn't all that clean, but neither is
682
# having the ui test dependent on the exact overhead of a given store.
683
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
689
685
self.assertEqual('', err)
690
686
tree3.commit('commit two')
692
688
# Out of date lightweight checkout
693
689
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')
690
datestring_last = format_date(rev.timestamp, rev.timezone)
691
out, err = self.runbzr('info tree/lightcheckout --verbose')
696
692
self.assertEqualDiff(
697
"""Lightweight checkout (format: %s)
699
light checkout root: tree/lightcheckout
700
checkout of branch: repo/branch
701
shared repository: repo
694
light checkout root: %s
695
shared repository: %s
696
repository branch: branch
704
699
control: Meta directory format 1
705
working tree: Working tree format 6
700
working tree: Working tree format 4
724
720
first revision: %s
725
721
latest revision: %s
729
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
726
""" % (tree2.bzrdir.root_transport.base,
727
repo.bzrdir.root_transport.base,
728
format.get_branch_format().get_format_description(),
730
729
format.repository_format.get_format_description(),
731
730
datestring_first, datestring_last,
731
# poking at _revision_store isn't all that clean, but neither is
732
# having the ui test dependent on the exact overhead of a given store.
733
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
733
735
self.assertEqual('', err)
735
737
# Show info about shared branch
736
out, err = self.run_bzr('info repo/branch --verbose')
738
out, err = self.runbzr('info repo/branch --verbose')
737
739
self.assertEqualDiff(
738
"""Repository branch (format: dirstate or knit)
740
shared repository: repo
741
repository branch: repo/branch
741
shared repository: %s
742
repository branch: branch
744
745
control: Meta directory format 1
751
753
first revision: %s
752
754
latest revision: %s
756
""" % (format.get_branch_format().get_format_description(),
759
""" % (repo.bzrdir.root_transport.base,
760
format.get_branch_format().get_format_description(),
757
761
format.repository_format.get_format_description(),
758
762
datestring_first, datestring_last,
763
# poking at _revision_store isn't all that clean, but neither is
764
# having the ui test dependent on the exact overhead of a given store.
765
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
760
767
self.assertEqual('', err)
762
769
# Show info about repository with revisions
763
out, err = self.run_bzr('info -v repo')
770
out, err = self.runbzr('info repo')
764
771
self.assertEqualDiff(
765
"""Shared repository (format: dirstate or dirstate-tags or knit)
767
shared repository: repo
773
shared repository: %s
770
776
control: Meta directory format 1
882
""" % (format.get_branch_format().get_format_description(),
896
""" % (repo.bzrdir.root_transport.base,
897
format.get_branch_format().get_format_description(),
883
898
format.repository_format.get_format_description(),
884
899
datestring_first, datestring_first,
900
# poking at _revision_store isn't all that clean, but neither is
901
# having the ui test dependent on the exact overhead of a given store.
902
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
886
904
self.assertEqual('', err)
888
906
# Out of date second branch
889
out, err = self.run_bzr('info repo/branch2 --verbose')
907
out, err = self.runbzr('info repo/branch2 --verbose')
890
908
self.assertEqualDiff(
891
"""Repository tree (format: knit)
893
shared repository: repo
894
repository branch: repo/branch2
910
shared repository: %s
911
repository checkout: branch2
896
913
Related branches:
897
parent branch: repo/branch1
900
917
control: Meta directory format 1
920
""" % (format.get_branch_format().get_format_description(),
939
""" % (repo.bzrdir.root_transport.base,
940
branch1.bzrdir.root_transport.base,
941
format.get_branch_format().get_format_description(),
921
942
format.repository_format.get_format_description(),
943
# poking at _revision_store isn't all that clean, but neither is
944
# having the ui test dependent on the exact overhead of a given store.
945
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
923
947
self.assertEqual('', err)
925
949
# Update second branch
926
950
tree2 = branch2.bzrdir.open_workingtree()
927
951
tree2.pull(branch1)
928
out, err = self.run_bzr('info -v repo/branch2')
952
out, err = self.runbzr('info repo/branch2')
929
953
self.assertEqualDiff(
930
"""Repository tree (format: knit)
932
shared repository: repo
933
repository branch: repo/branch2
955
shared repository: %s
956
repository checkout: branch2
935
958
Related branches:
936
parent branch: repo/branch1
939
962
control: Meta directory format 1
962
""" % (format.get_branch_format().get_format_description(),
986
""" % (repo.bzrdir.root_transport.base,
987
branch1.bzrdir.root_transport.base,
988
format.get_branch_format().get_format_description(),
963
989
format.repository_format.get_format_description(),
964
990
datestring_first, datestring_first,
991
# poking at _revision_store isn't all that clean, but neither is
992
# having the ui test dependent on the exact overhead of a given store.
993
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
966
995
self.assertEqual('', err)
968
997
# Show info about repository with revisions
969
out, err = self.run_bzr('info -v repo')
998
out, err = self.runbzr('info repo')
970
999
self.assertEqualDiff(
971
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
973
shared repository: repo
1001
shared repository: %s
976
1004
control: Meta directory format 1
1045
""" % (format.get_branch_format().get_format_description(),
1079
""" % (repo.bzrdir.root_transport.base,
1080
format.get_branch_format().get_format_description(),
1046
1081
format.repository_format.get_format_description(),
1048
1083
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,
1085
def assertCheckoutStatusOutput(self,
1077
1086
command_string, lco_tree, shared_repo=None,
1078
1087
repo_branch=None,
1079
1088
tree_locked=False,
1080
1089
branch_locked=False, repo_locked=False,
1082
light_checkout=True,
1083
checkout_root=None):
1084
"""Check the output of info in a checkout.
1091
light_checkout=True):
1092
"""Check the output of info in a light checkout tree.
1086
1094
This is not quite a mirror of the info code: rather than using the
1087
1095
tree being examined to predict output, it uses a bunch of flags which
1088
1096
allow us, the test writers, to document what *should* be present in
1089
1097
the output. Removing this separation would remove the value of the
1092
1100
:param path: the path to the light checkout.
1093
1101
:param lco_tree: the tree object for the light checkout.
1094
1102
:param shared_repo: A shared repository is in use, expect that in
1098
1106
:param tree_locked: If true, expect the tree to be locked.
1099
1107
:param branch_locked: If true, expect the branch to be locked.
1100
1108
: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
1109
:param verbose: If true, expect verbose output
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()
1111
out, err = self.runbzr('info %s' % command_string)
1134
1112
if repo_locked or branch_locked or tree_locked:
1135
1113
def locked_message(a_bool):
1148
1126
locked_message(repo_locked)))
1150
1128
expected_lock_output = ''
1153
1129
if light_checkout:
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)))
1130
tree_data = (" light checkout root: %s" %
1131
lco_tree.bzrdir.root_transport.base)
1133
tree_data = (" checkout root: %s" %
1134
lco_tree.bzrdir.root_transport.base)
1160
1135
if shared_repo is not None:
1161
1136
branch_data = (
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)))
1137
" shared repository: %s\n"
1138
" repository branch: branch\n" %
1139
shared_repo.bzrdir.root_transport.base)
1166
1140
elif repo_branch is not None:
1167
1141
branch_data = (
1168
"%s checkout of branch: %s\n" %
1170
friendly_location(repo_branch.bzrdir.root_transport.base)))
1142
" checkout of branch: %s\n" %
1143
repo_branch.bzrdir.root_transport.base)
1172
branch_data = (" checkout of branch: %s\n" %
1145
branch_data = (" checkout of branch: %s\n" %
1173
1146
lco_tree.branch.bzrdir.root_transport.base)
1176
1149
verbose_info = ' 0 committers\n'
1178
1151
verbose_info = ''
1180
1153
self.assertEqualDiff(
1185
1158
control: Meta directory format 1
1186
1159
working tree: %s
1218
1190
transport = self.get_transport()
1219
1191
# Create shared repository with a branch
1220
1192
repo = self.make_repository('repo', shared=True,
1221
format=bzrdir.BzrDirMetaFormat1())
1193
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1222
1194
repo.set_make_working_trees(False)
1223
1195
repo.bzrdir.root_transport.mkdir('branch')
1224
1196
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1225
format=bzrdir.BzrDirMetaFormat1())
1197
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1226
1198
# Do a heavy checkout
1227
1199
transport.mkdir('tree')
1228
1200
transport.mkdir('tree/checkout')
1229
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1230
format=bzrdir.BzrDirMetaFormat1())
1201
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1202
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1231
1203
co_branch.bind(repo_branch)
1232
1204
# Do a light checkout of the heavy one
1233
1205
transport.mkdir('tree/lightcheckout')
1234
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1235
branch.BranchReferenceFormat().initialize(lco_dir,
1236
target_branch=co_branch)
1206
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1207
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1237
1208
lco_dir.create_workingtree()
1238
1209
lco_tree = lco_dir.open_workingtree()
1244
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1245
repo_branch=repo_branch,
1246
verbose=True, light_checkout=True)
1215
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1248
1217
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)
1219
self.assertCheckoutStatusOutput('tree/lightcheckout',
1254
1223
lco_tree.branch.repository.unlock()
1256
1225
lco_tree.branch.lock_write()
1258
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1227
self.assertCheckoutStatusOutput('tree/lightcheckout',
1260
1229
branch_locked=True,
1262
repo_branch=repo_branch,
1265
1232
lco_tree.branch.unlock()
1267
1234
lco_tree.lock_write()
1269
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1270
lco_tree, repo_branch=repo_branch,
1236
self.assertCheckoutStatusOutput('tree/lightcheckout',
1271
1238
tree_locked=True,
1272
1239
branch_locked=True,
1276
1242
lco_tree.unlock()
1278
1244
lco_tree.lock_write()
1279
1245
lco_tree.branch.repository.unlock()
1281
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1282
lco_tree, repo_branch=repo_branch,
1247
self.assertCheckoutStatusOutput('tree/lightcheckout',
1283
1249
tree_locked=True,
1287
1252
lco_tree.branch.repository.lock_write()
1288
1253
lco_tree.unlock()
1315
1278
lco_tree.branch.lock_write()
1316
1279
lco_tree.branch.repository.unlock()
1318
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1319
lco_tree, repo_branch=repo_branch,
1281
self.assertCheckoutStatusOutput('tree/lightcheckout',
1323
1285
lco_tree.branch.repository.lock_write()
1324
1286
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)
1288
def test_info_locking_oslocks(self):
1289
if sys.platform == "win32":
1290
raise TestSkipped("don't use oslocks on win32 in unix manner")
1292
tree = self.make_branch_and_tree('branch',
1293
format=bzrlib.bzrdir.BzrDirFormat6())
1295
# Test all permutations of locking the working tree, branch and repository
1296
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1297
# implemented by raising NotImplementedError and get_physical_lock_status()
1298
# always returns false. This makes bzr info hide the lock status. (Olaf)
1302
out, err = self.runbzr('info branch')
1303
self.assertEqualDiff(
1308
control: All-in-one format 6
1309
working tree: Working tree format 2
1310
branch: Branch format 4
1313
In the working tree:
1321
0 versioned subdirectories
1329
""" % (tree.bzrdir.root_transport.base,
1330
tree.branch.repository._format.get_format_description(),
1332
self.assertEqual('', err)
1335
out, err = self.runbzr('info branch')
1336
self.assertEqualDiff(
1341
control: All-in-one format 6
1342
working tree: Working tree format 2
1343
branch: Branch format 4
1346
In the working tree:
1354
0 versioned subdirectories
1362
""" % (tree.bzrdir.root_transport.base,
1363
tree.branch.repository._format.get_format_description(),
1365
self.assertEqual('', err)