1
# Copyright (C) 2006-2010 Canonical Ltd
1
# Copyright (C) 2006, 2007 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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()
35
if sys.platform == "win32":
36
location = "C:/i/do/not/exist/"
38
location = "/i/do/not/exist/"
44
39
out, err = self.run_bzr('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()
58
53
self.assertEqualDiff(
59
54
"""Standalone tree (format: weave)
61
branch root: standalone
57
""" % branch1.bzrdir.root_transport.base, out)
63
58
self.assertEqual('', err)
65
# Standalone branch - verbose mode
66
60
out, err = self.run_bzr('info standalone -v')
67
61
self.assertEqualDiff(
68
62
"""Standalone tree (format: weave)
70
branch root: standalone
73
control: All-in-one format 6
74
working tree: Working tree format 2
75
branch: Branch format 4
76
repository: Weave repository format 6
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: weave)
101
branch root: standalone
104
67
control: All-in-one format 6
89
""" % branch1.bzrdir.root_transport.base, out)
126
90
self.assertEqual('', err)
127
91
tree1.commit('commit one')
128
92
rev = branch1.repository.get_revision(branch1.revision_history()[0])
129
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
93
datestring_first = format_date(rev.timestamp, rev.timezone)
131
95
# Branch standalone with push location
132
96
branch2 = branch1.bzrdir.sprout('branch').open_branch()
136
100
self.assertEqualDiff(
137
101
"""Standalone tree (format: weave)
141
105
Related branches:
142
push branch: standalone
143
parent branch: standalone
107
publish to branch: %s
108
""" % (branch2.bzrdir.root_transport.base,
109
branch1.bzrdir.root_transport.base,
110
branch1.bzrdir.root_transport.base), out)
145
111
self.assertEqual('', err)
147
113
out, err = self.run_bzr('info branch --verbose')
148
114
self.assertEqualDiff(
149
115
"""Standalone tree (format: weave)
153
119
Related branches:
154
push branch: standalone
155
parent branch: standalone
121
publish to branch: %s
158
124
control: All-in-one format 6
176
143
first revision: %s
177
144
latest revision: %s
181
""" % (datestring_first, datestring_first,
149
""" % (branch2.bzrdir.root_transport.base,
150
branch1.bzrdir.root_transport.base,
151
branch1.bzrdir.root_transport.base,
152
datestring_first, datestring_first,
153
# poking at _revision_store isn't all that clean, but neither is
154
# having the ui test dependent on the exact overhead of a given store.
155
branch2.repository._revision_store.total_size(
156
branch2.repository.get_transaction())[1] / 1024,
183
158
self.assertEqual('', err)
186
161
# (creates backup as unknown)
187
162
branch1.bzrdir.sprout('bound')
188
163
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
189
upgrade.upgrade('bound', knit1_format)
190
branch3 = bzrdir.BzrDir.open('bound').open_branch()
164
bzrlib.upgrade.upgrade('bound', knit1_format)
165
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
191
166
branch3.bind(branch1)
192
167
bound_tree = branch3.bzrdir.open_workingtree()
193
168
out, err = self.run_bzr('info -v bound')
194
169
self.assertEqualDiff(
195
170
"""Checkout (format: knit)
198
checkout of branch: standalone
173
checkout of branch: %s
200
175
Related branches:
201
parent branch: standalone
204
179
control: Meta directory format 1
217
192
0 versioned subdirectories
222
198
first revision: %s
223
199
latest revision: %s
227
""" % (bound_tree._format.get_format_description(),
204
""" % (branch3.bzrdir.root_transport.base,
205
branch1.bzrdir.root_transport.base,
206
branch1.bzrdir.root_transport.base,
207
bound_tree._format.get_format_description(),
228
208
branch3._format.get_format_description(),
229
209
branch3.repository._format.get_format_description(),
230
210
datestring_first, datestring_first,
211
# poking at _revision_store isn't all that clean, but neither is
212
# having the ui test dependent on the exact overhead of a given store.
213
branch3.repository._revision_store.total_size(
214
branch3.repository.get_transaction())[1] / 1024,
232
216
self.assertEqual('', err)
234
218
# Checkout standalone (same as above, but does not have parent set)
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
219
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
236
220
format=knit1_format)
237
221
branch4.bind(branch1)
238
222
branch4.bzrdir.open_workingtree().update()
265
250
first revision: %s
266
251
latest revision: %s
270
""" % (branch4.repository._format.get_format_description(),
256
""" % (branch4.bzrdir.root_transport.base,
257
branch1.bzrdir.root_transport.base,
258
branch4.repository._format.get_format_description(),
271
259
datestring_first, datestring_first,
260
# poking at _revision_store isn't all that clean, but neither is
261
# having the ui test dependent on the exact overhead of a given store.
262
branch4.repository._revision_store.total_size(
263
branch4.repository.get_transaction())[1] / 1024,
273
265
self.assertEqual('', err)
277
269
branch5 = tree5.branch
278
270
out, err = self.run_bzr('info -v lightcheckout')
279
271
self.assertEqualDiff(
280
"""Lightweight checkout (format: %s)
272
"""Lightweight checkout (format: dirstate or dirstate-tags)
282
light checkout root: lightcheckout
283
checkout of branch: standalone
274
light checkout root: %s
275
checkout of branch: %s
286
278
control: Meta directory format 1
287
working tree: Working tree format 6
279
working tree: Working tree format 4
288
280
branch: Branch format 4
289
281
repository: Weave repository format 6
304
297
first revision: %s
305
298
latest revision: %s
309
""" % (self._repo_strings, datestring_first, datestring_first,), out)
303
""" % (tree5.bzrdir.root_transport.base,
304
branch1.bzrdir.root_transport.base,
305
datestring_first, datestring_first,
310
307
self.assertEqual('', err)
312
309
# Update initial standalone branch
315
312
tree1.commit('commit two')
316
313
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
317
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
314
datestring_last = format_date(rev.timestamp, rev.timezone)
319
316
# Out of date branched standalone branch will not be detected
320
317
out, err = self.run_bzr('info -v branch')
321
318
self.assertEqualDiff(
322
319
"""Standalone tree (format: weave)
326
323
Related branches:
327
push branch: standalone
328
parent branch: standalone
325
publish to branch: %s
331
328
control: All-in-one format 6
349
347
first revision: %s
350
348
latest revision: %s
354
""" % (datestring_first, datestring_first,
353
""" % (branch2.bzrdir.root_transport.base,
354
branch1.bzrdir.root_transport.base,
355
branch1.bzrdir.root_transport.base,
356
datestring_first, datestring_first,
356
358
self.assertEqual('', err)
385
387
0 versioned subdirectories
390
393
first revision: %s
391
394
latest revision: %s
395
""" % (branch3.repository._format.get_format_description(),
399
""" % (branch3.bzrdir.root_transport.base,
400
branch1.bzrdir.root_transport.base,
401
branch1.bzrdir.root_transport.base,
402
branch3.repository._format.get_format_description(),
396
403
datestring_first, datestring_first,
404
# poking at _revision_store isn't all that clean, but neither is
405
# having the ui test dependent on the exact overhead of a given store.
406
branch3.repository._revision_store.total_size(
407
branch3.repository.get_transaction())[1] / 1024,
398
409
self.assertEqual('', err)
429
441
first revision: %s
430
442
latest revision: %s
434
""" % (branch4.repository._format.get_format_description(),
447
""" % (branch4.bzrdir.root_transport.base,
448
branch1.bzrdir.root_transport.base,
449
branch4.repository._format.get_format_description(),
435
450
datestring_first, datestring_first,
451
# poking at _revision_store isn't all that clean, but neither is
452
# having the ui test dependent on the exact overhead of a given store.
453
branch4.repository._revision_store.total_size(
454
branch4.repository.get_transaction())[1] / 1024,
437
456
self.assertEqual('', err)
439
458
# Out of date lightweight checkout
440
459
out, err = self.run_bzr('info lightcheckout --verbose')
441
460
self.assertEqualDiff(
442
"""Lightweight checkout (format: %s)
461
"""Lightweight checkout (format: dirstate or dirstate-tags)
444
light checkout root: lightcheckout
445
checkout of branch: standalone
463
light checkout root: %s
464
checkout of branch: %s
448
467
control: Meta directory format 1
449
working tree: Working tree format 6
468
working tree: Working tree format 4
450
469
branch: Branch format 4
451
470
repository: Weave repository format 6
468
488
first revision: %s
469
489
latest revision: %s
473
""" % (self._repo_strings, datestring_first, datestring_last,), out)
494
""" % (tree5.bzrdir.root_transport.base,
495
branch1.bzrdir.root_transport.base,
496
datestring_first, datestring_last,
474
498
self.assertEqual('', err)
476
500
def test_info_standalone_no_tree(self):
480
504
repo = branch.repository
481
505
out, err = self.run_bzr('info branch -v')
482
506
self.assertEqualDiff(
483
"""Standalone branch (format: %s)
507
"""Standalone branch (format: dirstate or knit)
488
512
control: Meta directory format 1
497
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
523
""" % (branch.bzrdir.root_transport.base,
498
524
format.get_branch_format().get_format_description(),
499
525
format.repository_format.get_format_description(),
522
""" % ('repo', format.repository_format.get_format_description(),
549
""" % (repo.bzrdir.root_transport.base,
550
format.repository_format.get_format_description(),
524
552
self.assertEqual('', err)
547
""" % (format.get_branch_format().get_format_description(),
577
""" % (repo.bzrdir.root_transport.base,
578
format.get_branch_format().get_format_description(),
548
579
format.repository_format.get_format_description(),
550
581
self.assertEqual('', err)
552
583
# Create lightweight checkout
553
584
transport.mkdir('tree')
554
585
transport.mkdir('tree/lightcheckout')
555
tree2 = branch1.create_checkout('tree/lightcheckout',
586
tree2 = branch1.create_checkout('tree/lightcheckout',
556
587
lightweight=True)
557
588
branch2 = tree2.branch
558
589
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
569
600
tree2.commit('commit one')
570
601
rev = repo.get_revision(branch2.revision_history()[0])
571
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
602
datestring_first = format_date(rev.timestamp, rev.timezone)
572
603
out, err = self.run_bzr('info tree/lightcheckout --verbose')
573
604
self.assertEqualDiff(
574
"""Lightweight checkout (format: %s)
605
"""Lightweight checkout (format: dirstate or dirstate-tags)
576
light checkout root: tree/lightcheckout
577
checkout of branch: repo/branch
578
shared repository: repo
607
light checkout root: %s
608
checkout of branch: %s
609
shared repository: %s
581
612
control: Meta directory format 1
582
working tree: Working tree format 6
613
working tree: Working tree format 4
599
631
first revision: %s
600
632
latest revision: %s
604
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
637
""" % (tree2.bzrdir.root_transport.base,
638
tree2.branch.bzrdir.root_transport.base,
639
repo.bzrdir.root_transport.base,
640
format.get_branch_format().get_format_description(),
605
641
format.repository_format.get_format_description(),
606
642
datestring_first, datestring_first,
643
# poking at _revision_store isn't all that clean, but neither is
644
# having the ui test dependent on the exact overhead of a given store.
645
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
608
647
self.assertEqual('', err)
610
649
# Out of date checkout
611
650
out, err = self.run_bzr('info -v tree/checkout')
612
651
self.assertEqualDiff(
613
"""Checkout (format: unnamed)
652
"""Checkout (format: dirstate)
615
checkout root: tree/checkout
616
checkout of branch: repo/branch
655
checkout of branch: %s
619
658
control: Meta directory format 1
620
working tree: Working tree format 6
659
working tree: Working tree format 4
641
""" % (format.get_branch_format().get_format_description(),
682
""" % (tree3.bzrdir.root_transport.base,
683
branch1.bzrdir.root_transport.base,
684
format.get_branch_format().get_format_description(),
642
685
format.repository_format.get_format_description(),
644
687
self.assertEqual('', err)
650
693
out, err = self.run_bzr('info tree/checkout --verbose')
651
694
self.assertEqualDiff(
652
"""Checkout (format: unnamed)
695
"""Checkout (format: dirstate)
654
checkout root: tree/checkout
655
checkout of branch: repo/branch
698
checkout of branch: %s
658
701
control: Meta directory format 1
659
working tree: Working tree format 6
702
working tree: Working tree format 4
676
720
first revision: %s
677
721
latest revision: %s
681
""" % (format.get_branch_format().get_format_description(),
726
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
727
format.get_branch_format().get_format_description(),
682
728
format.repository_format.get_format_description(),
683
729
datestring_first, datestring_first,
730
# poking at _revision_store isn't all that clean, but neither is
731
# having the ui test dependent on the exact overhead of a given store.
732
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
685
734
self.assertEqual('', err)
686
735
tree3.commit('commit two')
688
737
# Out of date lightweight checkout
689
738
rev = repo.get_revision(branch1.revision_history()[-1])
690
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
739
datestring_last = format_date(rev.timestamp, rev.timezone)
691
740
out, err = self.run_bzr('info tree/lightcheckout --verbose')
692
741
self.assertEqualDiff(
693
"""Lightweight checkout (format: %s)
742
"""Lightweight checkout (format: dirstate or dirstate-tags)
695
light checkout root: tree/lightcheckout
696
checkout of branch: repo/branch
697
shared repository: repo
744
light checkout root: %s
745
checkout of branch: %s
746
shared repository: %s
700
749
control: Meta directory format 1
701
working tree: Working tree format 6
750
working tree: Working tree format 4
720
770
first revision: %s
721
771
latest revision: %s
725
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
776
""" % (tree2.bzrdir.root_transport.base,
777
tree2.branch.bzrdir.root_transport.base,
778
repo.bzrdir.root_transport.base,
779
format.get_branch_format().get_format_description(),
726
780
format.repository_format.get_format_description(),
727
781
datestring_first, datestring_last,
782
# poking at _revision_store isn't all that clean, but neither is
783
# having the ui test dependent on the exact overhead of a given store.
784
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
729
786
self.assertEqual('', err)
747
805
first revision: %s
748
806
latest revision: %s
752
""" % (format.get_branch_format().get_format_description(),
811
""" % (repo.bzrdir.root_transport.base,
812
format.get_branch_format().get_format_description(),
753
813
format.repository_format.get_format_description(),
754
814
datestring_first, datestring_last,
815
# poking at _revision_store isn't all that clean, but neither is
816
# having the ui test dependent on the exact overhead of a given store.
817
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
756
819
self.assertEqual('', err)
771
""" % (format.repository_format.get_format_description(),
835
""" % (repo.bzrdir.root_transport.base,
836
format.repository_format.get_format_description(),
837
# poking at _revision_store isn't all that clean, but neither is
838
# having the ui test dependent on the exact overhead of a given store.
839
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
773
841
self.assertEqual('', err)
796
""" % (format.repository_format.get_format_description(),
865
""" % (repo.bzrdir.root_transport.base,
866
format.repository_format.get_format_description(),
798
868
self.assertEqual('', err)
835
""" % (format.get_branch_format().get_format_description(),
907
""" % (repo.bzrdir.root_transport.base,
908
format.get_branch_format().get_format_description(),
836
909
format.repository_format.get_format_description(),
838
911
self.assertEqual('', err)
844
917
tree1.commit('commit one')
845
918
rev = repo.get_revision(branch1.revision_history()[0])
846
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
919
datestring_first = format_date(rev.timestamp, rev.timezone)
847
920
out, err = self.run_bzr('info -v repo/branch1')
848
921
self.assertEqualDiff(
849
922
"""Repository tree (format: knit)
851
shared repository: repo
852
repository branch: repo/branch1
924
shared repository: %s
925
repository branch: branch1
855
928
control: Meta directory format 1
873
947
first revision: %s
874
948
latest revision: %s
878
""" % (format.get_branch_format().get_format_description(),
953
""" % (repo.bzrdir.root_transport.base,
954
format.get_branch_format().get_format_description(),
879
955
format.repository_format.get_format_description(),
880
956
datestring_first, datestring_first,
957
# poking at _revision_store isn't all that clean, but neither is
958
# having the ui test dependent on the exact overhead of a given store.
959
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
882
961
self.assertEqual('', err)
886
965
self.assertEqualDiff(
887
966
"""Repository tree (format: knit)
889
shared repository: repo
890
repository branch: repo/branch2
968
shared repository: %s
969
repository branch: branch2
892
971
Related branches:
893
parent branch: repo/branch1
896
975
control: Meta directory format 1
916
""" % (format.get_branch_format().get_format_description(),
997
""" % (repo.bzrdir.root_transport.base,
998
branch1.bzrdir.root_transport.base,
999
format.get_branch_format().get_format_description(),
917
1000
format.repository_format.get_format_description(),
1001
# poking at _revision_store isn't all that clean, but neither is
1002
# having the ui test dependent on the exact overhead of a given store.
1003
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
919
1005
self.assertEqual('', err)
925
1011
self.assertEqualDiff(
926
1012
"""Repository tree (format: knit)
928
shared repository: repo
929
repository branch: repo/branch2
1014
shared repository: %s
1015
repository branch: branch2
931
1017
Related branches:
932
parent branch: repo/branch1
935
1021
control: Meta directory format 1
953
1040
first revision: %s
954
1041
latest revision: %s
958
""" % (format.get_branch_format().get_format_description(),
1046
""" % (repo.bzrdir.root_transport.base,
1047
branch1.bzrdir.root_transport.base,
1048
format.get_branch_format().get_format_description(),
959
1049
format.repository_format.get_format_description(),
960
1050
datestring_first, datestring_first,
1051
# poking at _revision_store isn't all that clean, but neither is
1052
# having the ui test dependent on the exact overhead of a given store.
1053
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
962
1055
self.assertEqual('', err)
979
""" % (format.repository_format.get_format_description(),
1073
""" % (repo.bzrdir.root_transport.base,
1074
format.repository_format.get_format_description(),
1075
# poking at _revision_store isn't all that clean, but neither is
1076
# having the ui test dependent on the exact overhead of a given store.
1077
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
982
1080
self.assertEqual('', err)
984
1082
def test_info_shared_repository_with_tree_in_root(self):
985
1083
format = bzrdir.format_registry.make_bzrdir('knit')
986
1084
transport = self.get_transport()
1005
""" % (format.repository_format.get_format_description(),
1104
""" % (repo.bzrdir.root_transport.base,
1105
format.repository_format.get_format_description(),
1007
1107
self.assertEqual('', err)
1036
1136
Branch history:
1041
""" % (format.get_branch_format().get_format_description(),
1143
""" % (repo.bzrdir.root_transport.base,
1144
format.get_branch_format().get_format_description(),
1042
1145
format.repository_format.get_format_description(),
1044
1147
self.assertEqual('', err)
1046
def test_info_repository_hook(self):
1047
format = bzrdir.format_registry.make_bzrdir('knit')
1048
def repo_info(repo, stats, outf):
1049
outf.write("more info\n")
1050
info.hooks.install_named_hook('repository', repo_info, None)
1051
# Create shared repository with working trees
1052
repo = self.make_repository('repo', shared=True, format=format)
1053
out, err = self.run_bzr('info -v repo')
1054
self.assertEqualDiff(
1055
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1057
shared repository: repo
1060
control: Meta directory format 1
1063
Create working tree for new branches inside the repository.
1068
""" % (format.repository_format.get_format_description(),
1070
self.assertEqual('', err)
1072
def assertCheckoutStatusOutput(self,
1149
def assertCheckoutStatusOutput(self,
1073
1150
command_string, lco_tree, shared_repo=None,
1074
1151
repo_branch=None,
1075
1152
tree_locked=False,
1084
1161
allow us, the test writers, to document what *should* be present in
1085
1162
the output. Removing this separation would remove the value of the
1088
1165
:param path: the path to the light checkout.
1089
1166
:param lco_tree: the tree object for the light checkout.
1090
1167
:param shared_repo: A shared repository is in use, expect that in
1094
1171
:param tree_locked: If true, expect the tree to be locked.
1095
1172
:param branch_locked: If true, expect the branch to be locked.
1096
1173
:param repo_locked: If true, expect the repository to be locked.
1097
Note that the lco_tree.branch.repository is inspected, and if is not
1098
actually locked then this parameter is overridden. This is because
1099
pack repositories do not have any public API for obtaining an
1100
exclusive repository wide lock.
1101
:param verbose: verbosity level: 2 or higher to show committers
1174
:param verbose: If true, expect verbose output
1103
def friendly_location(url):
1104
path = urlutils.unescape_for_display(url, 'ascii')
1106
return osutils.relpath(osutils.getcwd(), path)
1107
except errors.PathNotChild:
1111
# We expect this to fail because of locking errors.
1112
# (A write-locked file cannot be read-locked
1113
# in the different process -- either on win32 or on linux).
1176
if tree_locked and sys.platform == 'win32':
1177
# We expect this to fail because of locking errors. (A write-locked
1178
# file cannot be read-locked in the same process).
1114
1179
# This should be removed when the locking errors are fixed.
1115
self.expectFailure('OS locks are exclusive '
1116
'for different processes (Bug #174055)',
1117
self.run_bzr_subprocess,
1118
'info ' + command_string)
1180
args = command_string.split(' ')
1181
self.run_bzr_error([], 'info', *args)
1119
1183
out, err = self.run_bzr('info %s' % command_string)
1120
1184
description = {
1121
1185
(True, True): 'Lightweight checkout',
1123
1187
(False, True): 'Lightweight checkout',
1124
1188
(False, False): 'Checkout',
1125
1189
}[(shared_repo is not None, light_checkout)]
1126
format = {True: self._repo_strings,
1127
False: 'unnamed'}[light_checkout]
1129
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1190
format = {True: 'dirstate or dirstate-tags',
1191
False: 'dirstate'}[light_checkout]
1130
1192
if repo_locked or branch_locked or tree_locked:
1131
1193
def locked_message(a_bool):
1148
1210
extra_space = ''
1149
1211
if light_checkout:
1150
1212
tree_data = (" light checkout root: %s\n" %
1151
friendly_location(lco_tree.bzrdir.root_transport.base))
1213
lco_tree.bzrdir.root_transport.base)
1152
1214
extra_space = ' '
1153
1215
if lco_tree.branch.get_bound_location() is not None:
1154
1216
tree_data += ("%s checkout root: %s\n" % (extra_space,
1155
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1217
lco_tree.branch.bzrdir.root_transport.base))
1156
1218
if shared_repo is not None:
1157
1219
branch_data = (
1158
1220
" checkout of branch: %s\n"
1159
1221
" shared repository: %s\n" %
1160
(friendly_location(repo_branch.bzrdir.root_transport.base),
1161
friendly_location(shared_repo.bzrdir.root_transport.base)))
1222
(repo_branch.bzrdir.root_transport.base,
1223
shared_repo.bzrdir.root_transport.base))
1162
1224
elif repo_branch is not None:
1163
1225
branch_data = (
1164
1226
"%s checkout of branch: %s\n" %
1166
friendly_location(repo_branch.bzrdir.root_transport.base)))
1228
repo_branch.bzrdir.root_transport.base))
1168
1230
branch_data = (" checkout of branch: %s\n" %
1169
1231
lco_tree.branch.bzrdir.root_transport.base)
1172
1234
verbose_info = ' 0 committers\n'
1174
1236
verbose_info = ''
1176
1238
self.assertEqualDiff(
1177
1239
"""%s (format: %s)
1214
1277
transport = self.get_transport()
1215
1278
# Create shared repository with a branch
1216
1279
repo = self.make_repository('repo', shared=True,
1217
format=bzrdir.BzrDirMetaFormat1())
1280
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1218
1281
repo.set_make_working_trees(False)
1219
1282
repo.bzrdir.root_transport.mkdir('branch')
1220
1283
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1221
format=bzrdir.BzrDirMetaFormat1())
1284
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1222
1285
# Do a heavy checkout
1223
1286
transport.mkdir('tree')
1224
1287
transport.mkdir('tree/checkout')
1225
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
format=bzrdir.BzrDirMetaFormat1())
1288
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1289
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1227
1290
co_branch.bind(repo_branch)
1228
1291
# Do a light checkout of the heavy one
1229
1292
transport.mkdir('tree/lightcheckout')
1230
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1231
branch.BranchReferenceFormat().initialize(lco_dir,
1232
target_branch=co_branch)
1293
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1294
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1233
1295
lco_dir.create_workingtree()
1234
1296
lco_tree = lco_dir.open_workingtree()
1326
1388
def test_info_locking_oslocks(self):
1327
1389
if sys.platform == "win32":
1328
self.skip("don't use oslocks on win32 in unix manner")
1329
# This test tests old (all-in-one, OS lock using) behaviour which
1330
# simply cannot work on windows (and is indeed why we changed our
1331
# design. As such, don't try to remove the thisFailsStrictLockCheck
1333
self.thisFailsStrictLockCheck()
1390
raise TestSkipped("don't use oslocks on win32 in unix manner")
1335
1392
tree = self.make_branch_and_tree('branch',
1336
format=bzrdir.BzrDirFormat6())
1393
format=bzrlib.bzrdir.BzrDirFormat6())
1338
1395
# Test all permutations of locking the working tree, branch and repository
1339
1396
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1367
1424
Branch history:
1372
""" % ('branch', tree.branch.repository._format.get_format_description(),
1431
""" % (tree.bzrdir.root_transport.base,
1432
tree.branch.repository._format.get_format_description(),
1374
1434
self.assertEqual('', err)
1399
1459
Branch history:
1404
""" % ('branch', tree.branch.repository._format.get_format_description(),
1466
""" % (tree.bzrdir.root_transport.base,
1467
tree.branch.repository._format.get_format_description(),
1406
1469
self.assertEqual('', err)
1409
def test_info_stacked(self):
1410
# We have a mainline
1411
trunk_tree = self.make_branch_and_tree('mainline',
1413
trunk_tree.commit('mainline')
1414
# and a branch from it which is stacked
1415
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1416
out, err = self.run_bzr('info newbranch')
1418
"""Standalone tree (format: 1.6)
1420
branch root: newbranch
1423
parent branch: mainline
1424
stacked on: mainline
1426
self.assertEqual("", err)