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()
53
48
self.build_tree(['standalone/a'])
55
50
branch1 = tree1.branch
57
out, err = self.run_bzr('info standalone')
59
"""Standalone tree (format: weave)
61
branch root: standalone
63
self.assertEqual('', err)
65
# Standalone branch - verbose mode
66
51
out, err = self.run_bzr('info standalone -v')
67
52
self.assertEqualDiff(
68
53
"""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
58
control: All-in-one format 6
80
""" % branch1.bzrdir.root_transport.base, out)
126
81
self.assertEqual('', err)
127
82
tree1.commit('commit one')
128
83
rev = branch1.repository.get_revision(branch1.revision_history()[0])
129
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
84
datestring_first = format_date(rev.timestamp, rev.timezone)
131
86
# Branch standalone with push location
132
87
branch2 = branch1.bzrdir.sprout('branch').open_branch()
133
88
branch2.set_push_location(branch1.bzrdir.root_transport.base)
135
out, err = self.run_bzr('info branch')
136
self.assertEqualDiff(
137
"""Standalone tree (format: weave)
142
push branch: standalone
143
parent branch: standalone
145
self.assertEqual('', err)
147
89
out, err = self.run_bzr('info branch --verbose')
148
90
self.assertEqualDiff(
149
91
"""Standalone tree (format: weave)
154
push branch: standalone
155
parent branch: standalone
158
100
control: All-in-one format 6
176
119
first revision: %s
177
120
latest revision: %s
181
""" % (datestring_first, datestring_first,
125
""" % (branch2.bzrdir.root_transport.base,
126
branch1.bzrdir.root_transport.base,
127
branch1.bzrdir.root_transport.base,
128
datestring_first, datestring_first,
129
# poking at _revision_store isn't all that clean, but neither is
130
# having the ui test dependent on the exact overhead of a given store.
131
branch2.repository._revision_store.total_size(
132
branch2.repository.get_transaction())[1] / 1024,
183
134
self.assertEqual('', err)
186
137
# (creates backup as unknown)
187
138
branch1.bzrdir.sprout('bound')
188
139
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
189
upgrade.upgrade('bound', knit1_format)
190
branch3 = bzrdir.BzrDir.open('bound').open_branch()
140
bzrlib.upgrade.upgrade('bound', knit1_format)
141
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
191
142
branch3.bind(branch1)
192
143
bound_tree = branch3.bzrdir.open_workingtree()
193
144
out, err = self.run_bzr('info -v bound')
194
145
self.assertEqualDiff(
195
146
"""Checkout (format: knit)
198
checkout of branch: standalone
149
checkout of branch: %s
200
151
Related branches:
201
parent branch: standalone
204
155
control: Meta directory format 1
217
168
0 versioned subdirectories
222
174
first revision: %s
223
175
latest revision: %s
227
""" % (bound_tree._format.get_format_description(),
180
""" % (branch3.bzrdir.root_transport.base,
181
branch1.bzrdir.root_transport.base,
182
branch1.bzrdir.root_transport.base,
183
bound_tree._format.get_format_description(),
228
184
branch3._format.get_format_description(),
229
185
branch3.repository._format.get_format_description(),
230
186
datestring_first, datestring_first,
187
# poking at _revision_store isn't all that clean, but neither is
188
# having the ui test dependent on the exact overhead of a given store.
189
branch3.repository._revision_store.total_size(
190
branch3.repository.get_transaction())[1] / 1024,
232
192
self.assertEqual('', err)
234
194
# Checkout standalone (same as above, but does not have parent set)
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
195
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
236
196
format=knit1_format)
237
197
branch4.bind(branch1)
238
198
branch4.bzrdir.open_workingtree().update()
265
226
first revision: %s
266
227
latest revision: %s
270
""" % (branch4.repository._format.get_format_description(),
232
""" % (branch4.bzrdir.root_transport.base,
233
branch1.bzrdir.root_transport.base,
234
branch4.repository._format.get_format_description(),
271
235
datestring_first, datestring_first,
236
# poking at _revision_store isn't all that clean, but neither is
237
# having the ui test dependent on the exact overhead of a given store.
238
branch4.repository._revision_store.total_size(
239
branch4.repository.get_transaction())[1] / 1024,
273
241
self.assertEqual('', err)
277
245
branch5 = tree5.branch
278
246
out, err = self.run_bzr('info -v lightcheckout')
279
247
self.assertEqualDiff(
280
"""Lightweight checkout (format: %s)
248
"""Lightweight checkout (format: dirstate or dirstate-tags)
282
light checkout root: lightcheckout
283
checkout of branch: standalone
250
light checkout root: %s
251
checkout of branch: %s
286
254
control: Meta directory format 1
287
working tree: Working tree format 6
255
working tree: Working tree format 4
288
256
branch: Branch format 4
289
257
repository: Weave repository format 6
304
273
first revision: %s
305
274
latest revision: %s
309
""" % (self._repo_strings, datestring_first, datestring_first,), out)
279
""" % (tree5.bzrdir.root_transport.base,
280
branch1.bzrdir.root_transport.base,
281
datestring_first, datestring_first,
310
283
self.assertEqual('', err)
312
285
# Update initial standalone branch
315
288
tree1.commit('commit two')
316
289
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
317
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
290
datestring_last = format_date(rev.timestamp, rev.timezone)
319
292
# Out of date branched standalone branch will not be detected
320
293
out, err = self.run_bzr('info -v branch')
321
294
self.assertEqualDiff(
322
295
"""Standalone tree (format: weave)
326
299
Related branches:
327
push branch: standalone
328
parent branch: standalone
301
publish to branch: %s
331
304
control: All-in-one format 6
349
323
first revision: %s
350
324
latest revision: %s
354
""" % (datestring_first, datestring_first,
329
""" % (branch2.bzrdir.root_transport.base,
330
branch1.bzrdir.root_transport.base,
331
branch1.bzrdir.root_transport.base,
332
datestring_first, datestring_first,
356
334
self.assertEqual('', err)
385
363
0 versioned subdirectories
390
369
first revision: %s
391
370
latest revision: %s
395
""" % (branch3.repository._format.get_format_description(),
375
""" % (branch3.bzrdir.root_transport.base,
376
branch1.bzrdir.root_transport.base,
377
branch1.bzrdir.root_transport.base,
378
branch3.repository._format.get_format_description(),
396
379
datestring_first, datestring_first,
380
# poking at _revision_store isn't all that clean, but neither is
381
# having the ui test dependent on the exact overhead of a given store.
382
branch3.repository._revision_store.total_size(
383
branch3.repository.get_transaction())[1] / 1024,
398
385
self.assertEqual('', err)
429
417
first revision: %s
430
418
latest revision: %s
434
""" % (branch4.repository._format.get_format_description(),
423
""" % (branch4.bzrdir.root_transport.base,
424
branch1.bzrdir.root_transport.base,
425
branch4.repository._format.get_format_description(),
435
426
datestring_first, datestring_first,
427
# poking at _revision_store isn't all that clean, but neither is
428
# having the ui test dependent on the exact overhead of a given store.
429
branch4.repository._revision_store.total_size(
430
branch4.repository.get_transaction())[1] / 1024,
437
432
self.assertEqual('', err)
439
434
# Out of date lightweight checkout
440
435
out, err = self.run_bzr('info lightcheckout --verbose')
441
436
self.assertEqualDiff(
442
"""Lightweight checkout (format: %s)
437
"""Lightweight checkout (format: dirstate or dirstate-tags)
444
light checkout root: lightcheckout
445
checkout of branch: standalone
439
light checkout root: %s
440
checkout of branch: %s
448
443
control: Meta directory format 1
449
working tree: Working tree format 6
444
working tree: Working tree format 4
450
445
branch: Branch format 4
451
446
repository: Weave repository format 6
468
464
first revision: %s
469
465
latest revision: %s
473
""" % (self._repo_strings, datestring_first, datestring_last,), out)
470
""" % (tree5.bzrdir.root_transport.base,
471
branch1.bzrdir.root_transport.base,
472
datestring_first, datestring_last,
474
474
self.assertEqual('', err)
476
476
def test_info_standalone_no_tree(self):
480
480
repo = branch.repository
481
481
out, err = self.run_bzr('info branch -v')
482
482
self.assertEqualDiff(
483
"""Standalone branch (format: %s)
483
"""Standalone branch (format: dirstate or knit)
488
488
control: Meta directory format 1
497
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
499
""" % (branch.bzrdir.root_transport.base,
498
500
format.get_branch_format().get_format_description(),
499
501
format.repository_format.get_format_description(),
522
""" % ('repo', format.repository_format.get_format_description(),
525
""" % (repo.bzrdir.root_transport.base,
526
format.repository_format.get_format_description(),
524
528
self.assertEqual('', err)
547
""" % (format.get_branch_format().get_format_description(),
553
""" % (repo.bzrdir.root_transport.base,
554
format.get_branch_format().get_format_description(),
548
555
format.repository_format.get_format_description(),
550
557
self.assertEqual('', err)
552
559
# Create lightweight checkout
553
560
transport.mkdir('tree')
554
561
transport.mkdir('tree/lightcheckout')
555
tree2 = branch1.create_checkout('tree/lightcheckout',
562
tree2 = branch1.create_checkout('tree/lightcheckout',
556
563
lightweight=True)
557
564
branch2 = tree2.branch
558
565
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
569
576
tree2.commit('commit one')
570
577
rev = repo.get_revision(branch2.revision_history()[0])
571
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
578
datestring_first = format_date(rev.timestamp, rev.timezone)
572
579
out, err = self.run_bzr('info tree/lightcheckout --verbose')
573
580
self.assertEqualDiff(
574
"""Lightweight checkout (format: %s)
581
"""Lightweight checkout (format: dirstate or dirstate-tags)
576
light checkout root: tree/lightcheckout
577
checkout of branch: repo/branch
578
shared repository: repo
583
light checkout root: %s
584
checkout of branch: %s
585
shared repository: %s
581
588
control: Meta directory format 1
582
working tree: Working tree format 6
589
working tree: Working tree format 4
599
607
first revision: %s
600
608
latest revision: %s
604
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
613
""" % (tree2.bzrdir.root_transport.base,
614
tree2.branch.bzrdir.root_transport.base,
615
repo.bzrdir.root_transport.base,
616
format.get_branch_format().get_format_description(),
605
617
format.repository_format.get_format_description(),
606
618
datestring_first, datestring_first,
619
# poking at _revision_store isn't all that clean, but neither is
620
# having the ui test dependent on the exact overhead of a given store.
621
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
608
623
self.assertEqual('', err)
610
625
# Out of date checkout
611
626
out, err = self.run_bzr('info -v tree/checkout')
612
627
self.assertEqualDiff(
613
"""Checkout (format: unnamed)
628
"""Checkout (format: dirstate)
615
checkout root: tree/checkout
616
checkout of branch: repo/branch
631
checkout of branch: %s
619
634
control: Meta directory format 1
620
working tree: Working tree format 6
635
working tree: Working tree format 4
641
""" % (format.get_branch_format().get_format_description(),
658
""" % (tree3.bzrdir.root_transport.base,
659
branch1.bzrdir.root_transport.base,
660
format.get_branch_format().get_format_description(),
642
661
format.repository_format.get_format_description(),
644
663
self.assertEqual('', err)
650
669
out, err = self.run_bzr('info tree/checkout --verbose')
651
670
self.assertEqualDiff(
652
"""Checkout (format: unnamed)
671
"""Checkout (format: dirstate)
654
checkout root: tree/checkout
655
checkout of branch: repo/branch
674
checkout of branch: %s
658
677
control: Meta directory format 1
659
working tree: Working tree format 6
678
working tree: Working tree format 4
676
696
first revision: %s
677
697
latest revision: %s
681
""" % (format.get_branch_format().get_format_description(),
702
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
703
format.get_branch_format().get_format_description(),
682
704
format.repository_format.get_format_description(),
683
705
datestring_first, datestring_first,
706
# poking at _revision_store isn't all that clean, but neither is
707
# having the ui test dependent on the exact overhead of a given store.
708
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
685
710
self.assertEqual('', err)
686
711
tree3.commit('commit two')
688
713
# Out of date lightweight checkout
689
714
rev = repo.get_revision(branch1.revision_history()[-1])
690
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
715
datestring_last = format_date(rev.timestamp, rev.timezone)
691
716
out, err = self.run_bzr('info tree/lightcheckout --verbose')
692
717
self.assertEqualDiff(
693
"""Lightweight checkout (format: %s)
718
"""Lightweight checkout (format: dirstate or dirstate-tags)
695
light checkout root: tree/lightcheckout
696
checkout of branch: repo/branch
697
shared repository: repo
720
light checkout root: %s
721
checkout of branch: %s
722
shared repository: %s
700
725
control: Meta directory format 1
701
working tree: Working tree format 6
726
working tree: Working tree format 4
720
746
first revision: %s
721
747
latest revision: %s
725
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
752
""" % (tree2.bzrdir.root_transport.base,
753
tree2.branch.bzrdir.root_transport.base,
754
repo.bzrdir.root_transport.base,
755
format.get_branch_format().get_format_description(),
726
756
format.repository_format.get_format_description(),
727
757
datestring_first, datestring_last,
758
# poking at _revision_store isn't all that clean, but neither is
759
# having the ui test dependent on the exact overhead of a given store.
760
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
729
762
self.assertEqual('', err)
747
781
first revision: %s
748
782
latest revision: %s
752
""" % (format.get_branch_format().get_format_description(),
787
""" % (repo.bzrdir.root_transport.base,
788
format.get_branch_format().get_format_description(),
753
789
format.repository_format.get_format_description(),
754
790
datestring_first, datestring_last,
791
# poking at _revision_store isn't all that clean, but neither is
792
# having the ui test dependent on the exact overhead of a given store.
793
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
756
795
self.assertEqual('', err)
771
""" % (format.repository_format.get_format_description(),
811
""" % (repo.bzrdir.root_transport.base,
812
format.repository_format.get_format_description(),
813
# poking at _revision_store isn't all that clean, but neither is
814
# having the ui test dependent on the exact overhead of a given store.
815
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
773
817
self.assertEqual('', err)
796
""" % (format.repository_format.get_format_description(),
841
""" % (repo.bzrdir.root_transport.base,
842
format.repository_format.get_format_description(),
798
844
self.assertEqual('', err)
835
""" % (format.get_branch_format().get_format_description(),
883
""" % (repo.bzrdir.root_transport.base,
884
format.get_branch_format().get_format_description(),
836
885
format.repository_format.get_format_description(),
838
887
self.assertEqual('', err)
844
893
tree1.commit('commit one')
845
894
rev = repo.get_revision(branch1.revision_history()[0])
846
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
895
datestring_first = format_date(rev.timestamp, rev.timezone)
847
896
out, err = self.run_bzr('info -v repo/branch1')
848
897
self.assertEqualDiff(
849
898
"""Repository tree (format: knit)
851
shared repository: repo
852
repository branch: repo/branch1
900
shared repository: %s
901
repository branch: branch1
855
904
control: Meta directory format 1
873
923
first revision: %s
874
924
latest revision: %s
878
""" % (format.get_branch_format().get_format_description(),
929
""" % (repo.bzrdir.root_transport.base,
930
format.get_branch_format().get_format_description(),
879
931
format.repository_format.get_format_description(),
880
932
datestring_first, datestring_first,
933
# poking at _revision_store isn't all that clean, but neither is
934
# having the ui test dependent on the exact overhead of a given store.
935
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
882
937
self.assertEqual('', err)
886
941
self.assertEqualDiff(
887
942
"""Repository tree (format: knit)
889
shared repository: repo
890
repository branch: repo/branch2
944
shared repository: %s
945
repository branch: branch2
892
947
Related branches:
893
parent branch: repo/branch1
896
951
control: Meta directory format 1
916
""" % (format.get_branch_format().get_format_description(),
973
""" % (repo.bzrdir.root_transport.base,
974
branch1.bzrdir.root_transport.base,
975
format.get_branch_format().get_format_description(),
917
976
format.repository_format.get_format_description(),
977
# poking at _revision_store isn't all that clean, but neither is
978
# having the ui test dependent on the exact overhead of a given store.
979
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
919
981
self.assertEqual('', err)
925
987
self.assertEqualDiff(
926
988
"""Repository tree (format: knit)
928
shared repository: repo
929
repository branch: repo/branch2
990
shared repository: %s
991
repository branch: branch2
931
993
Related branches:
932
parent branch: repo/branch1
935
997
control: Meta directory format 1
953
1016
first revision: %s
954
1017
latest revision: %s
958
""" % (format.get_branch_format().get_format_description(),
1022
""" % (repo.bzrdir.root_transport.base,
1023
branch1.bzrdir.root_transport.base,
1024
format.get_branch_format().get_format_description(),
959
1025
format.repository_format.get_format_description(),
960
1026
datestring_first, datestring_first,
1027
# poking at _revision_store isn't all that clean, but neither is
1028
# having the ui test dependent on the exact overhead of a given store.
1029
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
962
1031
self.assertEqual('', err)
979
""" % (format.repository_format.get_format_description(),
1049
""" % (repo.bzrdir.root_transport.base,
1050
format.repository_format.get_format_description(),
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,
982
1056
self.assertEqual('', err)
984
1058
def test_info_shared_repository_with_tree_in_root(self):
985
1059
format = bzrdir.format_registry.make_bzrdir('knit')
986
1060
transport = self.get_transport()
1005
""" % (format.repository_format.get_format_description(),
1080
""" % (repo.bzrdir.root_transport.base,
1081
format.repository_format.get_format_description(),
1007
1083
self.assertEqual('', err)
1036
1112
Branch history:
1041
""" % (format.get_branch_format().get_format_description(),
1119
""" % (repo.bzrdir.root_transport.base,
1120
format.get_branch_format().get_format_description(),
1042
1121
format.repository_format.get_format_description(),
1044
1123
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,
1125
def assertCheckoutStatusOutput(self,
1073
1126
command_string, lco_tree, shared_repo=None,
1074
1127
repo_branch=None,
1075
1128
tree_locked=False,
1084
1137
allow us, the test writers, to document what *should* be present in
1085
1138
the output. Removing this separation would remove the value of the
1088
1141
:param path: the path to the light checkout.
1089
1142
:param lco_tree: the tree object for the light checkout.
1090
1143
:param shared_repo: A shared repository is in use, expect that in
1094
1147
:param tree_locked: If true, expect the tree to be locked.
1095
1148
:param branch_locked: If true, expect the branch to be locked.
1096
1149
: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
1150
: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).
1152
if tree_locked and sys.platform == 'win32':
1153
# We expect this to fail because of locking errors. (A write-locked
1154
# file cannot be read-locked in the same process).
1114
1155
# 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)
1156
args = command_string.split(' ')
1157
self.run_bzr_error([], 'info', *args)
1119
1159
out, err = self.run_bzr('info %s' % command_string)
1120
1160
description = {
1121
1161
(True, True): 'Lightweight checkout',
1123
1163
(False, True): 'Lightweight checkout',
1124
1164
(False, False): 'Checkout',
1125
1165
}[(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()
1166
format = {True: 'dirstate or dirstate-tags',
1167
False: 'dirstate'}[light_checkout]
1130
1168
if repo_locked or branch_locked or tree_locked:
1131
1169
def locked_message(a_bool):
1148
1186
extra_space = ''
1149
1187
if light_checkout:
1150
1188
tree_data = (" light checkout root: %s\n" %
1151
friendly_location(lco_tree.bzrdir.root_transport.base))
1189
lco_tree.bzrdir.root_transport.base)
1152
1190
extra_space = ' '
1153
1191
if lco_tree.branch.get_bound_location() is not None:
1154
1192
tree_data += ("%s checkout root: %s\n" % (extra_space,
1155
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1193
lco_tree.branch.bzrdir.root_transport.base))
1156
1194
if shared_repo is not None:
1157
1195
branch_data = (
1158
1196
" checkout of branch: %s\n"
1159
1197
" shared repository: %s\n" %
1160
(friendly_location(repo_branch.bzrdir.root_transport.base),
1161
friendly_location(shared_repo.bzrdir.root_transport.base)))
1198
(repo_branch.bzrdir.root_transport.base,
1199
shared_repo.bzrdir.root_transport.base))
1162
1200
elif repo_branch is not None:
1163
1201
branch_data = (
1164
1202
"%s checkout of branch: %s\n" %
1166
friendly_location(repo_branch.bzrdir.root_transport.base)))
1204
repo_branch.bzrdir.root_transport.base))
1168
1206
branch_data = (" checkout of branch: %s\n" %
1169
1207
lco_tree.branch.bzrdir.root_transport.base)
1172
1210
verbose_info = ' 0 committers\n'
1174
1212
verbose_info = ''
1176
1214
self.assertEqualDiff(
1177
1215
"""%s (format: %s)
1214
1253
transport = self.get_transport()
1215
1254
# Create shared repository with a branch
1216
1255
repo = self.make_repository('repo', shared=True,
1217
format=bzrdir.BzrDirMetaFormat1())
1256
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1218
1257
repo.set_make_working_trees(False)
1219
1258
repo.bzrdir.root_transport.mkdir('branch')
1220
1259
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1221
format=bzrdir.BzrDirMetaFormat1())
1260
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1222
1261
# Do a heavy checkout
1223
1262
transport.mkdir('tree')
1224
1263
transport.mkdir('tree/checkout')
1225
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
format=bzrdir.BzrDirMetaFormat1())
1264
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1265
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1227
1266
co_branch.bind(repo_branch)
1228
1267
# Do a light checkout of the heavy one
1229
1268
transport.mkdir('tree/lightcheckout')
1230
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1231
branch.BranchReferenceFormat().initialize(lco_dir,
1232
target_branch=co_branch)
1269
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1270
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1233
1271
lco_dir.create_workingtree()
1234
1272
lco_tree = lco_dir.open_workingtree()
1326
1364
def test_info_locking_oslocks(self):
1327
1365
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()
1366
raise TestSkipped("don't use oslocks on win32 in unix manner")
1335
1368
tree = self.make_branch_and_tree('branch',
1336
format=bzrdir.BzrDirFormat6())
1369
format=bzrlib.bzrdir.BzrDirFormat6())
1338
1371
# Test all permutations of locking the working tree, branch and repository
1339
1372
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1367
1400
Branch history:
1372
""" % ('branch', tree.branch.repository._format.get_format_description(),
1407
""" % (tree.bzrdir.root_transport.base,
1408
tree.branch.repository._format.get_format_description(),
1374
1410
self.assertEqual('', err)
1399
1435
Branch history:
1404
""" % ('branch', tree.branch.repository._format.get_format_description(),
1442
""" % (tree.bzrdir.root_transport.base,
1443
tree.branch.repository._format.get_format_description(),
1406
1445
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)