29
36
class TestInfo(ExternalBase):
39
ExternalBase.setUp(self)
40
self._repo_strings = "2a or development-subtree"
31
42
def test_info_non_existing(self):
32
43
if sys.platform == "win32":
33
44
location = "C:/i/do/not/exist/"
35
46
location = "/i/do/not/exist/"
36
out, err = self.runbzr('info '+location, retcode=3)
47
out, err = self.run_bzr('info '+location, retcode=3)
37
48
self.assertEqual(out, '')
38
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
49
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
40
51
def test_info_standalone(self):
41
52
transport = self.get_transport()
43
54
# Create initial standalone branch
44
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
45
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
46
tree1 = self.make_branch_and_tree('standalone')
47
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
55
tree1 = self.make_branch_and_tree('standalone', 'weave')
48
56
self.build_tree(['standalone/a'])
50
58
branch1 = tree1.branch
51
out, err = self.runbzr('info standalone')
57
control: All-in-one format 6
58
working tree: Working tree format 2
59
branch: Branch format 4
60
repository: Weave repository format 6
70
0 versioned subdirectories
78
""" % branch1.bzrdir.root_transport.base, out)
60
out, err = self.run_bzr('info standalone')
62
"""Standalone tree (format: weave)
64
branch root: standalone
66
self.assertEqual('', err)
68
# Standalone branch - verbose mode
69
out, err = self.run_bzr('info standalone -v')
71
"""Standalone tree (format: weave)
73
branch root: standalone
76
control: All-in-one format 6
77
working tree: Working tree format 2
78
branch: Branch format 4
79
repository: Weave repository format 6
89
0 versioned subdirectories
97
self.assertEqual('', err)
99
# Standalone branch - really verbose mode
100
out, err = self.run_bzr('info standalone -vv')
101
self.assertEqualDiff(
102
"""Standalone tree (format: weave)
104
branch root: standalone
107
control: All-in-one format 6
108
working tree: Working tree format 2
109
branch: Branch format 4
110
repository: Weave repository format 6
120
0 versioned subdirectories
79
129
self.assertEqual('', err)
80
130
tree1.commit('commit one')
81
131
rev = branch1.repository.get_revision(branch1.revision_history()[0])
84
134
# Branch standalone with push location
85
135
branch2 = branch1.bzrdir.sprout('branch').open_branch()
86
136
branch2.set_push_location(branch1.bzrdir.root_transport.base)
87
out, err = self.runbzr('info branch --verbose')
138
out, err = self.run_bzr('info branch')
139
self.assertEqualDiff(
140
"""Standalone tree (format: weave)
145
push branch: standalone
146
parent branch: standalone
148
self.assertEqual('', err)
150
out, err = self.run_bzr('info branch --verbose')
151
self.assertEqualDiff(
152
"""Standalone tree (format: weave)
157
push branch: standalone
158
parent branch: standalone
97
161
control: All-in-one format 6
116
179
first revision: %s
117
180
latest revision: %s
122
""" % (branch2.bzrdir.root_transport.base,
123
branch1.bzrdir.root_transport.base,
124
branch1.bzrdir.root_transport.base,
125
datestring_first, datestring_first,
126
# poking at _revision_store isn't all that clean, but neither is
127
# having the ui test dependent on the exact overhead of a given store.
128
branch2.repository._revision_store.total_size(
129
branch2.repository.get_transaction())[1] / 1024,
184
""" % (datestring_first, datestring_first,
131
186
self.assertEqual('', err)
133
188
# Branch and bind to standalone, needs upgrade to metadir
134
189
# (creates backup as unknown)
135
190
branch1.bzrdir.sprout('bound')
136
bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
137
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
191
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
192
upgrade.upgrade('bound', knit1_format)
193
branch3 = bzrdir.BzrDir.open('bound').open_branch()
138
194
branch3.bind(branch1)
139
195
bound_tree = branch3.bzrdir.open_workingtree()
140
out, err = self.runbzr('info bound')
196
out, err = self.run_bzr('info -v bound')
141
197
self.assertEqualDiff(
144
checkout of branch: %s
198
"""Checkout (format: knit)
201
checkout of branch: standalone
146
203
Related branches:
204
parent branch: standalone
150
207
control: Meta directory format 1
152
branch: Branch format 5
155
212
In the working tree:
168
225
first revision: %s
169
226
latest revision: %s
174
""" % (branch3.bzrdir.root_transport.base,
175
branch1.bzrdir.root_transport.base,
176
branch1.bzrdir.root_transport.base,
177
bound_tree._format.get_format_description(),
230
""" % (bound_tree._format.get_format_description(),
231
branch3._format.get_format_description(),
178
232
branch3.repository._format.get_format_description(),
179
233
datestring_first, datestring_first,
180
# poking at _revision_store isn't all that clean, but neither is
181
# having the ui test dependent on the exact overhead of a given store.
182
branch3.repository._revision_store.total_size(
183
branch3.repository.get_transaction())[1] / 1024,
185
235
self.assertEqual('', err)
187
237
# Checkout standalone (same as above, but does not have parent set)
188
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
189
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
190
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout')
191
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
238
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
192
240
branch4.bind(branch1)
193
241
branch4.bzrdir.open_workingtree().update()
194
out, err = self.runbzr('info checkout --verbose')
242
out, err = self.run_bzr('info checkout --verbose')
195
243
self.assertEqualDiff(
198
checkout of branch: %s
244
"""Checkout (format: knit)
246
checkout root: checkout
247
checkout of branch: standalone
201
250
control: Meta directory format 1
220
268
first revision: %s
221
269
latest revision: %s
226
""" % (branch4.bzrdir.root_transport.base,
227
branch1.bzrdir.root_transport.base,
228
branch4.repository._format.get_format_description(),
273
""" % (branch4.repository._format.get_format_description(),
229
274
datestring_first, datestring_first,
230
# poking at _revision_store isn't all that clean, but neither is
231
# having the ui test dependent on the exact overhead of a given store.
232
branch4.repository._revision_store.total_size(
233
branch4.repository.get_transaction())[1] / 1024,
235
276
self.assertEqual('', err)
237
278
# Lightweight checkout (same as above, different branch and repository)
238
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
239
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
240
transport.mkdir('lightcheckout')
241
dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
242
bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
243
dir5.create_workingtree()
244
tree5 = dir5.open_workingtree()
245
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
279
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
246
280
branch5 = tree5.branch
247
out, err = self.runbzr('info lightcheckout')
281
out, err = self.run_bzr('info -v lightcheckout')
248
282
self.assertEqualDiff(
250
light checkout root: %s
251
checkout of branch: %s
283
"""Lightweight checkout (format: %s)
285
light checkout root: lightcheckout
286
checkout of branch: standalone
254
289
control: Meta directory format 1
255
working tree: Working tree format 3
290
working tree: Working tree format 6
256
291
branch: Branch format 4
257
292
repository: Weave repository format 6
320
352
first revision: %s
321
353
latest revision: %s
326
""" % (branch2.bzrdir.root_transport.base,
327
branch1.bzrdir.root_transport.base,
328
branch1.bzrdir.root_transport.base,
329
datestring_first, datestring_first,
357
""" % (datestring_first, datestring_first,
331
359
self.assertEqual('', err)
333
361
# Out of date bound branch
334
out, err = self.runbzr('info bound')
362
out, err = self.run_bzr('info -v bound')
335
363
self.assertEqualDiff(
338
checkout of branch: %s
364
"""Checkout (format: knit)
367
checkout of branch: standalone
340
369
Related branches:
370
parent branch: standalone
344
373
control: Meta directory format 1
364
393
first revision: %s
365
394
latest revision: %s
370
""" % (branch3.bzrdir.root_transport.base,
371
branch1.bzrdir.root_transport.base,
372
branch1.bzrdir.root_transport.base,
373
branch3.repository._format.get_format_description(),
398
""" % (branch3.repository._format.get_format_description(),
374
399
datestring_first, datestring_first,
375
# poking at _revision_store isn't all that clean, but neither is
376
# having the ui test dependent on the exact overhead of a given store.
377
branch3.repository._revision_store.total_size(
378
branch3.repository.get_transaction())[1] / 1024,
380
401
self.assertEqual('', err)
382
403
# Out of date checkout
383
out, err = self.runbzr('info checkout')
404
out, err = self.run_bzr('info -v checkout')
384
405
self.assertEqualDiff(
387
checkout of branch: %s
406
"""Checkout (format: knit)
408
checkout root: checkout
409
checkout of branch: standalone
390
412
control: Meta directory format 1
410
432
first revision: %s
411
433
latest revision: %s
416
""" % (branch4.bzrdir.root_transport.base,
417
branch1.bzrdir.root_transport.base,
418
branch4.repository._format.get_format_description(),
437
""" % (branch4.repository._format.get_format_description(),
419
438
datestring_first, datestring_first,
420
# poking at _revision_store isn't all that clean, but neither is
421
# having the ui test dependent on the exact overhead of a given store.
422
branch4.repository._revision_store.total_size(
423
branch4.repository.get_transaction())[1] / 1024,
425
440
self.assertEqual('', err)
427
442
# Out of date lightweight checkout
428
out, err = self.runbzr('info lightcheckout --verbose')
443
out, err = self.run_bzr('info lightcheckout --verbose')
429
444
self.assertEqualDiff(
431
light checkout root: %s
432
checkout of branch: %s
445
"""Lightweight checkout (format: %s)
447
light checkout root: lightcheckout
448
checkout of branch: standalone
435
451
control: Meta directory format 1
436
working tree: Working tree format 3
452
working tree: Working tree format 6
437
453
branch: Branch format 4
438
454
repository: Weave repository format 6
456
471
first revision: %s
457
472
latest revision: %s
462
""" % (tree5.bzrdir.root_transport.base,
463
branch1.bzrdir.root_transport.base,
464
datestring_first, datestring_last,
476
""" % (self._repo_strings, datestring_first, datestring_last,), out)
466
477
self.assertEqual('', err)
468
479
def test_info_standalone_no_tree(self):
469
480
# create standalone branch without a working tree
481
format = bzrdir.format_registry.make_bzrdir('default')
470
482
branch = self.make_branch('branch')
471
483
repo = branch.repository
472
out, err = self.runbzr('info branch')
484
out, err = self.run_bzr('info branch -v')
473
485
self.assertEqualDiff(
486
"""Standalone branch (format: %s)
478
491
control: Meta directory format 1
479
branch: Branch format 5
488
""" % (branch.bzrdir.root_transport.base,
489
repo._format.get_format_description(),
500
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
501
format.get_branch_format().get_format_description(),
502
format.repository_format.get_format_description(),
491
504
self.assertEqual('', err)
493
506
def test_info_shared_repository(self):
494
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
495
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
507
format = bzrdir.format_registry.make_bzrdir('knit')
496
508
transport = self.get_transport()
498
510
# Create shared repository
499
repo = self.make_repository('repo', shared=True)
511
repo = self.make_repository('repo', shared=True, format=format)
500
512
repo.set_make_working_trees(False)
501
out, err = self.runbzr('info repo')
513
out, err = self.run_bzr('info -v repo')
502
514
self.assertEqualDiff(
515
"""Shared repository (format: dirstate or dirstate-tags or knit)
504
517
shared repository: %s
507
520
control: Meta directory format 1
513
""" % (repo.bzrdir.root_transport.base,
514
repo._format.get_format_description(),
525
""" % ('repo', format.repository_format.get_format_description(),
516
527
self.assertEqual('', err)
518
529
# Create branch inside shared repository
519
530
repo.bzrdir.root_transport.mkdir('branch')
520
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
521
out, err = self.runbzr('info repo/branch')
531
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
533
out, err = self.run_bzr('info -v repo/branch')
522
534
self.assertEqualDiff(
524
shared repository: %s
525
repository branch: branch
535
"""Repository branch (format: dirstate or knit)
537
shared repository: repo
538
repository branch: repo/branch
528
541
control: Meta directory format 1
529
branch: Branch format 5
538
""" % (repo.bzrdir.root_transport.base,
539
repo._format.get_format_description(),
550
""" % (format.get_branch_format().get_format_description(),
551
format.repository_format.get_format_description(),
541
553
self.assertEqual('', err)
543
555
# Create lightweight checkout
544
556
transport.mkdir('tree')
545
557
transport.mkdir('tree/lightcheckout')
546
dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
547
bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
548
dir2.create_workingtree()
549
tree2 = dir2.open_workingtree()
558
tree2 = branch1.create_checkout('tree/lightcheckout',
550
560
branch2 = tree2.branch
551
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
561
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
562
shared_repo=repo, repo_branch=branch1, verbose=True)
553
564
# Create normal checkout
554
565
tree3 = branch1.create_checkout('tree/checkout')
561
572
tree2.commit('commit one')
562
573
rev = repo.get_revision(branch2.revision_history()[0])
563
574
datestring_first = format_date(rev.timestamp, rev.timezone)
564
out, err = self.runbzr('info tree/lightcheckout --verbose')
575
out, err = self.run_bzr('info tree/lightcheckout --verbose')
565
576
self.assertEqualDiff(
567
light checkout root: %s
568
shared repository: %s
569
repository branch: branch
577
"""Lightweight checkout (format: %s)
579
light checkout root: tree/lightcheckout
580
checkout of branch: repo/branch
581
shared repository: repo
572
584
control: Meta directory format 1
573
working tree: Working tree format 3
574
branch: Branch format 5
585
working tree: Working tree format 6
577
589
In the working tree:
591
602
first revision: %s
592
603
latest revision: %s
597
""" % (tree2.bzrdir.root_transport.base,
598
repo.bzrdir.root_transport.base,
599
repo._format.get_format_description(),
607
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
608
format.repository_format.get_format_description(),
600
609
datestring_first, datestring_first,
601
# poking at _revision_store isn't all that clean, but neither is
602
# having the ui test dependent on the exact overhead of a given store.
603
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
605
611
self.assertEqual('', err)
607
613
# Out of date checkout
608
out, err = self.runbzr('info tree/checkout')
614
out, err = self.run_bzr('info -v tree/checkout')
609
615
self.assertEqualDiff(
612
checkout of branch: %s
616
"""Checkout (format: unnamed)
618
checkout root: tree/checkout
619
checkout of branch: repo/branch
615
622
control: Meta directory format 1
616
working tree: Working tree format 3
617
branch: Branch format 5
623
working tree: Working tree format 6
620
627
Branch is out of date: missing 1 revision.
674
679
first revision: %s
675
680
latest revision: %s
680
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
681
repo._format.get_format_description(),
684
""" % (format.get_branch_format().get_format_description(),
685
format.repository_format.get_format_description(),
682
686
datestring_first, datestring_first,
683
# poking at _revision_store isn't all that clean, but neither is
684
# having the ui test dependent on the exact overhead of a given store.
685
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
687
688
self.assertEqual('', err)
688
689
tree3.commit('commit two')
690
691
# Out of date lightweight checkout
691
692
rev = repo.get_revision(branch1.revision_history()[-1])
692
693
datestring_last = format_date(rev.timestamp, rev.timezone)
693
out, err = self.runbzr('info tree/lightcheckout --verbose')
694
out, err = self.run_bzr('info tree/lightcheckout --verbose')
694
695
self.assertEqualDiff(
696
light checkout root: %s
697
shared repository: %s
698
repository branch: branch
696
"""Lightweight checkout (format: %s)
698
light checkout root: tree/lightcheckout
699
checkout of branch: repo/branch
700
shared repository: repo
701
703
control: Meta directory format 1
702
working tree: Working tree format 3
703
branch: Branch format 5
704
working tree: Working tree format 6
706
708
Working tree is out of date: missing 1 revision.
722
723
first revision: %s
723
724
latest revision: %s
728
""" % (tree2.bzrdir.root_transport.base,
729
repo.bzrdir.root_transport.base,
730
repo._format.get_format_description(),
728
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
729
format.repository_format.get_format_description(),
731
730
datestring_first, datestring_last,
732
# poking at _revision_store isn't all that clean, but neither is
733
# having the ui test dependent on the exact overhead of a given store.
734
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
736
732
self.assertEqual('', err)
738
734
# Show info about shared branch
739
out, err = self.runbzr('info repo/branch --verbose')
735
out, err = self.run_bzr('info repo/branch --verbose')
740
736
self.assertEqualDiff(
742
shared repository: %s
743
repository branch: branch
737
"""Repository branch (format: dirstate or knit)
739
shared repository: repo
740
repository branch: repo/branch
746
743
control: Meta directory format 1
747
branch: Branch format 5
754
750
first revision: %s
755
751
latest revision: %s
760
""" % (repo.bzrdir.root_transport.base,
761
repo._format.get_format_description(),
755
""" % (format.get_branch_format().get_format_description(),
756
format.repository_format.get_format_description(),
762
757
datestring_first, datestring_last,
763
# poking at _revision_store isn't all that clean, but neither is
764
# having the ui test dependent on the exact overhead of a given store.
765
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
767
759
self.assertEqual('', err)
769
761
# Show info about repository with revisions
770
out, err = self.runbzr('info repo')
762
out, err = self.run_bzr('info -v repo')
771
763
self.assertEqualDiff(
773
shared repository: %s
764
"""Shared repository (format: dirstate or dirstate-tags or knit)
766
shared repository: repo
776
769
control: Meta directory format 1
782
""" % (repo.bzrdir.root_transport.base,
783
repo._format.get_format_description(),
784
# poking at _revision_store isn't all that clean, but neither is
785
# having the ui test dependent on the exact overhead of a given store.
786
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
774
""" % (format.repository_format.get_format_description(),
788
776
self.assertEqual('', err)
790
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
792
778
def test_info_shared_repository_with_trees(self):
793
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
794
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
779
format = bzrdir.format_registry.make_bzrdir('knit')
795
780
transport = self.get_transport()
797
782
# Create shared repository with working trees
798
repo = self.make_repository('repo', shared=True)
783
repo = self.make_repository('repo', shared=True, format=format)
799
784
repo.set_make_working_trees(True)
800
out, err = self.runbzr('info repo')
785
out, err = self.run_bzr('info -v repo')
801
786
self.assertEqualDiff(
803
shared repository: %s
787
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
789
shared repository: repo
806
792
control: Meta directory format 1
809
795
Create working tree for new branches inside the repository.
814
""" % (repo.bzrdir.root_transport.base,
815
repo._format.get_format_description(),
799
""" % (format.repository_format.get_format_description(),
817
801
self.assertEqual('', err)
819
803
# Create two branches
820
804
repo.bzrdir.root_transport.mkdir('branch1')
821
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
805
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
822
807
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
824
809
# Empty first branch
825
out, err = self.runbzr('info repo/branch1 --verbose')
810
out, err = self.run_bzr('info repo/branch1 --verbose')
826
811
self.assertEqualDiff(
828
shared repository: %s
829
repository checkout: branch1
812
"""Repository tree (format: knit)
814
shared repository: repo
815
repository branch: repo/branch1
832
818
control: Meta directory format 1
833
819
working tree: Working tree format 3
834
branch: Branch format 5
837
823
In the working tree:
891
876
first revision: %s
892
877
latest revision: %s
897
""" % (repo.bzrdir.root_transport.base,
898
repo._format.get_format_description(),
881
""" % (format.get_branch_format().get_format_description(),
882
format.repository_format.get_format_description(),
899
883
datestring_first, datestring_first,
900
# poking at _revision_store isn't all that clean, but neither is
901
# having the ui test dependent on the exact overhead of a given store.
902
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
904
885
self.assertEqual('', err)
906
887
# Out of date second branch
907
out, err = self.runbzr('info repo/branch2 --verbose')
888
out, err = self.run_bzr('info repo/branch2 --verbose')
908
889
self.assertEqualDiff(
910
shared repository: %s
911
repository checkout: branch2
890
"""Repository tree (format: knit)
892
shared repository: repo
893
repository branch: repo/branch2
913
895
Related branches:
896
parent branch: repo/branch1
917
899
control: Meta directory format 1
918
900
working tree: Working tree format 3
919
branch: Branch format 5
922
904
In the working tree:
939
""" % (repo.bzrdir.root_transport.base,
940
branch1.bzrdir.root_transport.base,
941
repo._format.get_format_description(),
942
# poking at _revision_store isn't all that clean, but neither is
943
# having the ui test dependent on the exact overhead of a given store.
944
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
919
""" % (format.get_branch_format().get_format_description(),
920
format.repository_format.get_format_description(),
946
922
self.assertEqual('', err)
948
924
# Update second branch
949
925
tree2 = branch2.bzrdir.open_workingtree()
950
926
tree2.pull(branch1)
951
out, err = self.runbzr('info repo/branch2')
927
out, err = self.run_bzr('info -v repo/branch2')
952
928
self.assertEqualDiff(
954
shared repository: %s
955
repository checkout: branch2
929
"""Repository tree (format: knit)
931
shared repository: repo
932
repository branch: repo/branch2
957
934
Related branches:
935
parent branch: repo/branch1
961
938
control: Meta directory format 1
962
939
working tree: Working tree format 3
963
branch: Branch format 5
966
943
In the working tree:
979
956
first revision: %s
980
957
latest revision: %s
985
""" % (repo.bzrdir.root_transport.base,
986
branch1.bzrdir.root_transport.base,
987
repo._format.get_format_description(),
961
""" % (format.get_branch_format().get_format_description(),
962
format.repository_format.get_format_description(),
988
963
datestring_first, datestring_first,
989
# poking at _revision_store isn't all that clean, but neither is
990
# having the ui test dependent on the exact overhead of a given store.
991
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
993
965
self.assertEqual('', err)
995
967
# Show info about repository with revisions
996
out, err = self.runbzr('info repo')
968
out, err = self.run_bzr('info -v repo')
997
969
self.assertEqualDiff(
999
shared repository: %s
970
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
972
shared repository: repo
1002
975
control: Meta directory format 1
1005
978
Create working tree for new branches inside the repository.
1010
""" % (repo.bzrdir.root_transport.base,
1011
repo._format.get_format_description(),
1012
# poking at _revision_store isn't all that clean, but neither is
1013
# having the ui test dependent on the exact overhead of a given store.
1014
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
982
""" % (format.repository_format.get_format_description(),
1017
985
self.assertEqual('', err)
1019
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1021
987
def test_info_shared_repository_with_tree_in_root(self):
1022
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1023
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
988
format = bzrdir.format_registry.make_bzrdir('knit')
1024
989
transport = self.get_transport()
1026
991
# Create shared repository with working trees
1027
repo = self.make_repository('repo', shared=True)
992
repo = self.make_repository('repo', shared=True, format=format)
1028
993
repo.set_make_working_trees(True)
1029
out, err = self.runbzr('info repo')
994
out, err = self.run_bzr('info -v repo')
1030
995
self.assertEqualDiff(
1032
shared repository: %s
996
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
998
shared repository: repo
1035
1001
control: Meta directory format 1
1074
1039
Branch history:
1080
""" % (repo.bzrdir.root_transport.base,
1081
repo._format.get_format_description(),
1083
self.assertEqual('', err)
1085
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1087
def assertCheckoutStatusOutput(self,
1044
""" % (format.get_branch_format().get_format_description(),
1045
format.repository_format.get_format_description(),
1047
self.assertEqual('', err)
1049
def test_info_repository_hook(self):
1050
format = bzrdir.format_registry.make_bzrdir('knit')
1051
def repo_info(repo, stats, outf):
1052
outf.write("more info\n")
1053
info.hooks.install_named_hook('repository', repo_info, None)
1054
# Create shared repository with working trees
1055
repo = self.make_repository('repo', shared=True, format=format)
1056
out, err = self.run_bzr('info -v repo')
1057
self.assertEqualDiff(
1058
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1060
shared repository: repo
1063
control: Meta directory format 1
1066
Create working tree for new branches inside the repository.
1071
""" % (format.repository_format.get_format_description(),
1073
self.assertEqual('', err)
1075
def assertCheckoutStatusOutput(self,
1088
1076
command_string, lco_tree, shared_repo=None,
1089
1077
repo_branch=None,
1090
1078
tree_locked=False,
1091
1079
branch_locked=False, repo_locked=False,
1093
light_checkout=True):
1094
"""Check the output of info in a light checkout tree.
1081
light_checkout=True,
1082
checkout_root=None):
1083
"""Check the output of info in a checkout.
1096
1085
This is not quite a mirror of the info code: rather than using the
1097
1086
tree being examined to predict output, it uses a bunch of flags which
1098
1087
allow us, the test writers, to document what *should* be present in
1099
1088
the output. Removing this separation would remove the value of the
1102
1091
:param path: the path to the light checkout.
1103
1092
:param lco_tree: the tree object for the light checkout.
1104
1093
:param shared_repo: A shared repository is in use, expect that in
1108
1097
:param tree_locked: If true, expect the tree to be locked.
1109
1098
:param branch_locked: If true, expect the branch to be locked.
1110
1099
:param repo_locked: If true, expect the repository to be locked.
1111
:param verbose: If true, expect verbose output
1100
Note that the lco_tree.branch.repository is inspected, and if is not
1101
actually locked then this parameter is overridden. This is because
1102
pack repositories do not have any public API for obtaining an
1103
exclusive repository wide lock.
1104
:param verbose: verbosity level: 2 or higher to show committers
1113
out, err = self.runbzr('info %s' % command_string)
1106
def friendly_location(url):
1107
path = urlutils.unescape_for_display(url, 'ascii')
1109
return osutils.relpath(osutils.getcwd(), path)
1110
except errors.PathNotChild:
1114
# We expect this to fail because of locking errors.
1115
# (A write-locked file cannot be read-locked
1116
# in the different process -- either on win32 or on linux).
1117
# This should be removed when the locking errors are fixed.
1118
self.expectFailure('OS locks are exclusive '
1119
'for different processes (Bug #174055)',
1120
self.run_bzr_subprocess,
1121
'info ' + command_string)
1122
out, err = self.run_bzr('info %s' % command_string)
1124
(True, True): 'Lightweight checkout',
1125
(True, False): 'Repository checkout',
1126
(False, True): 'Lightweight checkout',
1127
(False, False): 'Checkout',
1128
}[(shared_repo is not None, light_checkout)]
1129
format = {True: self._repo_strings,
1130
False: 'unnamed'}[light_checkout]
1132
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1114
1133
if repo_locked or branch_locked or tree_locked:
1115
1134
def locked_message(a_bool):
1128
1147
locked_message(repo_locked)))
1130
1149
expected_lock_output = ''
1131
1152
if light_checkout:
1132
tree_data = (" light checkout root: %s" %
1133
lco_tree.bzrdir.root_transport.base)
1135
tree_data = (" checkout root: %s" %
1136
lco_tree.bzrdir.root_transport.base)
1153
tree_data = (" light checkout root: %s\n" %
1154
friendly_location(lco_tree.bzrdir.root_transport.base))
1156
if lco_tree.branch.get_bound_location() is not None:
1157
tree_data += ("%s checkout root: %s\n" % (extra_space,
1158
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1137
1159
if shared_repo is not None:
1138
1160
branch_data = (
1139
" shared repository: %s\n"
1140
" repository branch: branch\n" %
1141
shared_repo.bzrdir.root_transport.base)
1161
" checkout of branch: %s\n"
1162
" shared repository: %s\n" %
1163
(friendly_location(repo_branch.bzrdir.root_transport.base),
1164
friendly_location(shared_repo.bzrdir.root_transport.base)))
1142
1165
elif repo_branch is not None:
1143
1166
branch_data = (
1144
" checkout of branch: %s\n" %
1145
repo_branch.bzrdir.root_transport.base)
1167
"%s checkout of branch: %s\n" %
1169
friendly_location(repo_branch.bzrdir.root_transport.base)))
1147
branch_data = (" checkout of branch: %s\n" %
1171
branch_data = (" checkout of branch: %s\n" %
1148
1172
lco_tree.branch.bzrdir.root_transport.base)
1151
1175
verbose_info = ' 0 committers\n'
1153
1177
verbose_info = ''
1155
1179
self.assertEqualDiff(
1160
1184
control: Meta directory format 1
1161
1185
working tree: %s
1162
branch: Branch format 5
1165
1189
In the working tree:
1191
1217
transport = self.get_transport()
1192
1218
# Create shared repository with a branch
1193
1219
repo = self.make_repository('repo', shared=True,
1194
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1220
format=bzrdir.BzrDirMetaFormat1())
1195
1221
repo.set_make_working_trees(False)
1196
1222
repo.bzrdir.root_transport.mkdir('branch')
1197
1223
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1198
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1224
format=bzrdir.BzrDirMetaFormat1())
1199
1225
# Do a heavy checkout
1200
1226
transport.mkdir('tree')
1201
1227
transport.mkdir('tree/checkout')
1202
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1203
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1228
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1229
format=bzrdir.BzrDirMetaFormat1())
1204
1230
co_branch.bind(repo_branch)
1205
1231
# Do a light checkout of the heavy one
1206
1232
transport.mkdir('tree/lightcheckout')
1207
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1208
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1233
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1234
branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1209
1235
lco_dir.create_workingtree()
1210
1236
lco_tree = lco_dir.open_workingtree()
1216
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1242
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1243
repo_branch=repo_branch,
1244
verbose=True, light_checkout=True)
1218
1246
lco_tree.branch.repository.lock_write()
1220
self.assertCheckoutStatusOutput('tree/lightcheckout',
1248
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1249
lco_tree, repo_branch=repo_branch,
1250
repo_locked=True, verbose=True, light_checkout=True)
1224
1252
lco_tree.branch.repository.unlock()
1226
1254
lco_tree.branch.lock_write()
1228
self.assertCheckoutStatusOutput('tree/lightcheckout',
1256
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1230
1258
branch_locked=True,
1260
repo_branch=repo_branch,
1233
1263
lco_tree.branch.unlock()
1235
1265
lco_tree.lock_write()
1237
self.assertCheckoutStatusOutput('tree/lightcheckout',
1267
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1268
lco_tree, repo_branch=repo_branch,
1239
1269
tree_locked=True,
1240
1270
branch_locked=True,
1243
1274
lco_tree.unlock()
1245
1276
lco_tree.lock_write()
1246
1277
lco_tree.branch.repository.unlock()
1248
self.assertCheckoutStatusOutput('tree/lightcheckout',
1279
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1280
lco_tree, repo_branch=repo_branch,
1250
1281
tree_locked=True,
1253
1285
lco_tree.branch.repository.lock_write()
1254
1286
lco_tree.unlock()
1279
1313
lco_tree.branch.lock_write()
1280
1314
lco_tree.branch.repository.unlock()
1282
self.assertCheckoutStatusOutput('tree/lightcheckout',
1316
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1317
lco_tree, repo_branch=repo_branch,
1286
1321
lco_tree.branch.repository.lock_write()
1287
1322
lco_tree.branch.unlock()
1324
if sys.platform == 'win32':
1325
self.knownFailure('Win32 cannot run "bzr info"'
1326
' when the tree is locked.')
1289
1328
def test_info_locking_oslocks(self):
1290
1329
if sys.platform == "win32":
1291
1330
raise TestSkipped("don't use oslocks on win32 in unix manner")
1331
# This test tests old (all-in-one, OS lock using) behaviour which
1332
# simply cannot work on windows (and is indeed why we changed our
1333
# design. As such, don't try to remove the thisFailsStrictLockCheck
1335
self.thisFailsStrictLockCheck()
1293
1337
tree = self.make_branch_and_tree('branch',
1294
format=bzrlib.bzrdir.BzrDirFormat6())
1338
format=bzrdir.BzrDirFormat6())
1296
1340
# Test all permutations of locking the working tree, branch and repository
1297
1341
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1357
1401
Branch history:
1363
""" % (tree.bzrdir.root_transport.base,
1364
tree.branch.repository._format.get_format_description(),
1406
""" % ('branch', tree.branch.repository._format.get_format_description(),
1366
1408
self.assertEqual('', err)
1411
def test_info_stacked(self):
1412
# We have a mainline
1413
trunk_tree = self.make_branch_and_tree('mainline',
1415
trunk_tree.commit('mainline')
1416
# and a branch from it which is stacked
1417
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1418
out, err = self.run_bzr('info newbranch')
1420
"""Standalone tree (format: 1.6)
1422
branch root: newbranch
1425
parent branch: mainline
1426
stacked on: mainline
1428
self.assertEqual("", err)