13
14
# You should have received a copy of the GNU General Public License
14
15
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19
"""Tests for the info command of bzr."""
31
24
from bzrlib.osutils import format_date
32
from bzrlib.tests import TestSkipped, MemoryServer
25
from bzrlib.tests import TestSkipped
33
26
from bzrlib.tests.blackbox import ExternalBase
36
29
class TestInfo(ExternalBase):
39
ExternalBase.setUp(self)
40
self._repo_strings = "2a or development-subtree"
42
31
def test_info_non_existing(self):
43
self.vfs_transport_factory = MemoryServer
44
location = self.get_url()
45
out, err = self.run_bzr('info '+location, retcode=3)
32
if sys.platform == "win32":
33
location = "C:/i/do/not/exist/"
35
location = "/i/do/not/exist/"
36
out, err = self.runbzr('info '+location, retcode=3)
46
37
self.assertEqual(out, '')
47
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
38
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
49
40
def test_info_standalone(self):
50
41
transport = self.get_transport()
52
43
# Create initial standalone branch
53
tree1 = self.make_branch_and_tree('standalone', 'weave')
44
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
45
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
46
tree1 = self.make_branch_and_tree('standalone')
47
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
54
48
self.build_tree(['standalone/a'])
56
50
branch1 = tree1.branch
58
out, err = self.run_bzr('info standalone')
60
"""Standalone tree (format: weave)
62
branch root: standalone
64
self.assertEqual('', err)
66
# Standalone branch - verbose mode
67
out, err = self.run_bzr('info standalone -v')
69
"""Standalone tree (format: weave)
71
branch root: standalone
74
control: All-in-one format 6
75
working tree: Working tree format 2
76
branch: Branch format 4
77
repository: Weave repository format 6
87
0 versioned subdirectories
95
self.assertEqual('', err)
97
# Standalone branch - really verbose mode
98
out, err = self.run_bzr('info standalone -vv')
100
"""Standalone tree (format: weave)
102
branch root: standalone
105
control: All-in-one format 6
106
working tree: Working tree format 2
107
branch: Branch format 4
108
repository: Weave repository format 6
118
0 versioned subdirectories
51
out, err = self.runbzr('info standalone')
57
control: All-in-one format 6
58
working tree: Working tree format 2
59
branch: Branch format 4
60
repository: Weave repository format 6
70
0 versioned subdirectories
78
""" % branch1.bzrdir.root_transport.base, out)
127
79
self.assertEqual('', err)
128
80
tree1.commit('commit one')
129
81
rev = branch1.repository.get_revision(branch1.revision_history()[0])
177
116
first revision: %s
178
117
latest revision: %s
182
""" % (datestring_first, datestring_first,
122
""" % (branch2.bzrdir.root_transport.base,
123
branch1.bzrdir.root_transport.base,
124
branch1.bzrdir.root_transport.base,
125
datestring_first, datestring_first,
126
# poking at _revision_store isn't all that clean, but neither is
127
# having the ui test dependent on the exact overhead of a given store.
128
branch2.repository._revision_store.total_size(
129
branch2.repository.get_transaction())[1] / 1024,
184
131
self.assertEqual('', err)
186
133
# Branch and bind to standalone, needs upgrade to metadir
187
134
# (creates backup as unknown)
188
135
branch1.bzrdir.sprout('bound')
189
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
190
upgrade.upgrade('bound', knit1_format)
191
branch3 = bzrdir.BzrDir.open('bound').open_branch()
136
bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
137
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
192
138
branch3.bind(branch1)
193
139
bound_tree = branch3.bzrdir.open_workingtree()
194
out, err = self.run_bzr('info -v bound')
140
out, err = self.runbzr('info bound')
195
141
self.assertEqualDiff(
196
"""Checkout (format: knit)
199
checkout of branch: standalone
144
checkout of branch: %s
201
146
Related branches:
202
parent branch: standalone
205
150
control: Meta directory format 1
152
branch: Branch format 5
210
155
In the working tree:
223
168
first revision: %s
224
169
latest revision: %s
228
""" % (bound_tree._format.get_format_description(),
229
branch3._format.get_format_description(),
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
178
branch3.repository._format.get_format_description(),
231
179
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,
233
185
self.assertEqual('', err)
235
187
# Checkout standalone (same as above, but does not have parent set)
236
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
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
192
branch4.bind(branch1)
239
193
branch4.bzrdir.open_workingtree().update()
240
out, err = self.run_bzr('info checkout --verbose')
194
out, err = self.runbzr('info checkout --verbose')
241
195
self.assertEqualDiff(
242
"""Checkout (format: knit)
244
checkout root: checkout
245
checkout of branch: standalone
198
checkout of branch: %s
248
201
control: Meta directory format 1
266
220
first revision: %s
267
221
latest revision: %s
271
""" % (branch4.repository._format.get_format_description(),
226
""" % (branch4.bzrdir.root_transport.base,
227
branch1.bzrdir.root_transport.base,
228
branch4.repository._format.get_format_description(),
272
229
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,
274
235
self.assertEqual('', err)
276
237
# Lightweight checkout (same as above, different branch and repository)
277
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
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)
278
246
branch5 = tree5.branch
279
out, err = self.run_bzr('info -v lightcheckout')
247
out, err = self.runbzr('info lightcheckout')
280
248
self.assertEqualDiff(
281
"""Lightweight checkout (format: %s)
283
light checkout root: lightcheckout
284
checkout of branch: standalone
250
light checkout root: %s
251
checkout of branch: %s
287
254
control: Meta directory format 1
288
working tree: Working tree format 6
255
working tree: Working tree format 3
289
256
branch: Branch format 4
290
257
repository: Weave repository format 6
350
320
first revision: %s
351
321
latest revision: %s
355
""" % (datestring_first, datestring_first,
326
""" % (branch2.bzrdir.root_transport.base,
327
branch1.bzrdir.root_transport.base,
328
branch1.bzrdir.root_transport.base,
329
datestring_first, datestring_first,
357
331
self.assertEqual('', err)
359
333
# Out of date bound branch
360
out, err = self.run_bzr('info -v bound')
334
out, err = self.runbzr('info bound')
361
335
self.assertEqualDiff(
362
"""Checkout (format: knit)
365
checkout of branch: standalone
338
checkout of branch: %s
367
340
Related branches:
368
parent branch: standalone
371
344
control: Meta directory format 1
391
364
first revision: %s
392
365
latest revision: %s
396
""" % (branch3.repository._format.get_format_description(),
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(),
397
374
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,
399
380
self.assertEqual('', err)
401
382
# Out of date checkout
402
out, err = self.run_bzr('info -v checkout')
383
out, err = self.runbzr('info checkout')
403
384
self.assertEqualDiff(
404
"""Checkout (format: knit)
406
checkout root: checkout
407
checkout of branch: standalone
387
checkout of branch: %s
410
390
control: Meta directory format 1
430
410
first revision: %s
431
411
latest revision: %s
435
""" % (branch4.repository._format.get_format_description(),
416
""" % (branch4.bzrdir.root_transport.base,
417
branch1.bzrdir.root_transport.base,
418
branch4.repository._format.get_format_description(),
436
419
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,
438
425
self.assertEqual('', err)
440
427
# Out of date lightweight checkout
441
out, err = self.run_bzr('info lightcheckout --verbose')
428
out, err = self.runbzr('info lightcheckout --verbose')
442
429
self.assertEqualDiff(
443
"""Lightweight checkout (format: %s)
445
light checkout root: lightcheckout
446
checkout of branch: standalone
431
light checkout root: %s
432
checkout of branch: %s
449
435
control: Meta directory format 1
450
working tree: Working tree format 6
436
working tree: Working tree format 3
451
437
branch: Branch format 4
452
438
repository: Weave repository format 6
469
456
first revision: %s
470
457
latest revision: %s
474
""" % (self._repo_strings, datestring_first, datestring_last,), out)
462
""" % (tree5.bzrdir.root_transport.base,
463
branch1.bzrdir.root_transport.base,
464
datestring_first, datestring_last,
475
466
self.assertEqual('', err)
477
468
def test_info_standalone_no_tree(self):
478
469
# create standalone branch without a working tree
479
format = bzrdir.format_registry.make_bzrdir('default')
480
470
branch = self.make_branch('branch')
481
471
repo = branch.repository
482
out, err = self.run_bzr('info branch -v')
472
out, err = self.runbzr('info branch')
483
473
self.assertEqualDiff(
484
"""Standalone branch (format: %s)
489
478
control: Meta directory format 1
479
branch: Branch format 5
498
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
499
format.get_branch_format().get_format_description(),
500
format.repository_format.get_format_description(),
488
""" % (branch.bzrdir.root_transport.base,
489
repo._format.get_format_description(),
502
491
self.assertEqual('', err)
504
493
def test_info_shared_repository(self):
505
format = bzrdir.format_registry.make_bzrdir('knit')
494
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
495
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
506
496
transport = self.get_transport()
508
498
# Create shared repository
509
repo = self.make_repository('repo', shared=True, format=format)
499
repo = self.make_repository('repo', shared=True)
510
500
repo.set_make_working_trees(False)
511
out, err = self.run_bzr('info -v repo')
501
out, err = self.runbzr('info repo')
512
502
self.assertEqualDiff(
513
"""Shared repository (format: dirstate or dirstate-tags or knit)
515
504
shared repository: %s
518
507
control: Meta directory format 1
523
""" % ('repo', format.repository_format.get_format_description(),
513
""" % (repo.bzrdir.root_transport.base,
514
repo._format.get_format_description(),
525
516
self.assertEqual('', err)
527
518
# Create branch inside shared repository
528
519
repo.bzrdir.root_transport.mkdir('branch')
529
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
531
out, err = self.run_bzr('info -v repo/branch')
520
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
521
out, err = self.runbzr('info repo/branch')
532
522
self.assertEqualDiff(
533
"""Repository branch (format: dirstate or knit)
535
shared repository: repo
536
repository branch: repo/branch
524
shared repository: %s
525
repository branch: branch
539
528
control: Meta directory format 1
529
branch: Branch format 5
548
""" % (format.get_branch_format().get_format_description(),
549
format.repository_format.get_format_description(),
538
""" % (repo.bzrdir.root_transport.base,
539
repo._format.get_format_description(),
551
541
self.assertEqual('', err)
553
543
# Create lightweight checkout
554
544
transport.mkdir('tree')
555
545
transport.mkdir('tree/lightcheckout')
556
tree2 = branch1.create_checkout('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
550
branch2 = tree2.branch
559
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
560
shared_repo=repo, repo_branch=branch1, verbose=True)
551
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
562
553
# Create normal checkout
563
tree3 = branch1.create_checkout('tree/checkout')
554
branch3 = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout')
555
branch3.bind(branch1)
556
tree3 = branch3.bzrdir.open_workingtree()
564
558
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
566
560
light_checkout=False, repo_branch=branch1)
600
594
first revision: %s
601
595
latest revision: %s
605
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
606
format.repository_format.get_format_description(),
600
""" % (tree2.bzrdir.root_transport.base,
601
repo.bzrdir.root_transport.base,
602
repo._format.get_format_description(),
607
603
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,
609
608
self.assertEqual('', err)
611
610
# Out of date checkout
612
out, err = self.run_bzr('info -v tree/checkout')
611
out, err = self.runbzr('info tree/checkout')
613
612
self.assertEqualDiff(
614
"""Checkout (format: unnamed)
616
checkout root: tree/checkout
617
checkout of branch: repo/branch
615
checkout of branch: %s
620
618
control: Meta directory format 1
621
working tree: Working tree format 6
619
working tree: Working tree format 3
620
branch: Branch format 5
625
623
Branch is out of date: missing 1 revision.
677
677
first revision: %s
678
678
latest revision: %s
682
""" % (format.get_branch_format().get_format_description(),
683
format.repository_format.get_format_description(),
683
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
684
repo._format.get_format_description(),
684
685
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,
686
690
self.assertEqual('', err)
687
691
tree3.commit('commit two')
689
693
# Out of date lightweight checkout
690
694
rev = repo.get_revision(branch1.revision_history()[-1])
691
695
datestring_last = format_date(rev.timestamp, rev.timezone)
692
out, err = self.run_bzr('info tree/lightcheckout --verbose')
696
out, err = self.runbzr('info tree/lightcheckout --verbose')
693
697
self.assertEqualDiff(
694
"""Lightweight checkout (format: %s)
696
light checkout root: tree/lightcheckout
697
checkout of branch: repo/branch
698
shared repository: repo
699
light checkout root: %s
700
shared repository: %s
701
repository branch: branch
701
704
control: Meta directory format 1
702
working tree: Working tree format 6
705
working tree: Working tree format 3
706
branch: Branch format 5
706
709
Working tree is out of date: missing 1 revision.
721
725
first revision: %s
722
726
latest revision: %s
726
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
727
format.repository_format.get_format_description(),
731
""" % (tree2.bzrdir.root_transport.base,
732
repo.bzrdir.root_transport.base,
733
repo._format.get_format_description(),
728
734
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,
730
739
self.assertEqual('', err)
732
741
# Show info about shared branch
733
out, err = self.run_bzr('info repo/branch --verbose')
742
out, err = self.runbzr('info repo/branch --verbose')
734
743
self.assertEqualDiff(
735
"""Repository branch (format: dirstate or knit)
737
shared repository: repo
738
repository branch: repo/branch
745
shared repository: %s
746
repository branch: branch
741
749
control: Meta directory format 1
750
branch: Branch format 5
748
757
first revision: %s
749
758
latest revision: %s
753
""" % (format.get_branch_format().get_format_description(),
754
format.repository_format.get_format_description(),
763
""" % (repo.bzrdir.root_transport.base,
764
repo._format.get_format_description(),
755
765
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,
757
770
self.assertEqual('', err)
759
772
# Show info about repository with revisions
760
out, err = self.run_bzr('info -v repo')
773
out, err = self.runbzr('info repo')
761
774
self.assertEqualDiff(
762
"""Shared repository (format: dirstate or dirstate-tags or knit)
764
shared repository: repo
776
shared repository: %s
767
779
control: Meta directory format 1
772
""" % (format.repository_format.get_format_description(),
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,
774
791
self.assertEqual('', err)
793
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
776
795
def test_info_shared_repository_with_trees(self):
777
format = bzrdir.format_registry.make_bzrdir('knit')
796
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
797
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
778
798
transport = self.get_transport()
780
800
# Create shared repository with working trees
781
repo = self.make_repository('repo', shared=True, format=format)
801
repo = self.make_repository('repo', shared=True)
782
802
repo.set_make_working_trees(True)
783
out, err = self.run_bzr('info -v repo')
803
out, err = self.runbzr('info repo')
784
804
self.assertEqualDiff(
785
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
787
shared repository: repo
806
shared repository: %s
790
809
control: Meta directory format 1
793
812
Create working tree for new branches inside the repository.
797
""" % (format.repository_format.get_format_description(),
817
""" % (repo.bzrdir.root_transport.base,
818
repo._format.get_format_description(),
799
820
self.assertEqual('', err)
801
822
# Create two branches
802
823
repo.bzrdir.root_transport.mkdir('branch1')
803
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
824
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
805
825
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
807
827
# Empty first branch
808
out, err = self.run_bzr('info repo/branch1 --verbose')
828
out, err = self.runbzr('info repo/branch1 --verbose')
809
829
self.assertEqualDiff(
810
"""Repository tree (format: knit)
812
shared repository: repo
813
repository branch: repo/branch1
831
shared repository: %s
832
repository checkout: branch1
816
835
control: Meta directory format 1
817
836
working tree: Working tree format 3
837
branch: Branch format 5
821
840
In the working tree:
874
894
first revision: %s
875
895
latest revision: %s
879
""" % (format.get_branch_format().get_format_description(),
880
format.repository_format.get_format_description(),
900
""" % (repo.bzrdir.root_transport.base,
901
repo._format.get_format_description(),
881
902
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,
883
907
self.assertEqual('', err)
885
909
# Out of date second branch
886
out, err = self.run_bzr('info repo/branch2 --verbose')
910
out, err = self.runbzr('info repo/branch2 --verbose')
887
911
self.assertEqualDiff(
888
"""Repository tree (format: knit)
890
shared repository: repo
891
repository branch: repo/branch2
913
shared repository: %s
914
repository checkout: branch2
893
916
Related branches:
894
parent branch: repo/branch1
897
920
control: Meta directory format 1
898
921
working tree: Working tree format 3
922
branch: Branch format 5
902
925
In the working tree:
917
""" % (format.get_branch_format().get_format_description(),
918
format.repository_format.get_format_description(),
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
949
self.assertEqual('', err)
922
951
# Update second branch
923
952
tree2 = branch2.bzrdir.open_workingtree()
924
953
tree2.pull(branch1)
925
out, err = self.run_bzr('info -v repo/branch2')
954
out, err = self.runbzr('info repo/branch2')
926
955
self.assertEqualDiff(
927
"""Repository tree (format: knit)
929
shared repository: repo
930
repository branch: repo/branch2
957
shared repository: %s
958
repository checkout: branch2
932
960
Related branches:
933
parent branch: repo/branch1
936
964
control: Meta directory format 1
937
965
working tree: Working tree format 3
966
branch: Branch format 5
941
969
In the working tree:
954
982
first revision: %s
955
983
latest revision: %s
959
""" % (format.get_branch_format().get_format_description(),
960
format.repository_format.get_format_description(),
988
""" % (repo.bzrdir.root_transport.base,
989
branch1.bzrdir.root_transport.base,
990
repo._format.get_format_description(),
961
991
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,
963
996
self.assertEqual('', err)
965
998
# Show info about repository with revisions
966
out, err = self.run_bzr('info -v repo')
999
out, err = self.runbzr('info repo')
967
1000
self.assertEqualDiff(
968
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
970
shared repository: repo
1002
shared repository: %s
973
1005
control: Meta directory format 1
976
1008
Create working tree for new branches inside the repository.
980
""" % (format.repository_format.get_format_description(),
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
1020
self.assertEqual('', err)
1022
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
985
1024
def test_info_shared_repository_with_tree_in_root(self):
986
format = bzrdir.format_registry.make_bzrdir('knit')
1025
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1026
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
987
1027
transport = self.get_transport()
989
1029
# Create shared repository with working trees
990
repo = self.make_repository('repo', shared=True, format=format)
1030
repo = self.make_repository('repo', shared=True)
991
1031
repo.set_make_working_trees(True)
992
out, err = self.run_bzr('info -v repo')
1032
out, err = self.runbzr('info repo')
993
1033
self.assertEqualDiff(
994
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
996
shared repository: repo
1035
shared repository: %s
999
1038
control: Meta directory format 1
1037
1077
Branch history:
1042
""" % (format.get_branch_format().get_format_description(),
1043
format.repository_format.get_format_description(),
1045
self.assertEqual('', err)
1047
def test_info_repository_hook(self):
1048
format = bzrdir.format_registry.make_bzrdir('knit')
1049
def repo_info(repo, stats, outf):
1050
outf.write("more info\n")
1051
info.hooks.install_named_hook('repository', repo_info, None)
1052
# Create shared repository with working trees
1053
repo = self.make_repository('repo', shared=True, format=format)
1054
out, err = self.run_bzr('info -v repo')
1055
self.assertEqualDiff(
1056
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1058
shared repository: repo
1061
control: Meta directory format 1
1064
Create working tree for new branches inside the repository.
1069
""" % (format.repository_format.get_format_description(),
1071
self.assertEqual('', err)
1073
def assertCheckoutStatusOutput(self,
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,
1074
1091
command_string, lco_tree, shared_repo=None,
1075
1092
repo_branch=None,
1076
1093
tree_locked=False,
1077
1094
branch_locked=False, repo_locked=False,
1079
light_checkout=True,
1080
checkout_root=None):
1081
"""Check the output of info in a checkout.
1096
light_checkout=True):
1097
"""Check the output of info in a light checkout tree.
1083
1099
This is not quite a mirror of the info code: rather than using the
1084
1100
tree being examined to predict output, it uses a bunch of flags which
1085
1101
allow us, the test writers, to document what *should* be present in
1086
1102
the output. Removing this separation would remove the value of the
1089
1105
:param path: the path to the light checkout.
1090
1106
:param lco_tree: the tree object for the light checkout.
1091
1107
:param shared_repo: A shared repository is in use, expect that in
1095
1111
:param tree_locked: If true, expect the tree to be locked.
1096
1112
:param branch_locked: If true, expect the branch to be locked.
1097
1113
:param repo_locked: If true, expect the repository to be locked.
1098
Note that the lco_tree.branch.repository is inspected, and if is not
1099
actually locked then this parameter is overridden. This is because
1100
pack repositories do not have any public API for obtaining an
1101
exclusive repository wide lock.
1102
:param verbose: verbosity level: 2 or higher to show committers
1114
:param verbose: If true, expect verbose output
1104
def friendly_location(url):
1105
path = urlutils.unescape_for_display(url, 'ascii')
1107
return osutils.relpath(osutils.getcwd(), path)
1108
except errors.PathNotChild:
1112
# We expect this to fail because of locking errors.
1113
# (A write-locked file cannot be read-locked
1114
# in the different process -- either on win32 or on linux).
1115
# This should be removed when the locking errors are fixed.
1116
self.expectFailure('OS locks are exclusive '
1117
'for different processes (Bug #174055)',
1118
self.run_bzr_subprocess,
1119
'info ' + command_string)
1120
out, err = self.run_bzr('info %s' % command_string)
1122
(True, True): 'Lightweight checkout',
1123
(True, False): 'Repository checkout',
1124
(False, True): 'Lightweight checkout',
1125
(False, False): 'Checkout',
1126
}[(shared_repo is not None, light_checkout)]
1127
format = {True: self._repo_strings,
1128
False: 'unnamed'}[light_checkout]
1130
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1116
out, err = self.runbzr('info %s' % command_string)
1131
1117
if repo_locked or branch_locked or tree_locked:
1132
1118
def locked_message(a_bool):
1145
1131
locked_message(repo_locked)))
1147
1133
expected_lock_output = ''
1150
1134
if light_checkout:
1151
tree_data = (" light checkout root: %s\n" %
1152
friendly_location(lco_tree.bzrdir.root_transport.base))
1154
if lco_tree.branch.get_bound_location() is not None:
1155
tree_data += ("%s checkout root: %s\n" % (extra_space,
1156
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
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)
1157
1140
if shared_repo is not None:
1158
1141
branch_data = (
1159
" checkout of branch: %s\n"
1160
" shared repository: %s\n" %
1161
(friendly_location(repo_branch.bzrdir.root_transport.base),
1162
friendly_location(shared_repo.bzrdir.root_transport.base)))
1142
" shared repository: %s\n"
1143
" repository branch: branch\n" %
1144
shared_repo.bzrdir.root_transport.base)
1163
1145
elif repo_branch is not None:
1164
1146
branch_data = (
1165
"%s checkout of branch: %s\n" %
1167
friendly_location(repo_branch.bzrdir.root_transport.base)))
1147
" checkout of branch: %s\n" %
1148
repo_branch.bzrdir.root_transport.base)
1169
branch_data = (" checkout of branch: %s\n" %
1150
branch_data = (" checkout of branch: %s\n" %
1170
1151
lco_tree.branch.bzrdir.root_transport.base)
1173
1154
verbose_info = ' 0 committers\n'
1175
1156
verbose_info = ''
1177
1158
self.assertEqualDiff(
1182
1163
control: Meta directory format 1
1183
1164
working tree: %s
1165
branch: Branch format 5
1187
1168
In the working tree:
1215
1194
transport = self.get_transport()
1216
1195
# Create shared repository with a branch
1217
1196
repo = self.make_repository('repo', shared=True,
1218
format=bzrdir.BzrDirMetaFormat1())
1197
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1219
1198
repo.set_make_working_trees(False)
1220
1199
repo.bzrdir.root_transport.mkdir('branch')
1221
1200
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1222
format=bzrdir.BzrDirMetaFormat1())
1201
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1223
1202
# Do a heavy checkout
1224
1203
transport.mkdir('tree')
1225
1204
transport.mkdir('tree/checkout')
1226
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1227
format=bzrdir.BzrDirMetaFormat1())
1205
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1206
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1228
1207
co_branch.bind(repo_branch)
1229
1208
# Do a light checkout of the heavy one
1230
1209
transport.mkdir('tree/lightcheckout')
1231
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1232
branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1210
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1211
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1233
1212
lco_dir.create_workingtree()
1234
1213
lco_tree = lco_dir.open_workingtree()
1240
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1241
repo_branch=repo_branch,
1242
verbose=True, light_checkout=True)
1219
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1244
1221
lco_tree.branch.repository.lock_write()
1246
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1247
lco_tree, repo_branch=repo_branch,
1248
repo_locked=True, verbose=True, light_checkout=True)
1223
self.assertCheckoutStatusOutput('tree/lightcheckout',
1250
1227
lco_tree.branch.repository.unlock()
1252
1229
lco_tree.branch.lock_write()
1254
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1231
self.assertCheckoutStatusOutput('tree/lightcheckout',
1256
1233
branch_locked=True,
1258
repo_branch=repo_branch,
1261
1236
lco_tree.branch.unlock()
1263
1238
lco_tree.lock_write()
1265
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1266
lco_tree, repo_branch=repo_branch,
1240
self.assertCheckoutStatusOutput('tree/lightcheckout',
1267
1242
tree_locked=True,
1268
1243
branch_locked=True,
1272
1246
lco_tree.unlock()
1274
1248
lco_tree.lock_write()
1275
1249
lco_tree.branch.repository.unlock()
1277
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1278
lco_tree, repo_branch=repo_branch,
1251
self.assertCheckoutStatusOutput('tree/lightcheckout',
1279
1253
tree_locked=True,
1283
1256
lco_tree.branch.repository.lock_write()
1284
1257
lco_tree.unlock()
1311
1282
lco_tree.branch.lock_write()
1312
1283
lco_tree.branch.repository.unlock()
1314
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1315
lco_tree, repo_branch=repo_branch,
1285
self.assertCheckoutStatusOutput('tree/lightcheckout',
1319
1289
lco_tree.branch.repository.lock_write()
1320
1290
lco_tree.branch.unlock()
1322
if sys.platform == 'win32':
1323
self.knownFailure('Win32 cannot run "bzr info"'
1324
' when the tree is locked.')
1326
1292
def test_info_locking_oslocks(self):
1327
1293
if sys.platform == "win32":
1328
1294
raise TestSkipped("don't use oslocks on win32 in unix manner")
1329
# This test tests old (all-in-one, OS lock using) behaviour which
1330
# simply cannot work on windows (and is indeed why we changed our
1331
# design. As such, don't try to remove the thisFailsStrictLockCheck
1333
self.thisFailsStrictLockCheck()
1335
1296
tree = self.make_branch_and_tree('branch',
1336
format=bzrdir.BzrDirFormat6())
1297
format=bzrlib.bzrdir.BzrDirFormat6())
1338
1299
# Test all permutations of locking the working tree, branch and repository
1339
1300
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1399
1360
Branch history:
1404
""" % ('branch', tree.branch.repository._format.get_format_description(),
1366
""" % (tree.bzrdir.root_transport.base,
1367
tree.branch.repository._format.get_format_description(),
1406
1369
self.assertEqual('', err)
1409
def test_info_stacked(self):
1410
# We have a mainline
1411
trunk_tree = self.make_branch_and_tree('mainline',
1413
trunk_tree.commit('mainline')
1414
# and a branch from it which is stacked
1415
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1416
out, err = self.run_bzr('info newbranch')
1418
"""Standalone tree (format: 1.6)
1420
branch root: newbranch
1423
parent branch: mainline
1424
stacked on: mainline
1426
self.assertEqual("", err)