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."""
24
from bzrlib import repository
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
if sys.platform == "win32":
34
location = "C:/i/do/not/exist/"
36
location = "/i/do/not/exist/"
37
out, err = self.runbzr('info '+location, retcode=3)
42
self.vfs_transport_factory = memory.MemoryServer
43
location = self.get_url()
44
out, err = self.run_bzr('info '+location, retcode=3)
38
45
self.assertEqual(out, '')
39
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
41
48
def test_info_standalone(self):
42
49
transport = self.get_transport()
44
51
# Create initial standalone branch
45
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
46
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
47
tree1 = self.make_branch_and_tree('standalone')
48
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
52
tree1 = self.make_branch_and_tree('standalone', 'knit')
49
53
self.build_tree(['standalone/a'])
51
55
branch1 = tree1.branch
52
out, err = self.runbzr('info standalone')
58
control: All-in-one format 6
59
working tree: Working tree format 2
60
branch: Branch format 4
61
repository: Weave repository format 6
71
0 versioned subdirectories
79
""" % 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
80
126
self.assertEqual('', err)
81
127
tree1.commit('commit one')
82
128
rev = branch1.repository.get_revision(branch1.revision_history()[0])
83
datestring_first = format_date(rev.timestamp, rev.timezone)
129
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
85
131
# Branch standalone with push location
86
132
branch2 = branch1.bzrdir.sprout('branch').open_branch()
87
133
branch2.set_push_location(branch1.bzrdir.root_transport.base)
88
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
98
control: All-in-one format 6
99
working tree: Working tree format 2
100
branch: Branch format 4
101
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
103
163
In the working tree:
117
176
first revision: %s
118
177
latest revision: %s
123
""" % (branch2.bzrdir.root_transport.base,
124
branch1.bzrdir.root_transport.base,
125
branch1.bzrdir.root_transport.base,
126
datestring_first, datestring_first,
127
# poking at _revision_store isn't all that clean, but neither is
128
# having the ui test dependent on the exact overhead of a given store.
129
branch2.repository._revision_store.total_size(
130
branch2.repository.get_transaction())[1] / 1024,
181
""" % (datestring_first, datestring_first,
132
183
self.assertEqual('', err)
134
185
# Branch and bind to standalone, needs upgrade to metadir
135
186
# (creates backup as unknown)
136
187
branch1.bzrdir.sprout('bound')
137
knit1_format = bzrlib.bzrdir.BzrDirMetaFormat1()
138
knit1_format.repository_format = repository.RepositoryFormatKnit1()
139
bzrlib.upgrade.upgrade('bound', knit1_format)
140
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()
141
191
branch3.bind(branch1)
142
192
bound_tree = branch3.bzrdir.open_workingtree()
143
out, err = self.runbzr('info bound')
193
out, err = self.run_bzr('info -v bound')
144
194
self.assertEqualDiff(
147
checkout of branch: %s
195
"""Checkout (format: knit)
198
checkout of branch: standalone
149
200
Related branches:
201
parent branch: standalone
153
204
control: Meta directory format 1
155
branch: Branch format 5
158
209
In the working tree:
171
222
first revision: %s
172
223
latest revision: %s
177
""" % (branch3.bzrdir.root_transport.base,
178
branch1.bzrdir.root_transport.base,
179
branch1.bzrdir.root_transport.base,
180
bound_tree._format.get_format_description(),
227
""" % (bound_tree._format.get_format_description(),
228
branch3._format.get_format_description(),
181
229
branch3.repository._format.get_format_description(),
182
230
datestring_first, datestring_first,
183
# poking at _revision_store isn't all that clean, but neither is
184
# having the ui test dependent on the exact overhead of a given store.
185
branch3.repository._revision_store.total_size(
186
branch3.repository.get_transaction())[1] / 1024,
188
232
self.assertEqual('', err)
190
234
# Checkout standalone (same as above, but does not have parent set)
191
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
192
bzrlib.bzrdir.BzrDirFormat.set_default_format(knit1_format)
193
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout')
194
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
195
237
branch4.bind(branch1)
196
238
branch4.bzrdir.open_workingtree().update()
197
out, err = self.runbzr('info checkout --verbose')
239
out, err = self.run_bzr('info checkout --verbose')
198
240
self.assertEqualDiff(
201
checkout of branch: %s
241
"""Checkout (format: knit)
243
checkout root: checkout
244
checkout of branch: standalone
204
247
control: Meta directory format 1
223
265
first revision: %s
224
266
latest revision: %s
229
""" % (branch4.bzrdir.root_transport.base,
230
branch1.bzrdir.root_transport.base,
231
branch4.repository._format.get_format_description(),
270
""" % (branch4.repository._format.get_format_description(),
232
271
datestring_first, datestring_first,
233
# poking at _revision_store isn't all that clean, but neither is
234
# having the ui test dependent on the exact overhead of a given store.
235
branch4.repository._revision_store.total_size(
236
branch4.repository.get_transaction())[1] / 1024,
238
273
self.assertEqual('', err)
240
275
# Lightweight checkout (same as above, different branch and repository)
241
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
242
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
243
transport.mkdir('lightcheckout')
244
dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
245
bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
246
dir5.create_workingtree()
247
tree5 = dir5.open_workingtree()
248
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
276
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
249
277
branch5 = tree5.branch
250
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"
251
283
self.assertEqualDiff(
253
light checkout root: %s
254
checkout of branch: %s
284
"""Lightweight checkout (format: %s)
286
light checkout root: lightcheckout
287
checkout of branch: standalone
257
290
control: Meta directory format 1
258
291
working tree: Working tree format 3
259
branch: Branch format 4
260
repository: Weave repository format 6
292
branch: Branch format 5
293
repository: Knit repository format 1
262
295
In the working tree:
290
319
tree1.commit('commit two')
291
320
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
292
datestring_last = format_date(rev.timestamp, rev.timezone)
321
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
294
323
# Out of date branched standalone branch will not be detected
295
out, err = self.runbzr('info branch')
324
out, err = self.run_bzr('info -v branch')
296
325
self.assertEqualDiff(
326
"""Standalone tree (format: knit)
300
330
Related branches:
302
publish to branch: %s
331
push branch: standalone
332
parent branch: standalone
305
control: All-in-one format 6
306
working tree: Working tree format 2
307
branch: Branch format 4
308
repository: Weave repository format 6
335
control: Meta directory format 1
336
working tree: Working tree format 3
337
branch: Branch format 5
338
repository: Knit repository format 1
310
340
In the working tree:
323
353
first revision: %s
324
354
latest revision: %s
329
""" % (branch2.bzrdir.root_transport.base,
330
branch1.bzrdir.root_transport.base,
331
branch1.bzrdir.root_transport.base,
332
datestring_first, datestring_first,
358
""" % (datestring_first, datestring_first,
334
360
self.assertEqual('', err)
336
362
# Out of date bound branch
337
out, err = self.runbzr('info bound')
363
out, err = self.run_bzr('info -v bound')
338
364
self.assertEqualDiff(
341
checkout of branch: %s
365
"""Checkout (format: knit)
368
checkout of branch: standalone
343
370
Related branches:
371
parent branch: standalone
347
374
control: Meta directory format 1
367
394
first revision: %s
368
395
latest revision: %s
373
""" % (branch3.bzrdir.root_transport.base,
374
branch1.bzrdir.root_transport.base,
375
branch1.bzrdir.root_transport.base,
376
branch3.repository._format.get_format_description(),
399
""" % (branch3.repository._format.get_format_description(),
377
400
datestring_first, datestring_first,
378
# poking at _revision_store isn't all that clean, but neither is
379
# having the ui test dependent on the exact overhead of a given store.
380
branch3.repository._revision_store.total_size(
381
branch3.repository.get_transaction())[1] / 1024,
383
402
self.assertEqual('', err)
385
404
# Out of date checkout
386
out, err = self.runbzr('info checkout')
405
out, err = self.run_bzr('info -v checkout')
387
406
self.assertEqualDiff(
390
checkout of branch: %s
407
"""Checkout (format: knit)
409
checkout root: checkout
410
checkout of branch: standalone
393
413
control: Meta directory format 1
413
433
first revision: %s
414
434
latest revision: %s
419
""" % (branch4.bzrdir.root_transport.base,
420
branch1.bzrdir.root_transport.base,
421
branch4.repository._format.get_format_description(),
438
""" % (branch4.repository._format.get_format_description(),
422
439
datestring_first, datestring_first,
423
# poking at _revision_store isn't all that clean, but neither is
424
# having the ui test dependent on the exact overhead of a given store.
425
branch4.repository._revision_store.total_size(
426
branch4.repository.get_transaction())[1] / 1024,
428
441
self.assertEqual('', err)
430
443
# Out of date lightweight checkout
431
out, err = self.runbzr('info lightcheckout --verbose')
444
out, err = self.run_bzr('info lightcheckout --verbose')
432
445
self.assertEqualDiff(
434
light checkout root: %s
435
checkout of branch: %s
446
"""Lightweight checkout (format: %s)
448
light checkout root: lightcheckout
449
checkout of branch: standalone
438
452
control: Meta directory format 1
439
453
working tree: Working tree format 3
440
branch: Branch format 4
441
repository: Weave repository format 6
454
branch: Branch format 5
455
repository: Knit repository format 1
443
457
Working tree is out of date: missing 1 revision.
459
472
first revision: %s
460
473
latest revision: %s
465
""" % (tree5.bzrdir.root_transport.base,
466
branch1.bzrdir.root_transport.base,
467
datestring_first, datestring_last,
477
""" % (format_description, datestring_first, datestring_last,), out)
469
478
self.assertEqual('', err)
471
480
def test_info_standalone_no_tree(self):
472
481
# create standalone branch without a working tree
482
format = bzrdir.format_registry.make_bzrdir('default')
473
483
branch = self.make_branch('branch')
474
484
repo = branch.repository
475
out, err = self.runbzr('info branch')
485
out, err = self.run_bzr('info branch -v')
476
486
self.assertEqualDiff(
487
"""Standalone branch (format: %s)
481
492
control: Meta directory format 1
482
branch: Branch format 5
491
""" % (branch.bzrdir.root_transport.base,
492
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(),
494
505
self.assertEqual('', err)
496
507
def test_info_shared_repository(self):
497
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
498
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
508
format = bzrdir.format_registry.make_bzrdir('knit')
499
509
transport = self.get_transport()
501
511
# Create shared repository
502
repo = self.make_repository('repo', shared=True)
512
repo = self.make_repository('repo', shared=True, format=format)
503
513
repo.set_make_working_trees(False)
504
out, err = self.runbzr('info repo')
514
out, err = self.run_bzr('info -v repo')
505
515
self.assertEqualDiff(
516
"""Shared repository (format: dirstate or dirstate-tags or knit)
507
518
shared repository: %s
510
521
control: Meta directory format 1
516
""" % (repo.bzrdir.root_transport.base,
517
repo._format.get_format_description(),
526
""" % ('repo', format.repository_format.get_format_description(),
519
528
self.assertEqual('', err)
521
530
# Create branch inside shared repository
522
531
repo.bzrdir.root_transport.mkdir('branch')
523
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
524
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')
525
535
self.assertEqualDiff(
527
shared repository: %s
528
repository branch: branch
536
"""Repository branch (format: dirstate or knit)
538
shared repository: repo
539
repository branch: repo/branch
531
542
control: Meta directory format 1
532
branch: Branch format 5
541
""" % (repo.bzrdir.root_transport.base,
542
repo._format.get_format_description(),
551
""" % (format.get_branch_format().get_format_description(),
552
format.repository_format.get_format_description(),
544
554
self.assertEqual('', err)
546
556
# Create lightweight checkout
547
557
transport.mkdir('tree')
548
558
transport.mkdir('tree/lightcheckout')
549
dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
550
bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
551
dir2.create_workingtree()
552
tree2 = dir2.open_workingtree()
559
tree2 = branch1.create_checkout('tree/lightcheckout',
553
561
branch2 = tree2.branch
554
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
562
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
563
shared_repo=repo, repo_branch=branch1, verbose=True)
556
565
# Create normal checkout
557
566
tree3 = branch1.create_checkout('tree/checkout')
594
603
first revision: %s
595
604
latest revision: %s
600
""" % (tree2.bzrdir.root_transport.base,
601
repo.bzrdir.root_transport.base,
602
repo._format.get_format_description(),
608
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
609
format.repository_format.get_format_description(),
603
610
datestring_first, datestring_first,
604
# poking at _revision_store isn't all that clean, but neither is
605
# having the ui test dependent on the exact overhead of a given store.
606
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
608
612
self.assertEqual('', err)
610
614
# Out of date checkout
611
out, err = self.runbzr('info tree/checkout')
615
out, err = self.run_bzr('info -v tree/checkout')
612
616
self.assertEqualDiff(
615
checkout of branch: %s
617
"""Checkout (format: unnamed)
619
checkout root: tree/checkout
620
checkout of branch: repo/branch
618
623
control: Meta directory format 1
619
working tree: Working tree format 3
620
branch: Branch format 5
624
working tree: Working tree format 6
623
628
Branch is out of date: missing 1 revision.
677
680
first revision: %s
678
681
latest revision: %s
683
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
684
repo._format.get_format_description(),
685
""" % (format.get_branch_format().get_format_description(),
686
format.repository_format.get_format_description(),
685
687
datestring_first, datestring_first,
686
# poking at _revision_store isn't all that clean, but neither is
687
# having the ui test dependent on the exact overhead of a given store.
688
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
690
689
self.assertEqual('', err)
691
690
tree3.commit('commit two')
693
692
# Out of date lightweight checkout
694
693
rev = repo.get_revision(branch1.revision_history()[-1])
695
datestring_last = format_date(rev.timestamp, rev.timezone)
696
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')
697
696
self.assertEqualDiff(
699
light checkout root: %s
700
shared repository: %s
701
repository branch: branch
697
"""Lightweight checkout (format: %s)
699
light checkout root: tree/lightcheckout
700
checkout of branch: repo/branch
701
shared repository: repo
704
704
control: Meta directory format 1
705
working tree: Working tree format 3
706
branch: Branch format 5
705
working tree: Working tree format 6
709
709
Working tree is out of date: missing 1 revision.
725
724
first revision: %s
726
725
latest revision: %s
731
""" % (tree2.bzrdir.root_transport.base,
732
repo.bzrdir.root_transport.base,
733
repo._format.get_format_description(),
729
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
730
format.repository_format.get_format_description(),
734
731
datestring_first, datestring_last,
735
# poking at _revision_store isn't all that clean, but neither is
736
# having the ui test dependent on the exact overhead of a given store.
737
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
739
733
self.assertEqual('', err)
741
735
# Show info about shared branch
742
out, err = self.runbzr('info repo/branch --verbose')
736
out, err = self.run_bzr('info repo/branch --verbose')
743
737
self.assertEqualDiff(
745
shared repository: %s
746
repository branch: branch
738
"""Repository branch (format: dirstate or knit)
740
shared repository: repo
741
repository branch: repo/branch
749
744
control: Meta directory format 1
750
branch: Branch format 5
757
751
first revision: %s
758
752
latest revision: %s
763
""" % (repo.bzrdir.root_transport.base,
764
repo._format.get_format_description(),
756
""" % (format.get_branch_format().get_format_description(),
757
format.repository_format.get_format_description(),
765
758
datestring_first, datestring_last,
766
# poking at _revision_store isn't all that clean, but neither is
767
# having the ui test dependent on the exact overhead of a given store.
768
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
770
760
self.assertEqual('', err)
772
762
# Show info about repository with revisions
773
out, err = self.runbzr('info repo')
763
out, err = self.run_bzr('info -v repo')
774
764
self.assertEqualDiff(
776
shared repository: %s
765
"""Shared repository (format: dirstate or dirstate-tags or knit)
767
shared repository: repo
779
770
control: Meta directory format 1
785
""" % (repo.bzrdir.root_transport.base,
786
repo._format.get_format_description(),
787
# poking at _revision_store isn't all that clean, but neither is
788
# having the ui test dependent on the exact overhead of a given store.
789
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
775
""" % (format.repository_format.get_format_description(),
791
777
self.assertEqual('', err)
793
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
795
779
def test_info_shared_repository_with_trees(self):
796
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
797
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
780
format = bzrdir.format_registry.make_bzrdir('knit')
798
781
transport = self.get_transport()
800
783
# Create shared repository with working trees
801
repo = self.make_repository('repo', shared=True)
784
repo = self.make_repository('repo', shared=True, format=format)
802
785
repo.set_make_working_trees(True)
803
out, err = self.runbzr('info repo')
786
out, err = self.run_bzr('info -v repo')
804
787
self.assertEqualDiff(
806
shared repository: %s
788
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
790
shared repository: repo
809
793
control: Meta directory format 1
812
796
Create working tree for new branches inside the repository.
817
""" % (repo.bzrdir.root_transport.base,
818
repo._format.get_format_description(),
800
""" % (format.repository_format.get_format_description(),
820
802
self.assertEqual('', err)
822
804
# Create two branches
823
805
repo.bzrdir.root_transport.mkdir('branch1')
824
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
806
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
825
808
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
827
810
# Empty first branch
828
out, err = self.runbzr('info repo/branch1 --verbose')
811
out, err = self.run_bzr('info repo/branch1 --verbose')
829
812
self.assertEqualDiff(
831
shared repository: %s
832
repository checkout: branch1
813
"""Repository tree (format: knit)
815
shared repository: repo
816
repository branch: repo/branch1
835
819
control: Meta directory format 1
836
820
working tree: Working tree format 3
837
branch: Branch format 5
840
824
In the working tree:
894
877
first revision: %s
895
878
latest revision: %s
900
""" % (repo.bzrdir.root_transport.base,
901
repo._format.get_format_description(),
882
""" % (format.get_branch_format().get_format_description(),
883
format.repository_format.get_format_description(),
902
884
datestring_first, datestring_first,
903
# poking at _revision_store isn't all that clean, but neither is
904
# having the ui test dependent on the exact overhead of a given store.
905
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
907
886
self.assertEqual('', err)
909
888
# Out of date second branch
910
out, err = self.runbzr('info repo/branch2 --verbose')
889
out, err = self.run_bzr('info repo/branch2 --verbose')
911
890
self.assertEqualDiff(
913
shared repository: %s
914
repository checkout: branch2
891
"""Repository tree (format: knit)
893
shared repository: repo
894
repository branch: repo/branch2
916
896
Related branches:
897
parent branch: repo/branch1
920
900
control: Meta directory format 1
921
901
working tree: Working tree format 3
922
branch: Branch format 5
925
905
In the working tree:
942
""" % (repo.bzrdir.root_transport.base,
943
branch1.bzrdir.root_transport.base,
944
repo._format.get_format_description(),
945
# poking at _revision_store isn't all that clean, but neither is
946
# having the ui test dependent on the exact overhead of a given store.
947
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
920
""" % (format.get_branch_format().get_format_description(),
921
format.repository_format.get_format_description(),
949
923
self.assertEqual('', err)
951
925
# Update second branch
952
926
tree2 = branch2.bzrdir.open_workingtree()
953
927
tree2.pull(branch1)
954
out, err = self.runbzr('info repo/branch2')
928
out, err = self.run_bzr('info -v repo/branch2')
955
929
self.assertEqualDiff(
957
shared repository: %s
958
repository checkout: branch2
930
"""Repository tree (format: knit)
932
shared repository: repo
933
repository branch: repo/branch2
960
935
Related branches:
936
parent branch: repo/branch1
964
939
control: Meta directory format 1
965
940
working tree: Working tree format 3
966
branch: Branch format 5
969
944
In the working tree:
982
957
first revision: %s
983
958
latest revision: %s
988
""" % (repo.bzrdir.root_transport.base,
989
branch1.bzrdir.root_transport.base,
990
repo._format.get_format_description(),
962
""" % (format.get_branch_format().get_format_description(),
963
format.repository_format.get_format_description(),
991
964
datestring_first, datestring_first,
992
# poking at _revision_store isn't all that clean, but neither is
993
# having the ui test dependent on the exact overhead of a given store.
994
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
996
966
self.assertEqual('', err)
998
968
# Show info about repository with revisions
999
out, err = self.runbzr('info repo')
969
out, err = self.run_bzr('info -v repo')
1000
970
self.assertEqualDiff(
1002
shared repository: %s
971
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
973
shared repository: repo
1005
976
control: Meta directory format 1
1008
979
Create working tree for new branches inside the repository.
1013
""" % (repo.bzrdir.root_transport.base,
1014
repo._format.get_format_description(),
1015
# poking at _revision_store isn't all that clean, but neither is
1016
# having the ui test dependent on the exact overhead of a given store.
1017
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
983
""" % (format.repository_format.get_format_description(),
1020
986
self.assertEqual('', err)
1022
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1024
988
def test_info_shared_repository_with_tree_in_root(self):
1025
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1026
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
989
format = bzrdir.format_registry.make_bzrdir('knit')
1027
990
transport = self.get_transport()
1029
992
# Create shared repository with working trees
1030
repo = self.make_repository('repo', shared=True)
993
repo = self.make_repository('repo', shared=True, format=format)
1031
994
repo.set_make_working_trees(True)
1032
out, err = self.runbzr('info repo')
995
out, err = self.run_bzr('info -v repo')
1033
996
self.assertEqualDiff(
1035
shared repository: %s
997
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
999
shared repository: repo
1038
1002
control: Meta directory format 1
1077
1040
Branch history:
1083
""" % (repo.bzrdir.root_transport.base,
1084
repo._format.get_format_description(),
1086
self.assertEqual('', err)
1088
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1090
def assertCheckoutStatusOutput(self,
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,
1091
1077
command_string, lco_tree, shared_repo=None,
1092
1078
repo_branch=None,
1093
1079
tree_locked=False,
1094
1080
branch_locked=False, repo_locked=False,
1096
light_checkout=True):
1097
"""Check the output of info in a light checkout tree.
1082
light_checkout=True,
1083
checkout_root=None):
1084
"""Check the output of info in a checkout.
1099
1086
This is not quite a mirror of the info code: rather than using the
1100
1087
tree being examined to predict output, it uses a bunch of flags which
1101
1088
allow us, the test writers, to document what *should* be present in
1102
1089
the output. Removing this separation would remove the value of the
1105
1092
:param path: the path to the light checkout.
1106
1093
:param lco_tree: the tree object for the light checkout.
1107
1094
:param shared_repo: A shared repository is in use, expect that in
1111
1098
:param tree_locked: If true, expect the tree to be locked.
1112
1099
:param branch_locked: If true, expect the branch to be locked.
1113
1100
:param repo_locked: If true, expect the repository to be locked.
1114
:param verbose: If true, expect verbose output
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
1116
out, err = self.runbzr('info %s' % command_string)
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()
1117
1134
if repo_locked or branch_locked or tree_locked:
1118
1135
def locked_message(a_bool):
1131
1148
locked_message(repo_locked)))
1133
1150
expected_lock_output = ''
1134
1153
if light_checkout:
1135
tree_data = (" light checkout root: %s" %
1136
lco_tree.bzrdir.root_transport.base)
1138
tree_data = (" checkout root: %s" %
1139
lco_tree.bzrdir.root_transport.base)
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)))
1140
1160
if shared_repo is not None:
1141
1161
branch_data = (
1142
" shared repository: %s\n"
1143
" repository branch: branch\n" %
1144
shared_repo.bzrdir.root_transport.base)
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)))
1145
1166
elif repo_branch is not None:
1146
1167
branch_data = (
1147
" checkout of branch: %s\n" %
1148
repo_branch.bzrdir.root_transport.base)
1168
"%s checkout of branch: %s\n" %
1170
friendly_location(repo_branch.bzrdir.root_transport.base)))
1150
branch_data = (" checkout of branch: %s\n" %
1172
branch_data = (" checkout of branch: %s\n" %
1151
1173
lco_tree.branch.bzrdir.root_transport.base)
1154
1176
verbose_info = ' 0 committers\n'
1156
1178
verbose_info = ''
1158
1180
self.assertEqualDiff(
1163
1185
control: Meta directory format 1
1164
1186
working tree: %s
1165
branch: Branch format 5
1168
1190
In the working tree:
1194
1218
transport = self.get_transport()
1195
1219
# Create shared repository with a branch
1196
1220
repo = self.make_repository('repo', shared=True,
1197
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1221
format=bzrdir.BzrDirMetaFormat1())
1198
1222
repo.set_make_working_trees(False)
1199
1223
repo.bzrdir.root_transport.mkdir('branch')
1200
1224
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1201
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1225
format=bzrdir.BzrDirMetaFormat1())
1202
1226
# Do a heavy checkout
1203
1227
transport.mkdir('tree')
1204
1228
transport.mkdir('tree/checkout')
1205
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1206
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1229
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1230
format=bzrdir.BzrDirMetaFormat1())
1207
1231
co_branch.bind(repo_branch)
1208
1232
# Do a light checkout of the heavy one
1209
1233
transport.mkdir('tree/lightcheckout')
1210
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1211
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)
1212
1237
lco_dir.create_workingtree()
1213
1238
lco_tree = lco_dir.open_workingtree()
1219
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1244
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1245
repo_branch=repo_branch,
1246
verbose=True, light_checkout=True)
1221
1248
lco_tree.branch.repository.lock_write()
1223
self.assertCheckoutStatusOutput('tree/lightcheckout',
1250
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1251
lco_tree, repo_branch=repo_branch,
1252
repo_locked=True, verbose=True, light_checkout=True)
1227
1254
lco_tree.branch.repository.unlock()
1229
1256
lco_tree.branch.lock_write()
1231
self.assertCheckoutStatusOutput('tree/lightcheckout',
1258
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1233
1260
branch_locked=True,
1262
repo_branch=repo_branch,
1236
1265
lco_tree.branch.unlock()
1238
1267
lco_tree.lock_write()
1240
self.assertCheckoutStatusOutput('tree/lightcheckout',
1269
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1270
lco_tree, repo_branch=repo_branch,
1242
1271
tree_locked=True,
1243
1272
branch_locked=True,
1246
1276
lco_tree.unlock()
1248
1278
lco_tree.lock_write()
1249
1279
lco_tree.branch.repository.unlock()
1251
self.assertCheckoutStatusOutput('tree/lightcheckout',
1281
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1282
lco_tree, repo_branch=repo_branch,
1253
1283
tree_locked=True,
1256
1287
lco_tree.branch.repository.lock_write()
1257
1288
lco_tree.unlock()
1282
1315
lco_tree.branch.lock_write()
1283
1316
lco_tree.branch.repository.unlock()
1285
self.assertCheckoutStatusOutput('tree/lightcheckout',
1318
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1319
lco_tree, repo_branch=repo_branch,
1289
1323
lco_tree.branch.repository.lock_write()
1290
1324
lco_tree.branch.unlock()
1292
def test_info_locking_oslocks(self):
1293
if sys.platform == "win32":
1294
raise TestSkipped("don't use oslocks on win32 in unix manner")
1296
tree = self.make_branch_and_tree('branch',
1297
format=bzrlib.bzrdir.BzrDirFormat6())
1299
# Test all permutations of locking the working tree, branch and repository
1300
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1301
# implemented by raising NotImplementedError and get_physical_lock_status()
1302
# always returns false. This makes bzr info hide the lock status. (Olaf)
1306
out, err = self.runbzr('info branch')
1307
self.assertEqualDiff(
1312
control: All-in-one format 6
1313
working tree: Working tree format 2
1314
branch: Branch format 4
1317
In the working tree:
1325
0 versioned subdirectories
1333
""" % (tree.bzrdir.root_transport.base,
1334
tree.branch.repository._format.get_format_description(),
1336
self.assertEqual('', err)
1339
out, err = self.runbzr('info branch')
1340
self.assertEqualDiff(
1345
control: All-in-one format 6
1346
working tree: Working tree format 2
1347
branch: Branch format 4
1350
In the working tree:
1358
0 versioned subdirectories
1366
""" % (tree.bzrdir.root_transport.base,
1367
tree.branch.repository._format.get_format_description(),
1369
self.assertEqual('', err)
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)