13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
18
"""Tests for the info command of bzr."""
22
23
from bzrlib import (
31
27
from bzrlib.osutils import format_date
32
28
from bzrlib.tests import TestSkipped
40
36
location = "C:/i/do/not/exist/"
42
38
location = "/i/do/not/exist/"
43
out, err = self.run_bzr('info '+location, retcode=3)
39
out, err = self.runbzr('info '+location, retcode=3)
44
40
self.assertEqual(out, '')
45
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
41
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
47
43
def test_info_standalone(self):
48
44
transport = self.get_transport()
52
48
self.build_tree(['standalone/a'])
54
50
branch1 = tree1.branch
56
out, err = self.run_bzr('info standalone')
58
"""Standalone tree (format: weave)
60
branch root: standalone
62
self.assertEqual('', err)
64
# Standalone branch - verbose mode
65
out, err = self.run_bzr('info standalone -v')
67
"""Standalone tree (format: weave)
69
branch root: standalone
72
control: All-in-one format 6
73
working tree: Working tree format 2
74
branch: Branch format 4
75
repository: Weave repository format 6
85
0 versioned subdirectories
93
self.assertEqual('', err)
95
# Standalone branch - really verbose mode
96
out, err = self.run_bzr('info standalone -vv')
98
"""Standalone tree (format: weave)
100
branch root: standalone
103
control: All-in-one format 6
104
working tree: Working tree format 2
105
branch: Branch format 4
106
repository: Weave repository format 6
116
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)
125
79
self.assertEqual('', err)
126
80
tree1.commit('commit one')
127
81
rev = branch1.repository.get_revision(branch1.revision_history()[0])
130
84
# Branch standalone with push location
131
85
branch2 = branch1.bzrdir.sprout('branch').open_branch()
132
86
branch2.set_push_location(branch1.bzrdir.root_transport.base)
134
out, err = self.run_bzr('info branch')
135
self.assertEqualDiff(
136
"""Standalone tree (format: weave)
141
push branch: standalone
142
parent branch: standalone
144
self.assertEqual('', err)
146
out, err = self.run_bzr('info branch --verbose')
147
self.assertEqualDiff(
148
"""Standalone tree (format: weave)
153
push branch: standalone
154
parent branch: standalone
87
out, err = self.runbzr('info branch --verbose')
157
97
control: All-in-one format 6
175
116
first revision: %s
176
117
latest revision: %s
180
""" % (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,
182
131
self.assertEqual('', err)
185
134
# (creates backup as unknown)
186
135
branch1.bzrdir.sprout('bound')
187
136
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
188
upgrade.upgrade('bound', knit1_format)
189
branch3 = bzrdir.BzrDir.open('bound').open_branch()
137
bzrlib.upgrade.upgrade('bound', knit1_format)
138
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
190
139
branch3.bind(branch1)
191
140
bound_tree = branch3.bzrdir.open_workingtree()
192
out, err = self.run_bzr('info -v bound')
141
out, err = self.runbzr('info bound')
193
142
self.assertEqualDiff(
194
"""Checkout (format: knit)
197
checkout of branch: standalone
145
checkout of branch: %s
199
147
Related branches:
200
parent branch: standalone
203
151
control: Meta directory format 1
226
""" % (bound_tree._format.get_format_description(),
175
""" % (branch3.bzrdir.root_transport.base,
176
branch1.bzrdir.root_transport.base,
177
branch1.bzrdir.root_transport.base,
178
bound_tree._format.get_format_description(),
227
179
branch3._format.get_format_description(),
228
180
branch3.repository._format.get_format_description(),
229
181
datestring_first, datestring_first,
182
# poking at _revision_store isn't all that clean, but neither is
183
# having the ui test dependent on the exact overhead of a given store.
184
branch3.repository._revision_store.total_size(
185
branch3.repository.get_transaction())[1] / 1024,
231
187
self.assertEqual('', err)
233
189
# Checkout standalone (same as above, but does not have parent set)
234
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
190
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
235
191
format=knit1_format)
236
192
branch4.bind(branch1)
237
193
branch4.bzrdir.open_workingtree().update()
238
out, err = self.run_bzr('info checkout --verbose')
194
out, err = self.runbzr('info checkout --verbose')
239
195
self.assertEqualDiff(
240
"""Checkout (format: knit)
242
checkout root: checkout
243
checkout of branch: standalone
198
checkout of branch: %s
246
201
control: Meta directory format 1
264
220
first revision: %s
265
221
latest revision: %s
269
""" % (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(),
270
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,
272
235
self.assertEqual('', err)
274
237
# Lightweight checkout (same as above, different branch and repository)
275
238
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
276
239
branch5 = tree5.branch
277
out, err = self.run_bzr('info -v lightcheckout')
240
out, err = self.runbzr('info lightcheckout')
278
241
self.assertEqualDiff(
279
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root \
280
or 1.9 or 1.9-rich-root \
281
or dirstate or dirstate-tags or \
282
pack-0.92 or rich-root or rich-root-pack)
284
light checkout root: lightcheckout
285
checkout of branch: standalone
243
light checkout root: %s
244
checkout of branch: %s
288
247
control: Meta directory format 1
311
""" % (datestring_first, datestring_first,), out)
271
""" % (tree5.bzrdir.root_transport.base,
272
branch1.bzrdir.root_transport.base,
273
datestring_first, datestring_first,
312
275
self.assertEqual('', err)
314
277
# Update initial standalone branch
319
282
datestring_last = format_date(rev.timestamp, rev.timezone)
321
284
# Out of date branched standalone branch will not be detected
322
out, err = self.run_bzr('info -v branch')
285
out, err = self.runbzr('info branch')
323
286
self.assertEqualDiff(
324
"""Standalone tree (format: weave)
328
290
Related branches:
329
push branch: standalone
330
parent branch: standalone
292
publish to branch: %s
333
295
control: All-in-one format 6
356
""" % (datestring_first, datestring_first,
319
""" % (branch2.bzrdir.root_transport.base,
320
branch1.bzrdir.root_transport.base,
321
branch1.bzrdir.root_transport.base,
322
datestring_first, datestring_first,
358
324
self.assertEqual('', err)
360
326
# Out of date bound branch
361
out, err = self.run_bzr('info -v bound')
327
out, err = self.runbzr('info bound')
362
328
self.assertEqualDiff(
363
"""Checkout (format: knit)
366
checkout of branch: standalone
331
checkout of branch: %s
368
333
Related branches:
369
parent branch: standalone
372
337
control: Meta directory format 1
397
""" % (branch3.repository._format.get_format_description(),
363
""" % (branch3.bzrdir.root_transport.base,
364
branch1.bzrdir.root_transport.base,
365
branch1.bzrdir.root_transport.base,
366
branch3.repository._format.get_format_description(),
398
367
datestring_first, datestring_first,
368
# poking at _revision_store isn't all that clean, but neither is
369
# having the ui test dependent on the exact overhead of a given store.
370
branch3.repository._revision_store.total_size(
371
branch3.repository.get_transaction())[1] / 1024,
400
373
self.assertEqual('', err)
402
375
# Out of date checkout
403
out, err = self.run_bzr('info -v checkout')
376
out, err = self.runbzr('info checkout')
404
377
self.assertEqualDiff(
405
"""Checkout (format: knit)
407
checkout root: checkout
408
checkout of branch: standalone
380
checkout of branch: %s
411
383
control: Meta directory format 1
436
""" % (branch4.repository._format.get_format_description(),
409
""" % (branch4.bzrdir.root_transport.base,
410
branch1.bzrdir.root_transport.base,
411
branch4.repository._format.get_format_description(),
437
412
datestring_first, datestring_first,
413
# poking at _revision_store isn't all that clean, but neither is
414
# having the ui test dependent on the exact overhead of a given store.
415
branch4.repository._revision_store.total_size(
416
branch4.repository.get_transaction())[1] / 1024,
439
418
self.assertEqual('', err)
441
420
# Out of date lightweight checkout
442
out, err = self.run_bzr('info lightcheckout --verbose')
421
out, err = self.runbzr('info lightcheckout --verbose')
443
422
self.assertEqualDiff(
444
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
445
1.9 or 1.9-rich-root or \
446
dirstate or dirstate-tags or \
447
pack-0.92 or rich-root or rich-root-pack)
449
light checkout root: lightcheckout
450
checkout of branch: standalone
424
light checkout root: %s
425
checkout of branch: %s
453
428
control: Meta directory format 1
473
449
first revision: %s
474
450
latest revision: %s
478
""" % (datestring_first, datestring_last,), out)
455
""" % (tree5.bzrdir.root_transport.base,
456
branch1.bzrdir.root_transport.base,
457
datestring_first, datestring_last,
479
459
self.assertEqual('', err)
481
461
def test_info_standalone_no_tree(self):
483
463
format = bzrdir.format_registry.make_bzrdir('default')
484
464
branch = self.make_branch('branch')
485
465
repo = branch.repository
486
out, err = self.run_bzr('info branch -v')
466
out, err = self.runbzr('info branch')
487
467
self.assertEqualDiff(
488
"""Standalone branch (format: %s)
493
472
control: Meta directory format 1
502
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
482
""" % (branch.bzrdir.root_transport.base,
503
483
format.get_branch_format().get_format_description(),
504
484
format.repository_format.get_format_description(),
512
492
# Create shared repository
513
493
repo = self.make_repository('repo', shared=True, format=format)
514
494
repo.set_make_working_trees(False)
515
out, err = self.run_bzr('info -v repo')
495
out, err = self.runbzr('info repo')
516
496
self.assertEqualDiff(
517
"""Shared repository (format: dirstate or dirstate-tags or knit)
519
498
shared repository: %s
532
513
repo.bzrdir.root_transport.mkdir('branch')
533
514
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
535
out, err = self.run_bzr('info -v repo/branch')
516
out, err = self.runbzr('info repo/branch')
536
517
self.assertEqualDiff(
537
"""Repository branch (format: dirstate or knit)
539
shared repository: repo
540
repository branch: repo/branch
519
shared repository: %s
520
repository branch: branch
543
523
control: Meta directory format 1
552
""" % (format.get_branch_format().get_format_description(),
533
""" % (repo.bzrdir.root_transport.base,
534
format.get_branch_format().get_format_description(),
553
535
format.repository_format.get_format_description(),
555
537
self.assertEqual('', err)
557
539
# Create lightweight checkout
558
540
transport.mkdir('tree')
559
541
transport.mkdir('tree/lightcheckout')
560
tree2 = branch1.create_checkout('tree/lightcheckout',
542
tree2 = branch1.create_checkout('tree/lightcheckout',
561
543
lightweight=True)
562
544
branch2 = tree2.branch
563
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
564
shared_repo=repo, repo_branch=branch1, verbose=True)
545
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2,
566
548
# Create normal checkout
567
549
tree3 = branch1.create_checkout('tree/checkout')
574
556
tree2.commit('commit one')
575
557
rev = repo.get_revision(branch2.revision_history()[0])
576
558
datestring_first = format_date(rev.timestamp, rev.timezone)
577
out, err = self.run_bzr('info tree/lightcheckout --verbose')
559
out, err = self.runbzr('info tree/lightcheckout --verbose')
578
560
self.assertEqualDiff(
579
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
580
1.9 or 1.9-rich-root or \
581
dirstate or dirstate-tags or \
582
pack-0.92 or rich-root or rich-root-pack)
584
light checkout root: tree/lightcheckout
585
checkout of branch: repo/branch
586
shared repository: repo
562
light checkout root: %s
563
shared repository: %s
564
repository branch: branch
589
567
control: Meta directory format 1
607
586
first revision: %s
608
587
latest revision: %s
612
""" % (format.get_branch_format().get_format_description(),
592
""" % (tree2.bzrdir.root_transport.base,
593
repo.bzrdir.root_transport.base,
594
format.get_branch_format().get_format_description(),
613
595
format.repository_format.get_format_description(),
614
596
datestring_first, datestring_first,
597
# poking at _revision_store isn't all that clean, but neither is
598
# having the ui test dependent on the exact overhead of a given store.
599
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
616
601
self.assertEqual('', err)
618
603
# Out of date checkout
619
out, err = self.run_bzr('info -v tree/checkout')
604
out, err = self.runbzr('info tree/checkout')
620
605
self.assertEqualDiff(
621
"""Checkout (format: dirstate)
623
checkout root: tree/checkout
624
checkout of branch: repo/branch
608
checkout of branch: %s
627
611
control: Meta directory format 1
649
""" % (format.get_branch_format().get_format_description(),
634
""" % (tree3.bzrdir.root_transport.base,
635
branch1.bzrdir.root_transport.base,
636
format.get_branch_format().get_format_description(),
650
637
format.repository_format.get_format_description(),
652
639
self.assertEqual('', err)
656
643
self.build_tree(['tree/checkout/b'])
658
out, err = self.run_bzr('info tree/checkout --verbose')
645
out, err = self.runbzr('info tree/checkout --verbose')
659
646
self.assertEqualDiff(
660
"""Checkout (format: dirstate)
662
checkout root: tree/checkout
663
checkout of branch: repo/branch
649
checkout of branch: %s
666
652
control: Meta directory format 1
684
671
first revision: %s
685
672
latest revision: %s
689
""" % (format.get_branch_format().get_format_description(),
677
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
678
format.get_branch_format().get_format_description(),
690
679
format.repository_format.get_format_description(),
691
680
datestring_first, datestring_first,
681
# poking at _revision_store isn't all that clean, but neither is
682
# having the ui test dependent on the exact overhead of a given store.
683
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
693
685
self.assertEqual('', err)
694
686
tree3.commit('commit two')
696
688
# Out of date lightweight checkout
697
689
rev = repo.get_revision(branch1.revision_history()[-1])
698
690
datestring_last = format_date(rev.timestamp, rev.timezone)
699
out, err = self.run_bzr('info tree/lightcheckout --verbose')
691
out, err = self.runbzr('info tree/lightcheckout --verbose')
700
692
self.assertEqualDiff(
701
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
702
1.9 or 1.9-rich-root or \
703
dirstate or dirstate-tags or \
704
pack-0.92 or rich-root or rich-root-pack)
706
light checkout root: tree/lightcheckout
707
checkout of branch: repo/branch
708
shared repository: repo
694
light checkout root: %s
695
shared repository: %s
696
repository branch: branch
711
699
control: Meta directory format 1
731
720
first revision: %s
732
721
latest revision: %s
736
""" % (format.get_branch_format().get_format_description(),
726
""" % (tree2.bzrdir.root_transport.base,
727
repo.bzrdir.root_transport.base,
728
format.get_branch_format().get_format_description(),
737
729
format.repository_format.get_format_description(),
738
730
datestring_first, datestring_last,
731
# poking at _revision_store isn't all that clean, but neither is
732
# having the ui test dependent on the exact overhead of a given store.
733
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
740
735
self.assertEqual('', err)
742
737
# Show info about shared branch
743
out, err = self.run_bzr('info repo/branch --verbose')
738
out, err = self.runbzr('info repo/branch --verbose')
744
739
self.assertEqualDiff(
745
"""Repository branch (format: dirstate or knit)
747
shared repository: repo
748
repository branch: repo/branch
741
shared repository: %s
742
repository branch: branch
751
745
control: Meta directory format 1
758
753
first revision: %s
759
754
latest revision: %s
763
""" % (format.get_branch_format().get_format_description(),
759
""" % (repo.bzrdir.root_transport.base,
760
format.get_branch_format().get_format_description(),
764
761
format.repository_format.get_format_description(),
765
762
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
767
self.assertEqual('', err)
769
769
# Show info about repository with revisions
770
out, err = self.run_bzr('info -v repo')
770
out, err = self.runbzr('info repo')
771
771
self.assertEqualDiff(
772
"""Shared repository (format: dirstate or dirstate-tags or knit)
774
shared repository: repo
773
shared repository: %s
777
776
control: Meta directory format 1
782
""" % (format.repository_format.get_format_description(),
782
""" % (repo.bzrdir.root_transport.base,
783
format.repository_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,
784
788
self.assertEqual('', err)
790
794
# Create shared repository with working trees
791
795
repo = self.make_repository('repo', shared=True, format=format)
792
796
repo.set_make_working_trees(True)
793
out, err = self.run_bzr('info -v repo')
797
out, err = self.runbzr('info repo')
794
798
self.assertEqualDiff(
795
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
797
shared repository: repo
800
shared repository: %s
800
803
control: Meta directory format 1
815
820
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
817
822
# Empty first branch
818
out, err = self.run_bzr('info repo/branch1 --verbose')
823
out, err = self.runbzr('info repo/branch1 --verbose')
819
824
self.assertEqualDiff(
820
"""Repository tree (format: knit)
822
shared repository: repo
823
repository branch: repo/branch1
826
shared repository: %s
827
repository checkout: branch1
826
830
control: Meta directory format 1
846
""" % (format.get_branch_format().get_format_description(),
852
""" % (repo.bzrdir.root_transport.base,
853
format.get_branch_format().get_format_description(),
847
854
format.repository_format.get_format_description(),
849
856
self.assertEqual('', err)
855
862
tree1.commit('commit one')
856
863
rev = repo.get_revision(branch1.revision_history()[0])
857
864
datestring_first = format_date(rev.timestamp, rev.timezone)
858
out, err = self.run_bzr('info -v repo/branch1')
865
out, err = self.runbzr('info repo/branch1')
859
866
self.assertEqualDiff(
860
"""Repository tree (format: knit)
862
shared repository: repo
863
repository branch: repo/branch1
868
shared repository: %s
869
repository checkout: branch1
866
872
control: Meta directory format 1
889
""" % (format.get_branch_format().get_format_description(),
896
""" % (repo.bzrdir.root_transport.base,
897
format.get_branch_format().get_format_description(),
890
898
format.repository_format.get_format_description(),
891
899
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,
893
904
self.assertEqual('', err)
895
906
# Out of date second branch
896
out, err = self.run_bzr('info repo/branch2 --verbose')
907
out, err = self.runbzr('info repo/branch2 --verbose')
897
908
self.assertEqualDiff(
898
"""Repository tree (format: knit)
900
shared repository: repo
901
repository branch: repo/branch2
910
shared repository: %s
911
repository checkout: branch2
903
913
Related branches:
904
parent branch: repo/branch1
907
917
control: Meta directory format 1
927
""" % (format.get_branch_format().get_format_description(),
939
""" % (repo.bzrdir.root_transport.base,
940
branch1.bzrdir.root_transport.base,
941
format.get_branch_format().get_format_description(),
928
942
format.repository_format.get_format_description(),
943
# poking at _revision_store isn't all that clean, but neither is
944
# having the ui test dependent on the exact overhead of a given store.
945
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
930
947
self.assertEqual('', err)
932
949
# Update second branch
933
950
tree2 = branch2.bzrdir.open_workingtree()
934
951
tree2.pull(branch1)
935
out, err = self.run_bzr('info -v repo/branch2')
952
out, err = self.runbzr('info repo/branch2')
936
953
self.assertEqualDiff(
937
"""Repository tree (format: knit)
939
shared repository: repo
940
repository branch: repo/branch2
955
shared repository: %s
956
repository checkout: branch2
942
958
Related branches:
943
parent branch: repo/branch1
946
962
control: Meta directory format 1
969
""" % (format.get_branch_format().get_format_description(),
986
""" % (repo.bzrdir.root_transport.base,
987
branch1.bzrdir.root_transport.base,
988
format.get_branch_format().get_format_description(),
970
989
format.repository_format.get_format_description(),
971
990
datestring_first, datestring_first,
991
# poking at _revision_store isn't all that clean, but neither is
992
# having the ui test dependent on the exact overhead of a given store.
993
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
973
995
self.assertEqual('', err)
975
997
# Show info about repository with revisions
976
out, err = self.run_bzr('info -v repo')
998
out, err = self.runbzr('info repo')
977
999
self.assertEqualDiff(
978
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
980
shared repository: repo
1001
shared repository: %s
983
1004
control: Meta directory format 1
990
""" % (format.repository_format.get_format_description(),
1012
""" % (repo.bzrdir.root_transport.base,
1013
format.repository_format.get_format_description(),
1014
# poking at _revision_store isn't all that clean, but neither is
1015
# having the ui test dependent on the exact overhead of a given store.
1016
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
993
1019
self.assertEqual('', err)
995
1021
def test_info_shared_repository_with_tree_in_root(self):
996
1022
format = bzrdir.format_registry.make_bzrdir('knit')
997
1023
transport = self.get_transport()
999
1025
# Create shared repository with working trees
1000
1026
repo = self.make_repository('repo', shared=True, format=format)
1001
1027
repo.set_make_working_trees(True)
1002
out, err = self.run_bzr('info -v repo')
1028
out, err = self.runbzr('info repo')
1003
1029
self.assertEqualDiff(
1004
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1006
shared repository: repo
1031
shared repository: %s
1009
1034
control: Meta directory format 1
1052
""" % (format.get_branch_format().get_format_description(),
1079
""" % (repo.bzrdir.root_transport.base,
1080
format.get_branch_format().get_format_description(),
1053
1081
format.repository_format.get_format_description(),
1055
1083
self.assertEqual('', err)
1057
def assertCheckoutStatusOutput(self,
1085
def assertCheckoutStatusOutput(self,
1058
1086
command_string, lco_tree, shared_repo=None,
1059
1087
repo_branch=None,
1060
1088
tree_locked=False,
1061
1089
branch_locked=False, repo_locked=False,
1063
light_checkout=True,
1064
checkout_root=None):
1065
"""Check the output of info in a checkout.
1091
light_checkout=True):
1092
"""Check the output of info in a light checkout tree.
1067
1094
This is not quite a mirror of the info code: rather than using the
1068
1095
tree being examined to predict output, it uses a bunch of flags which
1069
1096
allow us, the test writers, to document what *should* be present in
1070
1097
the output. Removing this separation would remove the value of the
1073
1100
:param path: the path to the light checkout.
1074
1101
:param lco_tree: the tree object for the light checkout.
1075
1102
:param shared_repo: A shared repository is in use, expect that in
1079
1106
:param tree_locked: If true, expect the tree to be locked.
1080
1107
:param branch_locked: If true, expect the branch to be locked.
1081
1108
:param repo_locked: If true, expect the repository to be locked.
1082
Note that the lco_tree.branch.repository is inspected, and if is not
1083
actually locked then this parameter is overridden. This is because
1084
pack repositories do not have any public API for obtaining an
1085
exclusive repository wide lock.
1086
:param verbose: verbosity level: 2 or higher to show committers
1109
:param verbose: If true, expect verbose output
1088
def friendly_location(url):
1089
path = urlutils.unescape_for_display(url, 'ascii')
1091
return osutils.relpath(osutils.getcwd(), path)
1092
except errors.PathNotChild:
1096
# We expect this to fail because of locking errors.
1097
# (A write-locked file cannot be read-locked
1098
# in the different process -- either on win32 or on linux).
1111
if tree_locked and sys.platform == 'win32':
1112
# We expect this to fail because of locking errors. (A write-locked
1113
# file cannot be read-locked in the same process).
1099
1114
# This should be removed when the locking errors are fixed.
1100
self.expectFailure('OS locks are exclusive '
1101
'for different processes (Bug #174055)',
1102
self.run_bzr_subprocess,
1103
'info ' + command_string)
1104
out, err = self.run_bzr('info %s' % command_string)
1106
(True, True): 'Lightweight checkout',
1107
(True, False): 'Repository checkout',
1108
(False, True): 'Lightweight checkout',
1109
(False, False): 'Checkout',
1110
}[(shared_repo is not None, light_checkout)]
1111
format = {True: '1.6 or 1.6.1-rich-root'
1112
' or 1.9 or 1.9-rich-root'
1113
' or dirstate or dirstate-tags or pack-0.92'
1114
' or rich-root or rich-root-pack',
1115
False: 'dirstate'}[light_checkout]
1117
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1115
args = command_string.split(' ')
1116
self.run_bzr_error([], 'info', *args)
1118
out, err = self.runbzr('info %s' % command_string)
1118
1119
if repo_locked or branch_locked or tree_locked:
1119
1120
def locked_message(a_bool):
1132
1133
locked_message(repo_locked)))
1134
1135
expected_lock_output = ''
1137
1136
if light_checkout:
1138
tree_data = (" light checkout root: %s\n" %
1139
friendly_location(lco_tree.bzrdir.root_transport.base))
1141
if lco_tree.branch.get_bound_location() is not None:
1142
tree_data += ("%s checkout root: %s\n" % (extra_space,
1143
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1137
tree_data = (" light checkout root: %s" %
1138
lco_tree.bzrdir.root_transport.base)
1140
tree_data = (" checkout root: %s" %
1141
lco_tree.bzrdir.root_transport.base)
1144
1142
if shared_repo is not None:
1145
1143
branch_data = (
1146
" checkout of branch: %s\n"
1147
" shared repository: %s\n" %
1148
(friendly_location(repo_branch.bzrdir.root_transport.base),
1149
friendly_location(shared_repo.bzrdir.root_transport.base)))
1144
" shared repository: %s\n"
1145
" repository branch: branch\n" %
1146
shared_repo.bzrdir.root_transport.base)
1150
1147
elif repo_branch is not None:
1151
1148
branch_data = (
1152
"%s checkout of branch: %s\n" %
1154
friendly_location(repo_branch.bzrdir.root_transport.base)))
1149
" checkout of branch: %s\n" %
1150
repo_branch.bzrdir.root_transport.base)
1156
branch_data = (" checkout of branch: %s\n" %
1152
branch_data = (" checkout of branch: %s\n" %
1157
1153
lco_tree.branch.bzrdir.root_transport.base)
1160
1156
verbose_info = ' 0 committers\n'
1162
1158
verbose_info = ''
1164
1160
self.assertEqualDiff(
1169
1165
control: Meta directory format 1
1170
1166
working tree: %s
1202
1197
transport = self.get_transport()
1203
1198
# Create shared repository with a branch
1204
1199
repo = self.make_repository('repo', shared=True,
1205
format=bzrdir.BzrDirMetaFormat1())
1200
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1206
1201
repo.set_make_working_trees(False)
1207
1202
repo.bzrdir.root_transport.mkdir('branch')
1208
1203
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1209
format=bzrdir.BzrDirMetaFormat1())
1204
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1210
1205
# Do a heavy checkout
1211
1206
transport.mkdir('tree')
1212
1207
transport.mkdir('tree/checkout')
1213
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1214
format=bzrdir.BzrDirMetaFormat1())
1208
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1209
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1215
1210
co_branch.bind(repo_branch)
1216
1211
# Do a light checkout of the heavy one
1217
1212
transport.mkdir('tree/lightcheckout')
1218
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1219
branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1213
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1214
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1220
1215
lco_dir.create_workingtree()
1221
1216
lco_tree = lco_dir.open_workingtree()
1227
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1228
repo_branch=repo_branch,
1229
verbose=True, light_checkout=True)
1222
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1231
1224
lco_tree.branch.repository.lock_write()
1233
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1234
lco_tree, repo_branch=repo_branch,
1235
repo_locked=True, verbose=True, light_checkout=True)
1226
self.assertCheckoutStatusOutput('tree/lightcheckout',
1237
1230
lco_tree.branch.repository.unlock()
1239
1232
lco_tree.branch.lock_write()
1241
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1234
self.assertCheckoutStatusOutput('tree/lightcheckout',
1243
1236
branch_locked=True,
1245
repo_branch=repo_branch,
1248
1239
lco_tree.branch.unlock()
1250
1241
lco_tree.lock_write()
1252
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1253
lco_tree, repo_branch=repo_branch,
1243
self.assertCheckoutStatusOutput('tree/lightcheckout',
1254
1245
tree_locked=True,
1255
1246
branch_locked=True,
1259
1249
lco_tree.unlock()
1261
1251
lco_tree.lock_write()
1262
1252
lco_tree.branch.repository.unlock()
1264
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1265
lco_tree, repo_branch=repo_branch,
1254
self.assertCheckoutStatusOutput('tree/lightcheckout',
1266
1256
tree_locked=True,
1270
1259
lco_tree.branch.repository.lock_write()
1271
1260
lco_tree.unlock()
1285
1273
lco_tree.branch.unlock()
1286
1274
lco_tree.branch.repository.lock_write()
1288
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1289
lco_tree, repo_branch=repo_branch,
1276
self.assertCheckoutStatusOutput('tree/lightcheckout',
1290
1278
tree_locked=True,
1294
1281
lco_tree.branch.repository.unlock()
1295
1282
lco_tree.branch.lock_write()
1298
1285
lco_tree.branch.lock_write()
1299
1286
lco_tree.branch.repository.unlock()
1301
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1302
lco_tree, repo_branch=repo_branch,
1288
self.assertCheckoutStatusOutput('tree/lightcheckout',
1306
1292
lco_tree.branch.repository.lock_write()
1307
1293
lco_tree.branch.unlock()
1315
1301
raise TestSkipped("don't use oslocks on win32 in unix manner")
1317
1303
tree = self.make_branch_and_tree('branch',
1318
format=bzrdir.BzrDirFormat6())
1304
format=bzrlib.bzrdir.BzrDirFormat6())
1320
1306
# Test all permutations of locking the working tree, branch and repository
1321
1307
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1354
""" % ('branch', tree.branch.repository._format.get_format_description(),
1340
""" % (tree.bzrdir.root_transport.base,
1341
tree.branch.repository._format.get_format_description(),
1356
1343
self.assertEqual('', err)
1358
1345
tree.lock_write()
1359
out, err = self.run_bzr('info -v branch')
1346
out, err = self.runbzr('info branch')
1360
1347
self.assertEqualDiff(
1361
"""Standalone tree (format: weave)
1363
1349
branch root: %s
1386
""" % ('branch', tree.branch.repository._format.get_format_description(),
1373
""" % (tree.bzrdir.root_transport.base,
1374
tree.branch.repository._format.get_format_description(),
1388
1376
self.assertEqual('', err)
1391
def test_info_stacked(self):
1392
# We have a mainline
1393
trunk_tree = self.make_branch_and_tree('mainline',
1395
trunk_tree.commit('mainline')
1396
# and a branch from it which is stacked
1397
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1398
out, err = self.run_bzr('info newbranch')
1400
"""Standalone tree (format: 1.6)
1402
branch root: newbranch
1405
parent branch: mainline
1406
stacked on: mainline
1408
self.assertEqual("", err)