1
# Copyright (C) 2006 by Canonical Ltd
2
# -*- coding: utf-8 -*-
1
# Copyright (C) 2006-2010 Canonical Ltd
4
3
# This program is free software; you can redistribute it and/or modify
5
4
# it under the terms of the GNU General Public License as published by
6
5
# the Free Software Foundation; either version 2 of the License, or
7
6
# (at your option) any later version.
9
8
# This program is distributed in the hope that it will be useful,
10
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
11
# GNU General Public License for more details.
14
13
# You should have received a copy of the GNU General Public License
15
14
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
18
"""Tests for the info command of bzr."""
25
from bzrlib.osutils import format_date
26
from bzrlib.tests import TestSkipped
27
from bzrlib.tests.blackbox import ExternalBase
30
class TestInfo(ExternalBase):
32
from bzrlib.transport import memory
35
class TestInfo(tests.TestCaseWithTransport):
38
super(TestInfo, self).setUp()
39
self._repo_strings = "2a"
32
41
def test_info_non_existing(self):
33
out, err = self.runbzr('info /i/do/not/exist/', retcode=3)
42
self.vfs_transport_factory = memory.MemoryServer
43
location = self.get_url()
44
out, err = self.run_bzr('info '+location, retcode=3)
34
45
self.assertEqual(out, '')
35
self.assertEqual(err, 'bzr: ERROR: Not a branch: /i/do/not/exist/\n')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
37
48
def test_info_standalone(self):
38
49
transport = self.get_transport()
40
51
# Create initial standalone branch
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)
52
tree1 = self.make_branch_and_tree('standalone', 'knit')
45
53
self.build_tree(['standalone/a'])
47
55
branch1 = tree1.branch
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)
57
out, err = self.run_bzr('info standalone')
59
"""Standalone tree (format: knit)
61
branch root: standalone
63
self.assertEqual('', err)
65
# Standalone branch - verbose mode
66
out, err = self.run_bzr('info standalone -v')
68
"""Standalone tree (format: knit)
70
branch root: standalone
73
control: Meta directory format 1
74
working tree: Working tree format 3
75
branch: Branch format 5
76
repository: Knit repository format 1
86
0 versioned subdirectories
94
self.assertEqual('', err)
96
# Standalone branch - really verbose mode
97
out, err = self.run_bzr('info standalone -vv')
99
"""Standalone tree (format: knit)
101
branch root: standalone
104
control: Meta directory format 1
105
working tree: Working tree format 3
106
branch: Branch format 5
107
repository: Knit repository format 1
117
0 versioned subdirectories
76
126
self.assertEqual('', err)
77
127
tree1.commit('commit one')
78
128
rev = branch1.repository.get_revision(branch1.revision_history()[0])
79
datestring_first = format_date(rev.timestamp, rev.timezone)
129
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
81
131
# Branch standalone with push location
82
132
branch2 = branch1.bzrdir.sprout('branch').open_branch()
83
133
branch2.set_push_location(branch1.bzrdir.root_transport.base)
84
out, err = self.runbzr('info branch --verbose')
135
out, err = self.run_bzr('info branch')
136
self.assertEqualDiff(
137
"""Standalone tree (format: knit)
142
push branch: standalone
143
parent branch: standalone
145
self.assertEqual('', err)
147
out, err = self.run_bzr('info branch --verbose')
148
self.assertEqualDiff(
149
"""Standalone tree (format: knit)
154
push branch: standalone
155
parent branch: standalone
94
control: All-in-one format 6
95
working tree: Working tree format 2
96
branch: Branch format 4
97
repository: Weave repository format 6
158
control: Meta directory format 1
159
working tree: Working tree format 3
160
branch: Branch format 5
161
repository: Knit repository format 1
99
163
In the working tree:
113
176
first revision: %s
114
177
latest revision: %s
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,
181
""" % (datestring_first, datestring_first,
128
183
self.assertEqual('', err)
130
185
# Branch and bind to standalone, needs upgrade to metadir
131
186
# (creates backup as unknown)
132
187
branch1.bzrdir.sprout('bound')
133
bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
134
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
188
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
189
upgrade.upgrade('bound', knit1_format)
190
branch3 = bzrdir.BzrDir.open('bound').open_branch()
135
191
branch3.bind(branch1)
136
out, err = self.runbzr('info bound')
192
bound_tree = branch3.bzrdir.open_workingtree()
193
out, err = self.run_bzr('info -v bound')
137
194
self.assertEqualDiff(
140
checkout of branch: %s
195
"""Checkout (format: knit)
198
checkout of branch: standalone
142
200
Related branches:
201
parent branch: standalone
146
204
control: Meta directory format 1
147
working tree: Working tree format 3
148
branch: Branch format 5
151
209
In the working tree:
164
222
first revision: %s
165
223
latest revision: %s
170
""" % (branch3.bzrdir.root_transport.base,
171
branch1.bzrdir.root_transport.base,
172
branch1.bzrdir.root_transport.base,
227
""" % (bound_tree._format.get_format_description(),
228
branch3._format.get_format_description(),
173
229
branch3.repository._format.get_format_description(),
174
230
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,
180
232
self.assertEqual('', err)
182
234
# Checkout standalone (same as above, but does not have parent set)
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)
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
187
237
branch4.bind(branch1)
188
238
branch4.bzrdir.open_workingtree().update()
189
out, err = self.runbzr('info checkout --verbose')
239
out, err = self.run_bzr('info checkout --verbose')
190
240
self.assertEqualDiff(
193
checkout of branch: %s
241
"""Checkout (format: knit)
243
checkout root: checkout
244
checkout of branch: standalone
196
247
control: Meta directory format 1
215
265
first revision: %s
216
266
latest revision: %s
221
""" % (branch4.bzrdir.root_transport.base,
222
branch1.bzrdir.root_transport.base,
223
branch4.repository._format.get_format_description(),
270
""" % (branch4.repository._format.get_format_description(),
224
271
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,
230
273
self.assertEqual('', err)
232
275
# Lightweight checkout (same as above, different branch and repository)
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)
276
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
241
277
branch5 = tree5.branch
242
out, err = self.runbzr('info lightcheckout')
278
out, err = self.run_bzr('info -v lightcheckout')
279
if "metaweave" in bzrdir.format_registry:
280
format_description = "knit or metaweave"
282
format_description = "knit"
243
283
self.assertEqualDiff(
245
light checkout root: %s
246
checkout of branch: %s
284
"""Lightweight checkout (format: %s)
286
light checkout root: lightcheckout
287
checkout of branch: standalone
249
290
control: Meta directory format 1
250
291
working tree: Working tree format 3
251
branch: Branch format 4
252
repository: Weave repository format 6
292
branch: Branch format 5
293
repository: Knit repository format 1
254
295
In the working tree:
451
472
first revision: %s
452
473
latest revision: %s
457
""" % (tree5.bzrdir.root_transport.base,
458
branch1.bzrdir.root_transport.base,
459
datestring_first, datestring_last,
477
""" % (format_description, datestring_first, datestring_last,), out)
461
478
self.assertEqual('', err)
463
480
def test_info_standalone_no_tree(self):
464
481
# create standalone branch without a working tree
482
format = bzrdir.format_registry.make_bzrdir('default')
465
483
branch = self.make_branch('branch')
466
484
repo = branch.repository
467
out, err = self.runbzr('info branch')
485
out, err = self.run_bzr('info branch -v')
468
486
self.assertEqualDiff(
487
"""Standalone branch (format: %s)
473
492
control: Meta directory format 1
474
branch: Branch format 5
483
""" % (branch.bzrdir.root_transport.base,
484
repo._format.get_format_description(),
501
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
502
format.get_branch_format().get_format_description(),
503
format.repository_format.get_format_description(),
486
505
self.assertEqual('', err)
488
507
def test_info_shared_repository(self):
489
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
490
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
508
format = bzrdir.format_registry.make_bzrdir('knit')
491
509
transport = self.get_transport()
493
511
# Create shared repository
494
repo = self.make_repository('repo', shared=True)
512
repo = self.make_repository('repo', shared=True, format=format)
495
513
repo.set_make_working_trees(False)
496
out, err = self.runbzr('info repo')
514
out, err = self.run_bzr('info -v repo')
497
515
self.assertEqualDiff(
516
"""Shared repository (format: dirstate or dirstate-tags or knit)
499
518
shared repository: %s
502
521
control: Meta directory format 1
508
""" % (repo.bzrdir.root_transport.base,
509
repo._format.get_format_description(),
526
""" % ('repo', format.repository_format.get_format_description(),
511
528
self.assertEqual('', err)
513
530
# Create branch inside shared repository
514
531
repo.bzrdir.root_transport.mkdir('branch')
515
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
516
out, err = self.runbzr('info repo/branch')
532
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
534
out, err = self.run_bzr('info -v repo/branch')
517
535
self.assertEqualDiff(
519
shared repository: %s
520
repository branch: branch
536
"""Repository branch (format: dirstate or knit)
538
shared repository: repo
539
repository branch: repo/branch
523
542
control: Meta directory format 1
524
branch: Branch format 5
533
""" % (repo.bzrdir.root_transport.base,
534
repo._format.get_format_description(),
551
""" % (format.get_branch_format().get_format_description(),
552
format.repository_format.get_format_description(),
536
554
self.assertEqual('', err)
538
556
# Create lightweight checkout
539
557
transport.mkdir('tree')
540
558
transport.mkdir('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()
559
tree2 = branch1.create_checkout('tree/lightcheckout',
545
561
branch2 = tree2.branch
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)
562
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
563
shared_repo=repo, repo_branch=branch1, verbose=True)
581
565
# Create normal checkout
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
tree3 = branch1.create_checkout('tree/checkout')
567
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
569
light_checkout=False, repo_branch=branch1)
621
570
# Update lightweight checkout
622
571
self.build_tree(['tree/lightcheckout/a'])
624
573
tree2.commit('commit one')
625
574
rev = repo.get_revision(branch2.revision_history()[0])
626
datestring_first = format_date(rev.timestamp, rev.timezone)
627
out, err = self.runbzr('info tree/lightcheckout --verbose')
575
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
576
out, err = self.run_bzr('info tree/lightcheckout --verbose')
628
577
self.assertEqualDiff(
630
light checkout root: %s
631
shared repository: %s
632
repository branch: branch
578
"""Lightweight checkout (format: %s)
580
light checkout root: tree/lightcheckout
581
checkout of branch: repo/branch
582
shared repository: repo
635
585
control: Meta directory format 1
636
working tree: Working tree format 3
637
branch: Branch format 5
586
working tree: Working tree format 6
640
590
In the working tree:
737
680
first revision: %s
738
681
latest revision: %s
743
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
744
repo._format.get_format_description(),
685
""" % (format.get_branch_format().get_format_description(),
686
format.repository_format.get_format_description(),
745
687
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,
750
689
self.assertEqual('', err)
751
690
tree3.commit('commit two')
753
692
# Out of date lightweight checkout
754
693
rev = repo.get_revision(branch1.revision_history()[-1])
755
datestring_last = format_date(rev.timestamp, rev.timezone)
756
out, err = self.runbzr('info tree/lightcheckout --verbose')
694
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
695
out, err = self.run_bzr('info tree/lightcheckout --verbose')
757
696
self.assertEqualDiff(
759
light checkout root: %s
760
shared repository: %s
761
repository branch: branch
697
"""Lightweight checkout (format: %s)
699
light checkout root: tree/lightcheckout
700
checkout of branch: repo/branch
701
shared repository: repo
764
704
control: Meta directory format 1
765
working tree: Working tree format 3
766
branch: Branch format 5
705
working tree: Working tree format 6
769
709
Working tree is out of date: missing 1 revision.
785
724
first revision: %s
786
725
latest revision: %s
791
""" % (tree2.bzrdir.root_transport.base,
792
repo.bzrdir.root_transport.base,
793
repo._format.get_format_description(),
729
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
730
format.repository_format.get_format_description(),
794
731
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,
799
733
self.assertEqual('', err)
801
735
# Show info about shared branch
802
out, err = self.runbzr('info repo/branch --verbose')
736
out, err = self.run_bzr('info repo/branch --verbose')
803
737
self.assertEqualDiff(
805
shared repository: %s
806
repository branch: branch
738
"""Repository branch (format: dirstate or knit)
740
shared repository: repo
741
repository branch: repo/branch
809
744
control: Meta directory format 1
810
branch: Branch format 5
817
751
first revision: %s
818
752
latest revision: %s
823
""" % (repo.bzrdir.root_transport.base,
824
repo._format.get_format_description(),
756
""" % (format.get_branch_format().get_format_description(),
757
format.repository_format.get_format_description(),
825
758
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,
830
760
self.assertEqual('', err)
832
762
# Show info about repository with revisions
833
out, err = self.runbzr('info repo')
763
out, err = self.run_bzr('info -v repo')
834
764
self.assertEqualDiff(
836
shared repository: %s
765
"""Shared repository (format: dirstate or dirstate-tags or knit)
767
shared repository: repo
839
770
control: Meta directory format 1
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,
775
""" % (format.repository_format.get_format_description(),
851
777
self.assertEqual('', err)
853
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
855
779
def test_info_shared_repository_with_trees(self):
856
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
857
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
780
format = bzrdir.format_registry.make_bzrdir('knit')
858
781
transport = self.get_transport()
860
783
# Create shared repository with working trees
861
repo = self.make_repository('repo', shared=True)
784
repo = self.make_repository('repo', shared=True, format=format)
862
785
repo.set_make_working_trees(True)
863
out, err = self.runbzr('info repo')
786
out, err = self.run_bzr('info -v repo')
864
787
self.assertEqualDiff(
866
shared repository: %s
788
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
790
shared repository: repo
869
793
control: Meta directory format 1
1112
1014
control = repo.bzrdir
1113
1015
branch = control.create_branch()
1114
1016
control.create_workingtree()
1115
out, err = self.runbzr('info repo')
1017
out, err = self.run_bzr('info -v repo')
1116
1018
self.assertEqualDiff(
1118
shared repository: %s
1119
repository checkout: .
1019
"""Repository tree (format: knit)
1021
shared repository: repo
1022
repository branch: repo
1122
1025
control: Meta directory format 1
1123
1026
working tree: Working tree format 3
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)
1030
In the working tree:
1038
0 versioned subdirectories
1045
""" % (format.get_branch_format().get_format_description(),
1046
format.repository_format.get_format_description(),
1048
self.assertEqual('', err)
1050
def test_info_repository_hook(self):
1051
format = bzrdir.format_registry.make_bzrdir('knit')
1052
def repo_info(repo, stats, outf):
1053
outf.write("more info\n")
1054
info.hooks.install_named_hook('repository', repo_info, None)
1055
# Create shared repository with working trees
1056
repo = self.make_repository('repo', shared=True, format=format)
1057
out, err = self.run_bzr('info -v repo')
1058
self.assertEqualDiff(
1059
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1061
shared repository: repo
1064
control: Meta directory format 1
1067
Create working tree for new branches inside the repository.
1072
""" % (format.repository_format.get_format_description(),
1074
self.assertEqual('', err)
1076
def assertCheckoutStatusOutput(self,
1077
command_string, lco_tree, shared_repo=None,
1080
branch_locked=False, repo_locked=False,
1082
light_checkout=True,
1083
checkout_root=None):
1084
"""Check the output of info in a checkout.
1086
This is not quite a mirror of the info code: rather than using the
1087
tree being examined to predict output, it uses a bunch of flags which
1088
allow us, the test writers, to document what *should* be present in
1089
the output. Removing this separation would remove the value of the
1092
:param path: the path to the light checkout.
1093
:param lco_tree: the tree object for the light checkout.
1094
:param shared_repo: A shared repository is in use, expect that in
1096
:param repo_branch: A branch in a shared repository for non light
1098
:param tree_locked: If true, expect the tree to be locked.
1099
:param branch_locked: If true, expect the branch to be locked.
1100
:param repo_locked: If true, expect the repository to be locked.
1101
Note that the lco_tree.branch.repository is inspected, and if is not
1102
actually locked then this parameter is overridden. This is because
1103
pack repositories do not have any public API for obtaining an
1104
exclusive repository wide lock.
1105
:param verbose: verbosity level: 2 or higher to show committers
1107
def friendly_location(url):
1108
path = urlutils.unescape_for_display(url, 'ascii')
1110
return osutils.relpath(osutils.getcwd(), path)
1111
except errors.PathNotChild:
1115
# We expect this to fail because of locking errors.
1116
# (A write-locked file cannot be read-locked
1117
# in the different process -- either on win32 or on linux).
1118
# This should be removed when the locking errors are fixed.
1119
self.expectFailure('OS locks are exclusive '
1120
'for different processes (Bug #174055)',
1121
self.run_bzr_subprocess,
1122
'info ' + command_string)
1123
out, err = self.run_bzr('info %s' % command_string)
1125
(True, True): 'Lightweight checkout',
1126
(True, False): 'Repository checkout',
1127
(False, True): 'Lightweight checkout',
1128
(False, False): 'Checkout',
1129
}[(shared_repo is not None, light_checkout)]
1130
format = {True: self._repo_strings,
1131
False: 'unnamed'}[light_checkout]
1133
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1134
if repo_locked or branch_locked or tree_locked:
1135
def locked_message(a_bool):
1140
expected_lock_output = (
1143
" working tree: %s\n"
1145
" repository: %s\n" % (
1146
locked_message(tree_locked),
1147
locked_message(branch_locked),
1148
locked_message(repo_locked)))
1150
expected_lock_output = ''
1154
tree_data = (" light checkout root: %s\n" %
1155
friendly_location(lco_tree.bzrdir.root_transport.base))
1157
if lco_tree.branch.get_bound_location() is not None:
1158
tree_data += ("%s checkout root: %s\n" % (extra_space,
1159
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1160
if shared_repo is not None:
1162
" checkout of branch: %s\n"
1163
" shared repository: %s\n" %
1164
(friendly_location(repo_branch.bzrdir.root_transport.base),
1165
friendly_location(shared_repo.bzrdir.root_transport.base)))
1166
elif repo_branch is not None:
1168
"%s checkout of branch: %s\n" %
1170
friendly_location(repo_branch.bzrdir.root_transport.base)))
1172
branch_data = (" checkout of branch: %s\n" %
1173
lco_tree.branch.bzrdir.root_transport.base)
1176
verbose_info = ' 0 committers\n'
1180
self.assertEqualDiff(
1185
control: Meta directory format 1
1190
In the working tree:
1198
0 versioned subdirectories
1209
lco_tree._format.get_format_description(),
1210
lco_tree.branch._format.get_format_description(),
1211
lco_tree.branch.repository._format.get_format_description(),
1212
expected_lock_output,
1215
self.assertEqual('', err)
1150
1217
def test_info_locking(self):
1151
1218
transport = self.get_transport()
1152
1219
# Create shared repository with a branch
1153
1220
repo = self.make_repository('repo', shared=True,
1154
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1221
format=bzrdir.BzrDirMetaFormat1())
1155
1222
repo.set_make_working_trees(False)
1156
1223
repo.bzrdir.root_transport.mkdir('branch')
1157
1224
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1158
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1225
format=bzrdir.BzrDirMetaFormat1())
1159
1226
# Do a heavy checkout
1160
1227
transport.mkdir('tree')
1161
1228
transport.mkdir('tree/checkout')
1162
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1163
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1229
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1230
format=bzrdir.BzrDirMetaFormat1())
1164
1231
co_branch.bind(repo_branch)
1165
1232
# Do a light checkout of the heavy one
1166
1233
transport.mkdir('tree/lightcheckout')
1167
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1168
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1234
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1235
branch.BranchReferenceFormat().initialize(lco_dir,
1236
target_branch=co_branch)
1169
1237
lco_dir.create_workingtree()
1170
1238
lco_tree = lco_dir.open_workingtree()
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
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1245
repo_branch=repo_branch,
1246
verbose=True, light_checkout=True)
1210
1248
lco_tree.branch.repository.lock_write()
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()
1250
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1251
lco_tree, repo_branch=repo_branch,
1252
repo_locked=True, verbose=True, light_checkout=True)
1254
lco_tree.branch.repository.unlock()
1251
1256
lco_tree.branch.lock_write()
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()
1258
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1262
repo_branch=repo_branch,
1265
lco_tree.branch.unlock()
1292
1267
lco_tree.lock_write()
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)
1269
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1270
lco_tree, repo_branch=repo_branch,
1333
1278
lco_tree.lock_write()
1334
1279
lco_tree.branch.repository.unlock()
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()
1281
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1282
lco_tree, repo_branch=repo_branch,
1287
lco_tree.branch.repository.lock_write()
1376
1290
lco_tree.lock_write()
1377
1291
lco_tree.branch.unlock()
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()
1293
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1294
lco_tree, repo_branch=repo_branch,
1298
lco_tree.branch.lock_write()
1419
1301
lco_tree.lock_write()
1420
1302
lco_tree.branch.unlock()
1421
1303
lco_tree.branch.repository.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()
1305
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1306
lco_tree, repo_branch=repo_branch,
1311
lco_tree.branch.repository.unlock()
1312
lco_tree.branch.lock_write()
1464
1315
lco_tree.branch.lock_write()
1465
1316
lco_tree.branch.repository.unlock()
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()
1507
def test_info_locking_oslocks(self):
1508
tree = self.make_branch_and_tree('branch',
1509
format=bzrlib.bzrdir.BzrDirFormat6())
1511
# Test all permutations of locking the working tree, branch and repository
1512
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1513
# implemented by raising NotImplementedError and get_physical_lock_status()
1514
# always returns false. This makes bzr info hide the lock status. (Olaf)
1518
out, err = self.runbzr('info branch')
1519
self.assertEqualDiff(
1524
control: All-in-one format 6
1525
working tree: Working tree format 2
1526
branch: Branch format 4
1529
In the working tree:
1537
0 versioned subdirectories
1545
""" % (tree.bzrdir.root_transport.base,
1546
tree.branch.repository._format.get_format_description(),
1548
self.assertEqual('', err)
1551
out, err = self.runbzr('info branch')
1552
self.assertEqualDiff(
1557
control: All-in-one format 6
1558
working tree: Working tree format 2
1559
branch: Branch format 4
1562
In the working tree:
1570
0 versioned subdirectories
1578
""" % (tree.bzrdir.root_transport.base,
1579
tree.branch.repository._format.get_format_description(),
1581
self.assertEqual('', err)
1318
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1319
lco_tree, repo_branch=repo_branch,
1323
lco_tree.branch.repository.lock_write()
1324
lco_tree.branch.unlock()
1326
if sys.platform == 'win32':
1327
self.knownFailure('Win32 cannot run "bzr info"'
1328
' when the tree is locked.')
1330
def test_info_stacked(self):
1331
# We have a mainline
1332
trunk_tree = self.make_branch_and_tree('mainline',
1334
trunk_tree.commit('mainline')
1335
# and a branch from it which is stacked
1336
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1337
out, err = self.run_bzr('info newbranch')
1339
"""Standalone tree (format: 1.6)
1341
branch root: newbranch
1344
parent branch: mainline
1345
stacked on: mainline
1347
self.assertEqual("", err)