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"
25
from bzrlib.osutils import format_date
26
from bzrlib.tests import TestSkipped
27
from bzrlib.tests.blackbox import ExternalBase
30
class TestInfo(ExternalBase):
41
32
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)
33
out, err = self.runbzr('info /i/do/not/exist/', retcode=3)
45
34
self.assertEqual(out, '')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
35
self.assertEqual(err, 'bzr: ERROR: Not a branch: /i/do/not/exist/\n')
48
37
def test_info_standalone(self):
49
38
transport = self.get_transport()
51
40
# Create initial standalone branch
52
tree1 = self.make_branch_and_tree('standalone', 'weave')
41
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
42
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
43
tree1 = self.make_branch_and_tree('standalone')
44
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
53
45
self.build_tree(['standalone/a'])
55
47
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
48
out, err = self.runbzr('info standalone')
54
control: All-in-one format 6
55
working tree: Working tree format 2
56
branch: Branch format 4
57
repository: Weave repository format 6
67
0 versioned subdirectories
75
""" % branch1.bzrdir.root_transport.base, out)
126
76
self.assertEqual('', err)
127
77
tree1.commit('commit one')
128
78
rev = branch1.repository.get_revision(branch1.revision_history()[0])
129
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
79
datestring_first = format_date(rev.timestamp, rev.timezone)
131
81
# Branch standalone with push location
132
82
branch2 = branch1.bzrdir.sprout('branch').open_branch()
133
83
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
84
out, err = self.runbzr('info branch --verbose')
158
94
control: All-in-one format 6
176
113
first revision: %s
177
114
latest revision: %s
181
""" % (datestring_first, datestring_first,
119
""" % (branch2.bzrdir.root_transport.base,
120
branch1.bzrdir.root_transport.base,
121
branch1.bzrdir.root_transport.base,
122
datestring_first, datestring_first,
123
# poking at _revision_store isn't all that clean, but neither is
124
# having the ui test dependent on the exact overhead of a given store.
125
branch2.repository._revision_store.total_size(
126
branch2.repository.get_transaction())[1] / 1024,
183
128
self.assertEqual('', err)
185
130
# Branch and bind to standalone, needs upgrade to metadir
186
131
# (creates backup as unknown)
187
132
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()
133
bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
134
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
191
135
branch3.bind(branch1)
192
bound_tree = branch3.bzrdir.open_workingtree()
193
out, err = self.run_bzr('info -v bound')
136
out, err = self.runbzr('info bound')
194
137
self.assertEqualDiff(
195
"""Checkout (format: knit)
198
checkout of branch: standalone
140
checkout of branch: %s
200
142
Related branches:
201
parent branch: standalone
204
146
control: Meta directory format 1
147
working tree: Working tree format 3
148
branch: Branch format 5
209
151
In the working tree:
222
164
first revision: %s
223
165
latest revision: %s
227
""" % (bound_tree._format.get_format_description(),
228
branch3._format.get_format_description(),
170
""" % (branch3.bzrdir.root_transport.base,
171
branch1.bzrdir.root_transport.base,
172
branch1.bzrdir.root_transport.base,
229
173
branch3.repository._format.get_format_description(),
230
174
datestring_first, datestring_first,
175
# poking at _revision_store isn't all that clean, but neither is
176
# having the ui test dependent on the exact overhead of a given store.
177
branch3.repository._revision_store.total_size(
178
branch3.repository.get_transaction())[1] / 1024,
232
180
self.assertEqual('', err)
234
182
# Checkout standalone (same as above, but does not have parent set)
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
183
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
184
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
185
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout')
186
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
237
187
branch4.bind(branch1)
238
188
branch4.bzrdir.open_workingtree().update()
239
out, err = self.run_bzr('info checkout --verbose')
189
out, err = self.runbzr('info checkout --verbose')
240
190
self.assertEqualDiff(
241
"""Checkout (format: knit)
243
checkout root: checkout
244
checkout of branch: standalone
193
checkout of branch: %s
247
196
control: Meta directory format 1
265
215
first revision: %s
266
216
latest revision: %s
270
""" % (branch4.repository._format.get_format_description(),
221
""" % (branch4.bzrdir.root_transport.base,
222
branch1.bzrdir.root_transport.base,
223
branch4.repository._format.get_format_description(),
271
224
datestring_first, datestring_first,
225
# poking at _revision_store isn't all that clean, but neither is
226
# having the ui test dependent on the exact overhead of a given store.
227
branch4.repository._revision_store.total_size(
228
branch4.repository.get_transaction())[1] / 1024,
273
230
self.assertEqual('', err)
275
232
# Lightweight checkout (same as above, different branch and repository)
276
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
233
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
234
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
235
transport.mkdir('lightcheckout')
236
dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
237
bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
238
dir5.create_workingtree()
239
tree5 = dir5.open_workingtree()
240
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
277
241
branch5 = tree5.branch
278
out, err = self.run_bzr('info -v lightcheckout')
242
out, err = self.runbzr('info lightcheckout')
279
243
self.assertEqualDiff(
280
"""Lightweight checkout (format: %s)
282
light checkout root: lightcheckout
283
checkout of branch: standalone
245
light checkout root: %s
246
checkout of branch: %s
286
249
control: Meta directory format 1
287
working tree: Working tree format 6
250
working tree: Working tree format 3
288
251
branch: Branch format 4
289
252
repository: Weave repository format 6
468
451
first revision: %s
469
452
latest revision: %s
473
""" % (self._repo_strings, datestring_first, datestring_last,), out)
457
""" % (tree5.bzrdir.root_transport.base,
458
branch1.bzrdir.root_transport.base,
459
datestring_first, datestring_last,
474
461
self.assertEqual('', err)
476
463
def test_info_standalone_no_tree(self):
477
464
# create standalone branch without a working tree
478
format = bzrdir.format_registry.make_bzrdir('default')
479
465
branch = self.make_branch('branch')
480
466
repo = branch.repository
481
out, err = self.run_bzr('info branch -v')
467
out, err = self.runbzr('info branch')
482
468
self.assertEqualDiff(
483
"""Standalone branch (format: %s)
488
473
control: Meta directory format 1
474
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(),
483
""" % (branch.bzrdir.root_transport.base,
484
repo._format.get_format_description(),
501
486
self.assertEqual('', err)
503
488
def test_info_shared_repository(self):
504
format = bzrdir.format_registry.make_bzrdir('knit')
489
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
490
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
505
491
transport = self.get_transport()
507
493
# Create shared repository
508
repo = self.make_repository('repo', shared=True, format=format)
494
repo = self.make_repository('repo', shared=True)
509
495
repo.set_make_working_trees(False)
510
out, err = self.run_bzr('info -v repo')
496
out, err = self.runbzr('info repo')
511
497
self.assertEqualDiff(
512
"""Shared repository (format: dirstate or dirstate-tags or knit)
514
499
shared repository: %s
517
502
control: Meta directory format 1
522
""" % ('repo', format.repository_format.get_format_description(),
508
""" % (repo.bzrdir.root_transport.base,
509
repo._format.get_format_description(),
524
511
self.assertEqual('', err)
526
513
# Create branch inside shared repository
527
514
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')
515
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
516
out, err = self.runbzr('info repo/branch')
531
517
self.assertEqualDiff(
532
"""Repository branch (format: dirstate or knit)
534
shared repository: repo
535
repository branch: repo/branch
519
shared repository: %s
520
repository branch: branch
538
523
control: Meta directory format 1
524
branch: Branch format 5
547
""" % (format.get_branch_format().get_format_description(),
548
format.repository_format.get_format_description(),
533
""" % (repo.bzrdir.root_transport.base,
534
repo._format.get_format_description(),
550
536
self.assertEqual('', err)
552
538
# Create lightweight checkout
553
539
transport.mkdir('tree')
554
540
transport.mkdir('tree/lightcheckout')
555
tree2 = branch1.create_checkout('tree/lightcheckout',
541
dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
542
bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
543
dir2.create_workingtree()
544
tree2 = dir2.open_workingtree()
557
545
branch2 = tree2.branch
558
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
559
shared_repo=repo, repo_branch=branch1, verbose=True)
546
out, err = self.runbzr('info tree/lightcheckout')
547
self.assertEqualDiff(
549
light checkout root: %s
550
shared repository: %s
551
repository branch: branch
554
control: Meta directory format 1
555
working tree: Working tree format 3
556
branch: Branch format 5
567
0 versioned subdirectories
575
""" % (tree2.bzrdir.root_transport.base,
576
repo.bzrdir.root_transport.base,
577
repo._format.get_format_description(),
579
self.assertEqual('', err)
561
581
# Create normal checkout
562
tree3 = branch1.create_checkout('tree/checkout')
563
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
565
light_checkout=False, repo_branch=branch1)
582
branch3 = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout')
583
branch3.bind(branch1)
584
tree3 = branch3.bzrdir.open_workingtree()
586
out, err = self.runbzr('info tree/checkout --verbose')
587
self.assertEqualDiff(
590
checkout of branch: %s
593
control: Meta directory format 1
594
working tree: Working tree format 3
595
branch: Branch format 5
606
0 versioned subdirectories
615
""" % (branch3.bzrdir.root_transport.base,
616
branch1.bzrdir.root_transport.base,
617
repo._format.get_format_description(),
619
self.assertEqual('', err)
566
621
# Update lightweight checkout
567
622
self.build_tree(['tree/lightcheckout/a'])
569
624
tree2.commit('commit one')
570
625
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')
626
datestring_first = format_date(rev.timestamp, rev.timezone)
627
out, err = self.runbzr('info tree/lightcheckout --verbose')
573
628
self.assertEqualDiff(
574
"""Lightweight checkout (format: %s)
576
light checkout root: tree/lightcheckout
577
checkout of branch: repo/branch
578
shared repository: repo
630
light checkout root: %s
631
shared repository: %s
632
repository branch: branch
581
635
control: Meta directory format 1
582
working tree: Working tree format 6
636
working tree: Working tree format 3
637
branch: Branch format 5
586
640
In the working tree:
676
737
first revision: %s
677
738
latest revision: %s
681
""" % (format.get_branch_format().get_format_description(),
682
format.repository_format.get_format_description(),
743
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
744
repo._format.get_format_description(),
683
745
datestring_first, datestring_first,
746
# poking at _revision_store isn't all that clean, but neither is
747
# having the ui test dependent on the exact overhead of a given store.
748
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
685
750
self.assertEqual('', err)
686
751
tree3.commit('commit two')
688
753
# Out of date lightweight checkout
689
754
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')
755
datestring_last = format_date(rev.timestamp, rev.timezone)
756
out, err = self.runbzr('info tree/lightcheckout --verbose')
692
757
self.assertEqualDiff(
693
"""Lightweight checkout (format: %s)
695
light checkout root: tree/lightcheckout
696
checkout of branch: repo/branch
697
shared repository: repo
759
light checkout root: %s
760
shared repository: %s
761
repository branch: branch
700
764
control: Meta directory format 1
701
working tree: Working tree format 6
765
working tree: Working tree format 3
766
branch: Branch format 5
705
769
Working tree is out of date: missing 1 revision.
720
785
first revision: %s
721
786
latest revision: %s
725
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
726
format.repository_format.get_format_description(),
791
""" % (tree2.bzrdir.root_transport.base,
792
repo.bzrdir.root_transport.base,
793
repo._format.get_format_description(),
727
794
datestring_first, datestring_last,
795
# poking at _revision_store isn't all that clean, but neither is
796
# having the ui test dependent on the exact overhead of a given store.
797
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
729
799
self.assertEqual('', err)
731
801
# Show info about shared branch
732
out, err = self.run_bzr('info repo/branch --verbose')
802
out, err = self.runbzr('info repo/branch --verbose')
733
803
self.assertEqualDiff(
734
"""Repository branch (format: dirstate or knit)
736
shared repository: repo
737
repository branch: repo/branch
805
shared repository: %s
806
repository branch: branch
740
809
control: Meta directory format 1
810
branch: Branch format 5
747
817
first revision: %s
748
818
latest revision: %s
752
""" % (format.get_branch_format().get_format_description(),
753
format.repository_format.get_format_description(),
823
""" % (repo.bzrdir.root_transport.base,
824
repo._format.get_format_description(),
754
825
datestring_first, datestring_last,
826
# poking at _revision_store isn't all that clean, but neither is
827
# having the ui test dependent on the exact overhead of a given store.
828
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
756
830
self.assertEqual('', err)
758
832
# Show info about repository with revisions
759
out, err = self.run_bzr('info -v repo')
833
out, err = self.runbzr('info repo')
760
834
self.assertEqualDiff(
761
"""Shared repository (format: dirstate or dirstate-tags or knit)
763
shared repository: repo
836
shared repository: %s
766
839
control: Meta directory format 1
771
""" % (format.repository_format.get_format_description(),
845
""" % (repo.bzrdir.root_transport.base,
846
repo._format.get_format_description(),
847
# poking at _revision_store isn't all that clean, but neither is
848
# having the ui test dependent on the exact overhead of a given store.
849
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
773
851
self.assertEqual('', err)
853
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
775
855
def test_info_shared_repository_with_trees(self):
776
format = bzrdir.format_registry.make_bzrdir('knit')
856
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
857
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
777
858
transport = self.get_transport()
779
860
# Create shared repository with working trees
780
repo = self.make_repository('repo', shared=True, format=format)
861
repo = self.make_repository('repo', shared=True)
781
862
repo.set_make_working_trees(True)
782
out, err = self.run_bzr('info -v repo')
863
out, err = self.runbzr('info repo')
783
864
self.assertEqualDiff(
784
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
786
shared repository: repo
866
shared repository: %s
789
869
control: Meta directory format 1
975
1068
Create working tree for new branches inside the repository.
979
""" % (format.repository_format.get_format_description(),
1073
""" % (repo.bzrdir.root_transport.base,
1074
repo._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)
1082
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
984
1084
def test_info_shared_repository_with_tree_in_root(self):
985
format = bzrdir.format_registry.make_bzrdir('knit')
1085
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1086
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
986
1087
transport = self.get_transport()
988
1089
# Create shared repository with working trees
989
repo = self.make_repository('repo', shared=True, format=format)
1090
repo = self.make_repository('repo', shared=True)
990
1091
repo.set_make_working_trees(True)
991
out, err = self.run_bzr('info -v repo')
1092
out, err = self.runbzr('info repo')
992
1093
self.assertEqualDiff(
993
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
995
shared repository: repo
1095
shared repository: %s
998
1098
control: Meta directory format 1
1010
1112
control = repo.bzrdir
1011
1113
branch = control.create_branch()
1012
1114
control.create_workingtree()
1013
out, err = self.run_bzr('info -v repo')
1115
out, err = self.runbzr('info repo')
1014
1116
self.assertEqualDiff(
1015
"""Repository tree (format: knit)
1017
shared repository: repo
1018
repository branch: repo
1118
shared repository: %s
1119
repository checkout: .
1021
1122
control: Meta directory format 1
1022
1123
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)
1124
branch: Branch format 5
1127
In the working tree:
1135
0 versioned subdirectories
1143
""" % (repo.bzrdir.root_transport.base,
1144
repo._format.get_format_description(),
1146
self.assertEqual('', err)
1148
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1213
1150
def test_info_locking(self):
1214
1151
transport = self.get_transport()
1215
1152
# Create shared repository with a branch
1216
1153
repo = self.make_repository('repo', shared=True,
1217
format=bzrdir.BzrDirMetaFormat1())
1154
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1218
1155
repo.set_make_working_trees(False)
1219
1156
repo.bzrdir.root_transport.mkdir('branch')
1220
1157
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1221
format=bzrdir.BzrDirMetaFormat1())
1158
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1222
1159
# Do a heavy checkout
1223
1160
transport.mkdir('tree')
1224
1161
transport.mkdir('tree/checkout')
1225
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
format=bzrdir.BzrDirMetaFormat1())
1162
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1163
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1227
1164
co_branch.bind(repo_branch)
1228
1165
# Do a light checkout of the heavy one
1229
1166
transport.mkdir('tree/lightcheckout')
1230
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1231
branch.BranchReferenceFormat().initialize(lco_dir,
1232
target_branch=co_branch)
1167
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1168
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1233
1169
lco_dir.create_workingtree()
1234
1170
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)
1176
out, err = self.runbzr('info tree/lightcheckout')
1177
self.assertEqualDiff(
1179
light checkout root: %s
1180
checkout of branch: %s
1183
control: Meta directory format 1
1184
working tree: Working tree format 3
1185
branch: Branch format 5
1188
In the working tree:
1196
0 versioned subdirectories
1204
""" % (lco_tree.bzrdir.root_transport.base,
1205
lco_tree.branch.bzrdir.root_transport.base,
1206
lco_tree.branch.repository._format.get_format_description(),
1208
self.assertEqual('', err)
1244
1210
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()
1211
out, err = self.runbzr('info tree/lightcheckout')
1212
self.assertEqualDiff(
1214
light checkout root: %s
1215
checkout of branch: %s
1218
control: Meta directory format 1
1219
working tree: Working tree format 3
1220
branch: Branch format 5
1224
working tree: unlocked
1228
In the working tree:
1236
0 versioned subdirectories
1244
""" % (lco_tree.bzrdir.root_transport.base,
1245
lco_tree.branch.bzrdir.root_transport.base,
1246
lco_tree.branch.repository._format.get_format_description(),
1248
self.assertEqual('', err)
1249
lco_tree.branch.repository.unlock()
1252
1251
lco_tree.branch.lock_write()
1254
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1258
repo_branch=repo_branch,
1261
lco_tree.branch.unlock()
1252
out, err = self.runbzr('info tree/lightcheckout')
1253
self.assertEqualDiff(
1255
light checkout root: %s
1256
checkout of branch: %s
1259
control: Meta directory format 1
1260
working tree: Working tree format 3
1261
branch: Branch format 5
1265
working tree: unlocked
1269
In the working tree:
1277
0 versioned subdirectories
1285
""" % (lco_tree.bzrdir.root_transport.base,
1286
lco_tree.branch.bzrdir.root_transport.base,
1287
lco_tree.branch.repository._format.get_format_description(),
1289
self.assertEqual('', err)
1290
lco_tree.branch.unlock()
1263
1292
lco_tree.lock_write()
1265
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1266
lco_tree, repo_branch=repo_branch,
1293
out, err = self.runbzr('info tree/lightcheckout')
1294
self.assertEqualDiff(
1296
light checkout root: %s
1297
checkout of branch: %s
1300
control: Meta directory format 1
1301
working tree: Working tree format 3
1302
branch: Branch format 5
1306
working tree: locked
1310
In the working tree:
1318
0 versioned subdirectories
1326
""" % (lco_tree.bzrdir.root_transport.base,
1327
lco_tree.branch.bzrdir.root_transport.base,
1328
lco_tree.branch.repository._format.get_format_description(),
1330
self.assertEqual('', err)
1274
1333
lco_tree.lock_write()
1275
1334
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()
1335
out, err = self.runbzr('info tree/lightcheckout')
1336
self.assertEqualDiff(
1338
light checkout root: %s
1339
checkout of branch: %s
1342
control: Meta directory format 1
1343
working tree: Working tree format 3
1344
branch: Branch format 5
1348
working tree: locked
1350
repository: unlocked
1352
In the working tree:
1360
0 versioned subdirectories
1368
""" % (lco_tree.bzrdir.root_transport.base,
1369
lco_tree.branch.bzrdir.root_transport.base,
1370
lco_tree.branch.repository._format.get_format_description(),
1372
self.assertEqual('', err)
1373
lco_tree.branch.repository.lock_write()
1286
1376
lco_tree.lock_write()
1287
1377
lco_tree.branch.unlock()
1289
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1290
lco_tree, repo_branch=repo_branch,
1294
lco_tree.branch.lock_write()
1378
out, err = self.runbzr('info tree/lightcheckout')
1379
self.assertEqualDiff(
1381
light checkout root: %s
1382
checkout of branch: %s
1385
control: Meta directory format 1
1386
working tree: Working tree format 3
1387
branch: Branch format 5
1391
working tree: locked
1393
repository: unlocked
1395
In the working tree:
1403
0 versioned subdirectories
1411
""" % (lco_tree.bzrdir.root_transport.base,
1412
lco_tree.branch.bzrdir.root_transport.base,
1413
lco_tree.branch.repository._format.get_format_description(),
1415
self.assertEqual('', err)
1416
lco_tree.branch.lock_write()
1297
1419
lco_tree.lock_write()
1298
1420
lco_tree.branch.unlock()
1299
1421
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()
1422
out, err = self.runbzr('info tree/lightcheckout')
1423
self.assertEqualDiff(
1425
light checkout root: %s
1426
checkout of branch: %s
1429
control: Meta directory format 1
1430
working tree: Working tree format 3
1431
branch: Branch format 5
1435
working tree: locked
1439
In the working tree:
1447
0 versioned subdirectories
1455
""" % (lco_tree.bzrdir.root_transport.base,
1456
lco_tree.branch.bzrdir.root_transport.base,
1457
lco_tree.branch.repository._format.get_format_description(),
1459
self.assertEqual('', err)
1460
lco_tree.branch.repository.unlock()
1461
lco_tree.branch.lock_write()
1311
1464
lco_tree.branch.lock_write()
1312
1465
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.')
1466
out, err = self.runbzr('info tree/lightcheckout')
1467
self.assertEqualDiff(
1469
light checkout root: %s
1470
checkout of branch: %s
1473
control: Meta directory format 1
1474
working tree: Working tree format 3
1475
branch: Branch format 5
1479
working tree: unlocked
1481
repository: unlocked
1483
In the working tree:
1491
0 versioned subdirectories
1499
""" % (lco_tree.bzrdir.root_transport.base,
1500
lco_tree.branch.bzrdir.root_transport.base,
1501
lco_tree.branch.repository._format.get_format_description(),
1503
self.assertEqual('', err)
1504
lco_tree.branch.repository.lock_write()
1505
lco_tree.branch.unlock()
1326
1507
def test_info_locking_oslocks(self):
1327
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()
1335
1508
tree = self.make_branch_and_tree('branch',
1336
format=bzrdir.BzrDirFormat6())
1509
format=bzrlib.bzrdir.BzrDirFormat6())
1338
1511
# Test all permutations of locking the working tree, branch and repository
1339
1512
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's