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"
24
from bzrlib.osutils import format_date
25
from bzrlib.tests import TestSkipped
26
from bzrlib.tests.blackbox import ExternalBase
29
class TestInfo(ExternalBase):
41
31
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)
32
if sys.platform == "win32":
33
location = "C:/i/do/not/exist/"
35
location = "/i/do/not/exist/"
36
out, err = self.runbzr('info '+location, retcode=3)
45
37
self.assertEqual(out, '')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
38
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
48
40
def test_info_standalone(self):
49
41
transport = self.get_transport()
51
43
# Create initial standalone branch
52
tree1 = self.make_branch_and_tree('standalone', 'weave')
44
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
45
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
46
tree1 = self.make_branch_and_tree('standalone')
47
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
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
out, err = self.run_bzr('info standalone -v')
68
"""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
control: All-in-one format 6
105
working tree: Working tree format 2
106
branch: Branch format 4
107
repository: Weave repository format 6
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: weave)
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: weave)
154
push branch: standalone
155
parent branch: standalone
87
out, err = self.runbzr('info branch --verbose')
158
97
control: All-in-one format 6
176
116
first revision: %s
177
117
latest revision: %s
181
""" % (datestring_first, datestring_first,
122
""" % (branch2.bzrdir.root_transport.base,
123
branch1.bzrdir.root_transport.base,
124
branch1.bzrdir.root_transport.base,
125
datestring_first, datestring_first,
126
# poking at _revision_store isn't all that clean, but neither is
127
# having the ui test dependent on the exact overhead of a given store.
128
branch2.repository._revision_store.total_size(
129
branch2.repository.get_transaction())[1] / 1024,
183
131
self.assertEqual('', err)
185
133
# Branch and bind to standalone, needs upgrade to metadir
186
134
# (creates backup as unknown)
187
135
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()
136
bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
137
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
191
138
branch3.bind(branch1)
192
bound_tree = branch3.bzrdir.open_workingtree()
193
out, err = self.run_bzr('info -v bound')
139
out, err = self.runbzr('info bound')
194
140
self.assertEqualDiff(
195
"""Checkout (format: knit)
198
checkout of branch: standalone
143
checkout of branch: %s
200
145
Related branches:
201
parent branch: standalone
204
149
control: Meta directory format 1
150
working tree: Working tree format 3
151
branch: Branch format 5
209
154
In the working tree:
222
167
first revision: %s
223
168
latest revision: %s
227
""" % (bound_tree._format.get_format_description(),
228
branch3._format.get_format_description(),
173
""" % (branch3.bzrdir.root_transport.base,
174
branch1.bzrdir.root_transport.base,
175
branch1.bzrdir.root_transport.base,
229
176
branch3.repository._format.get_format_description(),
230
177
datestring_first, datestring_first,
178
# poking at _revision_store isn't all that clean, but neither is
179
# having the ui test dependent on the exact overhead of a given store.
180
branch3.repository._revision_store.total_size(
181
branch3.repository.get_transaction())[1] / 1024,
232
183
self.assertEqual('', err)
234
185
# Checkout standalone (same as above, but does not have parent set)
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
186
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
187
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
188
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout')
189
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
237
190
branch4.bind(branch1)
238
191
branch4.bzrdir.open_workingtree().update()
239
out, err = self.run_bzr('info checkout --verbose')
192
out, err = self.runbzr('info checkout --verbose')
240
193
self.assertEqualDiff(
241
"""Checkout (format: knit)
243
checkout root: checkout
244
checkout of branch: standalone
196
checkout of branch: %s
247
199
control: Meta directory format 1
265
218
first revision: %s
266
219
latest revision: %s
270
""" % (branch4.repository._format.get_format_description(),
224
""" % (branch4.bzrdir.root_transport.base,
225
branch1.bzrdir.root_transport.base,
226
branch4.repository._format.get_format_description(),
271
227
datestring_first, datestring_first,
228
# poking at _revision_store isn't all that clean, but neither is
229
# having the ui test dependent on the exact overhead of a given store.
230
branch4.repository._revision_store.total_size(
231
branch4.repository.get_transaction())[1] / 1024,
273
233
self.assertEqual('', err)
275
235
# Lightweight checkout (same as above, different branch and repository)
276
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
236
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
237
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
238
transport.mkdir('lightcheckout')
239
dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
240
bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
241
dir5.create_workingtree()
242
tree5 = dir5.open_workingtree()
243
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
277
244
branch5 = tree5.branch
278
out, err = self.run_bzr('info -v lightcheckout')
245
out, err = self.runbzr('info lightcheckout')
279
246
self.assertEqualDiff(
280
"""Lightweight checkout (format: %s)
282
light checkout root: lightcheckout
283
checkout of branch: standalone
248
light checkout root: %s
249
checkout of branch: %s
286
252
control: Meta directory format 1
287
working tree: Working tree format 6
253
working tree: Working tree format 3
288
254
branch: Branch format 4
289
255
repository: Weave repository format 6
468
454
first revision: %s
469
455
latest revision: %s
473
""" % (self._repo_strings, datestring_first, datestring_last,), out)
460
""" % (tree5.bzrdir.root_transport.base,
461
branch1.bzrdir.root_transport.base,
462
datestring_first, datestring_last,
474
464
self.assertEqual('', err)
476
466
def test_info_standalone_no_tree(self):
477
467
# create standalone branch without a working tree
478
format = bzrdir.format_registry.make_bzrdir('default')
479
468
branch = self.make_branch('branch')
480
469
repo = branch.repository
481
out, err = self.run_bzr('info branch -v')
470
out, err = self.runbzr('info branch')
482
471
self.assertEqualDiff(
483
"""Standalone branch (format: %s)
488
476
control: Meta directory format 1
477
branch: Branch format 5
497
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
498
format.get_branch_format().get_format_description(),
499
format.repository_format.get_format_description(),
486
""" % (branch.bzrdir.root_transport.base,
487
repo._format.get_format_description(),
501
489
self.assertEqual('', err)
503
491
def test_info_shared_repository(self):
504
format = bzrdir.format_registry.make_bzrdir('knit')
492
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
493
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
505
494
transport = self.get_transport()
507
496
# Create shared repository
508
repo = self.make_repository('repo', shared=True, format=format)
497
repo = self.make_repository('repo', shared=True)
509
498
repo.set_make_working_trees(False)
510
out, err = self.run_bzr('info -v repo')
499
out, err = self.runbzr('info repo')
511
500
self.assertEqualDiff(
512
"""Shared repository (format: dirstate or dirstate-tags or knit)
514
502
shared repository: %s
517
505
control: Meta directory format 1
522
""" % ('repo', format.repository_format.get_format_description(),
511
""" % (repo.bzrdir.root_transport.base,
512
repo._format.get_format_description(),
524
514
self.assertEqual('', err)
526
516
# Create branch inside shared repository
527
517
repo.bzrdir.root_transport.mkdir('branch')
528
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
530
out, err = self.run_bzr('info -v repo/branch')
518
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
519
out, err = self.runbzr('info repo/branch')
531
520
self.assertEqualDiff(
532
"""Repository branch (format: dirstate or knit)
534
shared repository: repo
535
repository branch: repo/branch
522
shared repository: %s
523
repository branch: branch
538
526
control: Meta directory format 1
527
branch: Branch format 5
547
""" % (format.get_branch_format().get_format_description(),
548
format.repository_format.get_format_description(),
536
""" % (repo.bzrdir.root_transport.base,
537
repo._format.get_format_description(),
550
539
self.assertEqual('', err)
552
541
# Create lightweight checkout
553
542
transport.mkdir('tree')
554
543
transport.mkdir('tree/lightcheckout')
555
tree2 = branch1.create_checkout('tree/lightcheckout',
544
dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
545
bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
546
dir2.create_workingtree()
547
tree2 = dir2.open_workingtree()
557
548
branch2 = tree2.branch
558
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
559
shared_repo=repo, repo_branch=branch1, verbose=True)
549
out, err = self.runbzr('info tree/lightcheckout')
550
self.assertEqualDiff(
552
light checkout root: %s
553
shared repository: %s
554
repository branch: branch
557
control: Meta directory format 1
558
working tree: Working tree format 3
559
branch: Branch format 5
570
0 versioned subdirectories
578
""" % (tree2.bzrdir.root_transport.base,
579
repo.bzrdir.root_transport.base,
580
repo._format.get_format_description(),
582
self.assertEqual('', err)
561
584
# Create normal checkout
562
tree3 = branch1.create_checkout('tree/checkout')
563
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
565
light_checkout=False, repo_branch=branch1)
585
branch3 = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout')
586
branch3.bind(branch1)
587
tree3 = branch3.bzrdir.open_workingtree()
589
out, err = self.runbzr('info tree/checkout --verbose')
590
self.assertEqualDiff(
593
checkout of branch: %s
596
control: Meta directory format 1
597
working tree: Working tree format 3
598
branch: Branch format 5
609
0 versioned subdirectories
618
""" % (branch3.bzrdir.root_transport.base,
619
branch1.bzrdir.root_transport.base,
620
repo._format.get_format_description(),
622
self.assertEqual('', err)
566
624
# Update lightweight checkout
567
625
self.build_tree(['tree/lightcheckout/a'])
569
627
tree2.commit('commit one')
570
628
rev = repo.get_revision(branch2.revision_history()[0])
571
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
572
out, err = self.run_bzr('info tree/lightcheckout --verbose')
629
datestring_first = format_date(rev.timestamp, rev.timezone)
630
out, err = self.runbzr('info tree/lightcheckout --verbose')
573
631
self.assertEqualDiff(
574
"""Lightweight checkout (format: %s)
576
light checkout root: tree/lightcheckout
577
checkout of branch: repo/branch
578
shared repository: repo
633
light checkout root: %s
634
shared repository: %s
635
repository branch: branch
581
638
control: Meta directory format 1
582
working tree: Working tree format 6
639
working tree: Working tree format 3
640
branch: Branch format 5
586
643
In the working tree:
676
740
first revision: %s
677
741
latest revision: %s
681
""" % (format.get_branch_format().get_format_description(),
682
format.repository_format.get_format_description(),
746
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
747
repo._format.get_format_description(),
683
748
datestring_first, datestring_first,
749
# poking at _revision_store isn't all that clean, but neither is
750
# having the ui test dependent on the exact overhead of a given store.
751
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
685
753
self.assertEqual('', err)
686
754
tree3.commit('commit two')
688
756
# Out of date lightweight checkout
689
757
rev = repo.get_revision(branch1.revision_history()[-1])
690
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
691
out, err = self.run_bzr('info tree/lightcheckout --verbose')
758
datestring_last = format_date(rev.timestamp, rev.timezone)
759
out, err = self.runbzr('info tree/lightcheckout --verbose')
692
760
self.assertEqualDiff(
693
"""Lightweight checkout (format: %s)
695
light checkout root: tree/lightcheckout
696
checkout of branch: repo/branch
697
shared repository: repo
762
light checkout root: %s
763
shared repository: %s
764
repository branch: branch
700
767
control: Meta directory format 1
701
working tree: Working tree format 6
768
working tree: Working tree format 3
769
branch: Branch format 5
705
772
Working tree is out of date: missing 1 revision.
720
788
first revision: %s
721
789
latest revision: %s
725
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
726
format.repository_format.get_format_description(),
794
""" % (tree2.bzrdir.root_transport.base,
795
repo.bzrdir.root_transport.base,
796
repo._format.get_format_description(),
727
797
datestring_first, datestring_last,
798
# poking at _revision_store isn't all that clean, but neither is
799
# having the ui test dependent on the exact overhead of a given store.
800
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
729
802
self.assertEqual('', err)
731
804
# Show info about shared branch
732
out, err = self.run_bzr('info repo/branch --verbose')
805
out, err = self.runbzr('info repo/branch --verbose')
733
806
self.assertEqualDiff(
734
"""Repository branch (format: dirstate or knit)
736
shared repository: repo
737
repository branch: repo/branch
808
shared repository: %s
809
repository branch: branch
740
812
control: Meta directory format 1
813
branch: Branch format 5
747
820
first revision: %s
748
821
latest revision: %s
752
""" % (format.get_branch_format().get_format_description(),
753
format.repository_format.get_format_description(),
826
""" % (repo.bzrdir.root_transport.base,
827
repo._format.get_format_description(),
754
828
datestring_first, datestring_last,
829
# poking at _revision_store isn't all that clean, but neither is
830
# having the ui test dependent on the exact overhead of a given store.
831
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
756
833
self.assertEqual('', err)
758
835
# Show info about repository with revisions
759
out, err = self.run_bzr('info -v repo')
836
out, err = self.runbzr('info repo')
760
837
self.assertEqualDiff(
761
"""Shared repository (format: dirstate or dirstate-tags or knit)
763
shared repository: repo
839
shared repository: %s
766
842
control: Meta directory format 1
771
""" % (format.repository_format.get_format_description(),
848
""" % (repo.bzrdir.root_transport.base,
849
repo._format.get_format_description(),
850
# poking at _revision_store isn't all that clean, but neither is
851
# having the ui test dependent on the exact overhead of a given store.
852
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
773
854
self.assertEqual('', err)
856
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
775
858
def test_info_shared_repository_with_trees(self):
776
format = bzrdir.format_registry.make_bzrdir('knit')
859
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
860
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
777
861
transport = self.get_transport()
779
863
# Create shared repository with working trees
780
repo = self.make_repository('repo', shared=True, format=format)
864
repo = self.make_repository('repo', shared=True)
781
865
repo.set_make_working_trees(True)
782
out, err = self.run_bzr('info -v repo')
866
out, err = self.runbzr('info repo')
783
867
self.assertEqualDiff(
784
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
786
shared repository: repo
869
shared repository: %s
789
872
control: Meta directory format 1
975
1071
Create working tree for new branches inside the repository.
979
""" % (format.repository_format.get_format_description(),
1076
""" % (repo.bzrdir.root_transport.base,
1077
repo._format.get_format_description(),
1078
# poking at _revision_store isn't all that clean, but neither is
1079
# having the ui test dependent on the exact overhead of a given store.
1080
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
982
1083
self.assertEqual('', err)
1085
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
984
1087
def test_info_shared_repository_with_tree_in_root(self):
985
format = bzrdir.format_registry.make_bzrdir('knit')
1088
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1089
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
986
1090
transport = self.get_transport()
988
1092
# Create shared repository with working trees
989
repo = self.make_repository('repo', shared=True, format=format)
1093
repo = self.make_repository('repo', shared=True)
990
1094
repo.set_make_working_trees(True)
991
out, err = self.run_bzr('info -v repo')
1095
out, err = self.runbzr('info repo')
992
1096
self.assertEqualDiff(
993
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
995
shared repository: repo
1098
shared repository: %s
998
1101
control: Meta directory format 1
1010
1115
control = repo.bzrdir
1011
1116
branch = control.create_branch()
1012
1117
control.create_workingtree()
1013
out, err = self.run_bzr('info -v repo')
1118
out, err = self.runbzr('info repo')
1014
1119
self.assertEqualDiff(
1015
"""Repository tree (format: knit)
1017
shared repository: repo
1018
repository branch: repo
1121
shared repository: %s
1122
repository checkout: .
1021
1125
control: Meta directory format 1
1022
1126
working tree: Working tree format 3
1026
In the working tree:
1034
0 versioned subdirectories
1041
""" % (format.get_branch_format().get_format_description(),
1042
format.repository_format.get_format_description(),
1044
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,
1073
command_string, lco_tree, shared_repo=None,
1076
branch_locked=False, repo_locked=False,
1078
light_checkout=True,
1079
checkout_root=None):
1080
"""Check the output of info in a checkout.
1082
This is not quite a mirror of the info code: rather than using the
1083
tree being examined to predict output, it uses a bunch of flags which
1084
allow us, the test writers, to document what *should* be present in
1085
the output. Removing this separation would remove the value of the
1088
:param path: the path to the light checkout.
1089
:param lco_tree: the tree object for the light checkout.
1090
:param shared_repo: A shared repository is in use, expect that in
1092
:param repo_branch: A branch in a shared repository for non light
1094
:param tree_locked: If true, expect the tree to be locked.
1095
:param branch_locked: If true, expect the branch to be locked.
1096
: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
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).
1114
# 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)
1119
out, err = self.run_bzr('info %s' % command_string)
1121
(True, True): 'Lightweight checkout',
1122
(True, False): 'Repository checkout',
1123
(False, True): 'Lightweight checkout',
1124
(False, False): 'Checkout',
1125
}[(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()
1130
if repo_locked or branch_locked or tree_locked:
1131
def locked_message(a_bool):
1136
expected_lock_output = (
1139
" working tree: %s\n"
1141
" repository: %s\n" % (
1142
locked_message(tree_locked),
1143
locked_message(branch_locked),
1144
locked_message(repo_locked)))
1146
expected_lock_output = ''
1150
tree_data = (" light checkout root: %s\n" %
1151
friendly_location(lco_tree.bzrdir.root_transport.base))
1153
if lco_tree.branch.get_bound_location() is not None:
1154
tree_data += ("%s checkout root: %s\n" % (extra_space,
1155
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1156
if shared_repo is not None:
1158
" checkout of branch: %s\n"
1159
" shared repository: %s\n" %
1160
(friendly_location(repo_branch.bzrdir.root_transport.base),
1161
friendly_location(shared_repo.bzrdir.root_transport.base)))
1162
elif repo_branch is not None:
1164
"%s checkout of branch: %s\n" %
1166
friendly_location(repo_branch.bzrdir.root_transport.base)))
1168
branch_data = (" checkout of branch: %s\n" %
1169
lco_tree.branch.bzrdir.root_transport.base)
1172
verbose_info = ' 0 committers\n'
1176
self.assertEqualDiff(
1181
control: Meta directory format 1
1186
In the working tree:
1194
0 versioned subdirectories
1205
lco_tree._format.get_format_description(),
1206
lco_tree.branch._format.get_format_description(),
1207
lco_tree.branch.repository._format.get_format_description(),
1208
expected_lock_output,
1211
self.assertEqual('', err)
1127
branch: Branch format 5
1130
In the working tree:
1138
0 versioned subdirectories
1146
""" % (repo.bzrdir.root_transport.base,
1147
repo._format.get_format_description(),
1149
self.assertEqual('', err)
1151
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1213
1153
def test_info_locking(self):
1214
1154
transport = self.get_transport()
1215
1155
# Create shared repository with a branch
1216
1156
repo = self.make_repository('repo', shared=True,
1217
format=bzrdir.BzrDirMetaFormat1())
1157
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1218
1158
repo.set_make_working_trees(False)
1219
1159
repo.bzrdir.root_transport.mkdir('branch')
1220
1160
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1221
format=bzrdir.BzrDirMetaFormat1())
1161
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1222
1162
# Do a heavy checkout
1223
1163
transport.mkdir('tree')
1224
1164
transport.mkdir('tree/checkout')
1225
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
format=bzrdir.BzrDirMetaFormat1())
1165
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1166
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1227
1167
co_branch.bind(repo_branch)
1228
1168
# Do a light checkout of the heavy one
1229
1169
transport.mkdir('tree/lightcheckout')
1230
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1231
branch.BranchReferenceFormat().initialize(lco_dir,
1232
target_branch=co_branch)
1170
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1171
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1233
1172
lco_dir.create_workingtree()
1234
1173
lco_tree = lco_dir.open_workingtree()
1240
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1241
repo_branch=repo_branch,
1242
verbose=True, light_checkout=True)
1179
out, err = self.runbzr('info tree/lightcheckout')
1180
self.assertEqualDiff(
1182
light checkout root: %s
1183
checkout of branch: %s
1186
control: Meta directory format 1
1187
working tree: Working tree format 3
1188
branch: Branch format 5
1191
In the working tree:
1199
0 versioned subdirectories
1207
""" % (lco_tree.bzrdir.root_transport.base,
1208
lco_tree.branch.bzrdir.root_transport.base,
1209
lco_tree.branch.repository._format.get_format_description(),
1211
self.assertEqual('', err)
1244
1213
lco_tree.branch.repository.lock_write()
1246
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1247
lco_tree, repo_branch=repo_branch,
1248
repo_locked=True, verbose=True, light_checkout=True)
1250
lco_tree.branch.repository.unlock()
1214
out, err = self.runbzr('info tree/lightcheckout')
1215
self.assertEqualDiff(
1217
light checkout root: %s
1218
checkout of branch: %s
1221
control: Meta directory format 1
1222
working tree: Working tree format 3
1223
branch: Branch format 5
1227
working tree: unlocked
1231
In the working tree:
1239
0 versioned subdirectories
1247
""" % (lco_tree.bzrdir.root_transport.base,
1248
lco_tree.branch.bzrdir.root_transport.base,
1249
lco_tree.branch.repository._format.get_format_description(),
1251
self.assertEqual('', err)
1252
lco_tree.branch.repository.unlock()
1252
1254
lco_tree.branch.lock_write()
1254
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1258
repo_branch=repo_branch,
1261
lco_tree.branch.unlock()
1255
out, err = self.runbzr('info tree/lightcheckout')
1256
self.assertEqualDiff(
1258
light checkout root: %s
1259
checkout of branch: %s
1262
control: Meta directory format 1
1263
working tree: Working tree format 3
1264
branch: Branch format 5
1268
working tree: unlocked
1272
In the working tree:
1280
0 versioned subdirectories
1288
""" % (lco_tree.bzrdir.root_transport.base,
1289
lco_tree.branch.bzrdir.root_transport.base,
1290
lco_tree.branch.repository._format.get_format_description(),
1292
self.assertEqual('', err)
1293
lco_tree.branch.unlock()
1263
1295
lco_tree.lock_write()
1265
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1266
lco_tree, repo_branch=repo_branch,
1296
out, err = self.runbzr('info tree/lightcheckout')
1297
self.assertEqualDiff(
1299
light checkout root: %s
1300
checkout of branch: %s
1303
control: Meta directory format 1
1304
working tree: Working tree format 3
1305
branch: Branch format 5
1309
working tree: locked
1313
In the working tree:
1321
0 versioned subdirectories
1329
""" % (lco_tree.bzrdir.root_transport.base,
1330
lco_tree.branch.bzrdir.root_transport.base,
1331
lco_tree.branch.repository._format.get_format_description(),
1333
self.assertEqual('', err)
1274
1336
lco_tree.lock_write()
1275
1337
lco_tree.branch.repository.unlock()
1277
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1278
lco_tree, repo_branch=repo_branch,
1283
lco_tree.branch.repository.lock_write()
1338
out, err = self.runbzr('info tree/lightcheckout')
1339
self.assertEqualDiff(
1341
light checkout root: %s
1342
checkout of branch: %s
1345
control: Meta directory format 1
1346
working tree: Working tree format 3
1347
branch: Branch format 5
1351
working tree: locked
1353
repository: unlocked
1355
In the working tree:
1363
0 versioned subdirectories
1371
""" % (lco_tree.bzrdir.root_transport.base,
1372
lco_tree.branch.bzrdir.root_transport.base,
1373
lco_tree.branch.repository._format.get_format_description(),
1375
self.assertEqual('', err)
1376
lco_tree.branch.repository.lock_write()
1286
1379
lco_tree.lock_write()
1287
1380
lco_tree.branch.unlock()
1289
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1290
lco_tree, repo_branch=repo_branch,
1294
lco_tree.branch.lock_write()
1381
out, err = self.runbzr('info tree/lightcheckout')
1382
self.assertEqualDiff(
1384
light checkout root: %s
1385
checkout of branch: %s
1388
control: Meta directory format 1
1389
working tree: Working tree format 3
1390
branch: Branch format 5
1394
working tree: locked
1396
repository: unlocked
1398
In the working tree:
1406
0 versioned subdirectories
1414
""" % (lco_tree.bzrdir.root_transport.base,
1415
lco_tree.branch.bzrdir.root_transport.base,
1416
lco_tree.branch.repository._format.get_format_description(),
1418
self.assertEqual('', err)
1419
lco_tree.branch.lock_write()
1297
1422
lco_tree.lock_write()
1298
1423
lco_tree.branch.unlock()
1299
1424
lco_tree.branch.repository.lock_write()
1301
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1302
lco_tree, repo_branch=repo_branch,
1307
lco_tree.branch.repository.unlock()
1308
lco_tree.branch.lock_write()
1425
out, err = self.runbzr('info tree/lightcheckout')
1426
self.assertEqualDiff(
1428
light checkout root: %s
1429
checkout of branch: %s
1432
control: Meta directory format 1
1433
working tree: Working tree format 3
1434
branch: Branch format 5
1438
working tree: locked
1442
In the working tree:
1450
0 versioned subdirectories
1458
""" % (lco_tree.bzrdir.root_transport.base,
1459
lco_tree.branch.bzrdir.root_transport.base,
1460
lco_tree.branch.repository._format.get_format_description(),
1462
self.assertEqual('', err)
1463
lco_tree.branch.repository.unlock()
1464
lco_tree.branch.lock_write()
1311
1467
lco_tree.branch.lock_write()
1312
1468
lco_tree.branch.repository.unlock()
1314
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1315
lco_tree, repo_branch=repo_branch,
1319
lco_tree.branch.repository.lock_write()
1320
lco_tree.branch.unlock()
1322
if sys.platform == 'win32':
1323
self.knownFailure('Win32 cannot run "bzr info"'
1324
' when the tree is locked.')
1469
out, err = self.runbzr('info tree/lightcheckout')
1470
self.assertEqualDiff(
1472
light checkout root: %s
1473
checkout of branch: %s
1476
control: Meta directory format 1
1477
working tree: Working tree format 3
1478
branch: Branch format 5
1482
working tree: unlocked
1484
repository: unlocked
1486
In the working tree:
1494
0 versioned subdirectories
1502
""" % (lco_tree.bzrdir.root_transport.base,
1503
lco_tree.branch.bzrdir.root_transport.base,
1504
lco_tree.branch.repository._format.get_format_description(),
1506
self.assertEqual('', err)
1507
lco_tree.branch.repository.lock_write()
1508
lco_tree.branch.unlock()
1326
1510
def test_info_locking_oslocks(self):
1327
1511
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()
1512
raise TestSkipped("don't use oslocks on win32 in unix manner")
1335
1514
tree = self.make_branch_and_tree('branch',
1336
format=bzrdir.BzrDirFormat6())
1515
format=bzrlib.bzrdir.BzrDirFormat6())
1338
1517
# Test all permutations of locking the working tree, branch and repository
1339
1518
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's