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 (
32
from bzrlib.transport import memory
35
class TestInfo(tests.TestCaseWithTransport):
38
super(TestInfo, self).setUp()
39
self._repo_strings = "2a"
27
from bzrlib.osutils import format_date
28
from bzrlib.tests import TestSkipped
29
from bzrlib.tests.blackbox import ExternalBase
32
class TestInfo(ExternalBase):
41
34
def test_info_non_existing(self):
42
self.vfs_transport_factory = memory.MemoryServer
43
location = self.get_url()
44
out, err = self.run_bzr('info '+location, retcode=3)
35
if sys.platform == "win32":
36
location = "C:/i/do/not/exist/"
38
location = "/i/do/not/exist/"
39
out, err = self.runbzr('info '+location, retcode=3)
45
40
self.assertEqual(out, '')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
41
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
48
43
def test_info_standalone(self):
49
44
transport = self.get_transport()
53
48
self.build_tree(['standalone/a'])
55
50
branch1 = tree1.branch
57
out, err = self.run_bzr('info standalone')
59
"""Standalone tree (format: weave)
61
branch root: standalone
63
self.assertEqual('', err)
65
# Standalone branch - verbose mode
66
out, err = self.run_bzr('info standalone -v')
68
"""Standalone tree (format: weave)
70
branch root: standalone
73
control: All-in-one format 6
74
working tree: Working tree format 2
75
branch: Branch format 4
76
repository: Weave repository format 6
86
0 versioned subdirectories
94
self.assertEqual('', err)
96
# Standalone branch - really verbose mode
97
out, err = self.run_bzr('info standalone -vv')
99
"""Standalone tree (format: weave)
101
branch root: standalone
51
out, err = self.runbzr('info standalone -v')
53
"""Standalone tree (format: weave)
104
58
control: All-in-one format 6
80
""" % branch1.bzrdir.root_transport.base, out)
126
81
self.assertEqual('', err)
127
82
tree1.commit('commit one')
128
83
rev = branch1.repository.get_revision(branch1.revision_history()[0])
129
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
84
datestring_first = format_date(rev.timestamp, rev.timezone)
131
86
# Branch standalone with push location
132
87
branch2 = branch1.bzrdir.sprout('branch').open_branch()
133
88
branch2.set_push_location(branch1.bzrdir.root_transport.base)
135
out, err = self.run_bzr('info branch')
136
self.assertEqualDiff(
137
"""Standalone tree (format: weave)
142
push branch: standalone
143
parent branch: standalone
145
self.assertEqual('', err)
147
out, err = self.run_bzr('info branch --verbose')
148
self.assertEqualDiff(
149
"""Standalone tree (format: weave)
154
push branch: standalone
155
parent branch: standalone
89
out, err = self.runbzr('info branch --verbose')
91
"""Standalone tree (format: weave)
158
100
control: All-in-one format 6
176
119
first revision: %s
177
120
latest revision: %s
181
""" % (datestring_first, datestring_first,
125
""" % (branch2.bzrdir.root_transport.base,
126
branch1.bzrdir.root_transport.base,
127
branch1.bzrdir.root_transport.base,
128
datestring_first, datestring_first,
129
# poking at _revision_store isn't all that clean, but neither is
130
# having the ui test dependent on the exact overhead of a given store.
131
branch2.repository._revision_store.total_size(
132
branch2.repository.get_transaction())[1] / 1024,
183
134
self.assertEqual('', err)
186
137
# (creates backup as unknown)
187
138
branch1.bzrdir.sprout('bound')
188
139
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
189
upgrade.upgrade('bound', knit1_format)
190
branch3 = bzrdir.BzrDir.open('bound').open_branch()
140
bzrlib.upgrade.upgrade('bound', knit1_format)
141
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
191
142
branch3.bind(branch1)
192
143
bound_tree = branch3.bzrdir.open_workingtree()
193
out, err = self.run_bzr('info -v bound')
144
out, err = self.runbzr('info -v bound')
194
145
self.assertEqualDiff(
195
146
"""Checkout (format: knit)
198
checkout of branch: standalone
149
checkout of branch: %s
200
151
Related branches:
201
parent branch: standalone
204
155
control: Meta directory format 1
217
168
0 versioned subdirectories
222
174
first revision: %s
223
175
latest revision: %s
227
""" % (bound_tree._format.get_format_description(),
180
""" % (branch3.bzrdir.root_transport.base,
181
branch1.bzrdir.root_transport.base,
182
branch1.bzrdir.root_transport.base,
183
bound_tree._format.get_format_description(),
228
184
branch3._format.get_format_description(),
229
185
branch3.repository._format.get_format_description(),
230
186
datestring_first, datestring_first,
187
# poking at _revision_store isn't all that clean, but neither is
188
# having the ui test dependent on the exact overhead of a given store.
189
branch3.repository._revision_store.total_size(
190
branch3.repository.get_transaction())[1] / 1024,
232
192
self.assertEqual('', err)
234
194
# Checkout standalone (same as above, but does not have parent set)
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
195
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
236
196
format=knit1_format)
237
197
branch4.bind(branch1)
238
198
branch4.bzrdir.open_workingtree().update()
239
out, err = self.run_bzr('info checkout --verbose')
199
out, err = self.runbzr('info checkout --verbose')
240
200
self.assertEqualDiff(
241
201
"""Checkout (format: knit)
243
checkout root: checkout
244
checkout of branch: standalone
204
checkout of branch: %s
247
207
control: Meta directory format 1
265
226
first revision: %s
266
227
latest revision: %s
270
""" % (branch4.repository._format.get_format_description(),
232
""" % (branch4.bzrdir.root_transport.base,
233
branch1.bzrdir.root_transport.base,
234
branch4.repository._format.get_format_description(),
271
235
datestring_first, datestring_first,
236
# poking at _revision_store isn't all that clean, but neither is
237
# having the ui test dependent on the exact overhead of a given store.
238
branch4.repository._revision_store.total_size(
239
branch4.repository.get_transaction())[1] / 1024,
273
241
self.assertEqual('', err)
275
243
# Lightweight checkout (same as above, different branch and repository)
276
244
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
277
245
branch5 = tree5.branch
278
out, err = self.run_bzr('info -v lightcheckout')
246
out, err = self.runbzr('info -v lightcheckout')
279
247
self.assertEqualDiff(
280
"""Lightweight checkout (format: %s)
248
"""Lightweight checkout (format: dirstate / dirstate-tags)
282
light checkout root: lightcheckout
283
checkout of branch: standalone
250
light checkout root: %s
251
checkout of branch: %s
286
254
control: Meta directory format 1
287
working tree: Working tree format 6
255
working tree: Working tree format 4
288
256
branch: Branch format 4
289
257
repository: Weave repository format 6
304
273
first revision: %s
305
274
latest revision: %s
309
""" % (self._repo_strings, datestring_first, datestring_first,), out)
279
""" % (tree5.bzrdir.root_transport.base,
280
branch1.bzrdir.root_transport.base,
281
datestring_first, datestring_first,
310
283
self.assertEqual('', err)
312
285
# Update initial standalone branch
315
288
tree1.commit('commit two')
316
289
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
317
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
290
datestring_last = format_date(rev.timestamp, rev.timezone)
319
292
# Out of date branched standalone branch will not be detected
320
out, err = self.run_bzr('info -v branch')
293
out, err = self.runbzr('info -v branch')
321
294
self.assertEqualDiff(
322
295
"""Standalone tree (format: weave)
326
299
Related branches:
327
push branch: standalone
328
parent branch: standalone
301
publish to branch: %s
331
304
control: All-in-one format 6
349
323
first revision: %s
350
324
latest revision: %s
354
""" % (datestring_first, datestring_first,
329
""" % (branch2.bzrdir.root_transport.base,
330
branch1.bzrdir.root_transport.base,
331
branch1.bzrdir.root_transport.base,
332
datestring_first, datestring_first,
356
334
self.assertEqual('', err)
358
336
# Out of date bound branch
359
out, err = self.run_bzr('info -v bound')
337
out, err = self.runbzr('info -v bound')
360
338
self.assertEqualDiff(
361
339
"""Checkout (format: knit)
364
checkout of branch: standalone
342
checkout of branch: %s
366
344
Related branches:
367
parent branch: standalone
370
348
control: Meta directory format 1
385
363
0 versioned subdirectories
390
369
first revision: %s
391
370
latest revision: %s
395
""" % (branch3.repository._format.get_format_description(),
375
""" % (branch3.bzrdir.root_transport.base,
376
branch1.bzrdir.root_transport.base,
377
branch1.bzrdir.root_transport.base,
378
branch3.repository._format.get_format_description(),
396
379
datestring_first, datestring_first,
380
# poking at _revision_store isn't all that clean, but neither is
381
# having the ui test dependent on the exact overhead of a given store.
382
branch3.repository._revision_store.total_size(
383
branch3.repository.get_transaction())[1] / 1024,
398
385
self.assertEqual('', err)
400
387
# Out of date checkout
401
out, err = self.run_bzr('info -v checkout')
388
out, err = self.runbzr('info -v checkout')
402
389
self.assertEqualDiff(
403
390
"""Checkout (format: knit)
405
checkout root: checkout
406
checkout of branch: standalone
393
checkout of branch: %s
409
396
control: Meta directory format 1
429
417
first revision: %s
430
418
latest revision: %s
434
""" % (branch4.repository._format.get_format_description(),
423
""" % (branch4.bzrdir.root_transport.base,
424
branch1.bzrdir.root_transport.base,
425
branch4.repository._format.get_format_description(),
435
426
datestring_first, datestring_first,
427
# poking at _revision_store isn't all that clean, but neither is
428
# having the ui test dependent on the exact overhead of a given store.
429
branch4.repository._revision_store.total_size(
430
branch4.repository.get_transaction())[1] / 1024,
437
432
self.assertEqual('', err)
439
434
# Out of date lightweight checkout
440
out, err = self.run_bzr('info lightcheckout --verbose')
435
out, err = self.runbzr('info lightcheckout --verbose')
441
436
self.assertEqualDiff(
442
"""Lightweight checkout (format: %s)
437
"""Lightweight checkout (format: dirstate / dirstate-tags)
444
light checkout root: lightcheckout
445
checkout of branch: standalone
439
light checkout root: %s
440
checkout of branch: %s
448
443
control: Meta directory format 1
449
working tree: Working tree format 6
444
working tree: Working tree format 4
450
445
branch: Branch format 4
451
446
repository: Weave repository format 6
468
464
first revision: %s
469
465
latest revision: %s
473
""" % (self._repo_strings, datestring_first, datestring_last,), out)
470
""" % (tree5.bzrdir.root_transport.base,
471
branch1.bzrdir.root_transport.base,
472
datestring_first, datestring_last,
474
474
self.assertEqual('', err)
476
476
def test_info_standalone_no_tree(self):
478
478
format = bzrdir.format_registry.make_bzrdir('default')
479
479
branch = self.make_branch('branch')
480
480
repo = branch.repository
481
out, err = self.run_bzr('info branch -v')
481
out, err = self.runbzr('info branch -v')
482
482
self.assertEqualDiff(
483
"""Standalone branch (format: %s)
483
"""Standalone branch (format: dirstate / knit)
488
488
control: Meta directory format 1
497
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
499
""" % (branch.bzrdir.root_transport.base,
498
500
format.get_branch_format().get_format_description(),
499
501
format.repository_format.get_format_description(),
507
509
# Create shared repository
508
510
repo = self.make_repository('repo', shared=True, format=format)
509
511
repo.set_make_working_trees(False)
510
out, err = self.run_bzr('info -v repo')
512
out, err = self.runbzr('info -v repo')
511
513
self.assertEqualDiff(
512
"""Shared repository (format: dirstate or dirstate-tags or knit)
514
"""Shared repository (format: dirstate / dirstate-tags / knit)
514
516
shared repository: %s
527
531
repo.bzrdir.root_transport.mkdir('branch')
528
532
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
530
out, err = self.run_bzr('info -v repo/branch')
534
out, err = self.runbzr('info -v repo/branch')
531
535
self.assertEqualDiff(
532
"""Repository branch (format: dirstate or knit)
536
"""Repository branch (format: dirstate / knit)
534
shared repository: repo
535
repository branch: repo/branch
538
shared repository: %s
539
repository branch: branch
538
542
control: Meta directory format 1
547
""" % (format.get_branch_format().get_format_description(),
553
""" % (repo.bzrdir.root_transport.base,
554
format.get_branch_format().get_format_description(),
548
555
format.repository_format.get_format_description(),
550
557
self.assertEqual('', err)
552
559
# Create lightweight checkout
553
560
transport.mkdir('tree')
554
561
transport.mkdir('tree/lightcheckout')
555
tree2 = branch1.create_checkout('tree/lightcheckout',
562
tree2 = branch1.create_checkout('tree/lightcheckout',
556
563
lightweight=True)
557
564
branch2 = tree2.branch
558
565
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
559
shared_repo=repo, repo_branch=branch1, verbose=True)
566
shared_repo=repo, verbose=True)
561
568
# Create normal checkout
562
569
tree3 = branch1.create_checkout('tree/checkout')
569
576
tree2.commit('commit one')
570
577
rev = repo.get_revision(branch2.revision_history()[0])
571
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
572
out, err = self.run_bzr('info tree/lightcheckout --verbose')
578
datestring_first = format_date(rev.timestamp, rev.timezone)
579
out, err = self.runbzr('info tree/lightcheckout --verbose')
573
580
self.assertEqualDiff(
574
"""Lightweight checkout (format: %s)
581
"""Lightweight checkout (format: dirstate / dirstate-tags)
576
light checkout root: tree/lightcheckout
577
checkout of branch: repo/branch
578
shared repository: repo
583
light checkout root: %s
584
shared repository: %s
585
repository branch: branch
581
588
control: Meta directory format 1
582
working tree: Working tree format 6
589
working tree: Working tree format 4
599
607
first revision: %s
600
608
latest revision: %s
604
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
613
""" % (tree2.bzrdir.root_transport.base,
614
repo.bzrdir.root_transport.base,
615
format.get_branch_format().get_format_description(),
605
616
format.repository_format.get_format_description(),
606
617
datestring_first, datestring_first,
618
# poking at _revision_store isn't all that clean, but neither is
619
# having the ui test dependent on the exact overhead of a given store.
620
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
608
622
self.assertEqual('', err)
610
624
# Out of date checkout
611
out, err = self.run_bzr('info -v tree/checkout')
625
out, err = self.runbzr('info -v tree/checkout')
612
626
self.assertEqualDiff(
613
"""Checkout (format: unnamed)
627
"""Checkout (format: dirstate)
615
checkout root: tree/checkout
616
checkout of branch: repo/branch
630
checkout of branch: %s
619
633
control: Meta directory format 1
620
working tree: Working tree format 6
634
working tree: Working tree format 4
641
""" % (format.get_branch_format().get_format_description(),
657
""" % (tree3.bzrdir.root_transport.base,
658
branch1.bzrdir.root_transport.base,
659
format.get_branch_format().get_format_description(),
642
660
format.repository_format.get_format_description(),
644
662
self.assertEqual('', err)
648
666
self.build_tree(['tree/checkout/b'])
650
out, err = self.run_bzr('info tree/checkout --verbose')
668
out, err = self.runbzr('info tree/checkout --verbose')
651
669
self.assertEqualDiff(
652
"""Checkout (format: unnamed)
670
"""Checkout (format: dirstate)
654
checkout root: tree/checkout
655
checkout of branch: repo/branch
673
checkout of branch: %s
658
676
control: Meta directory format 1
659
working tree: Working tree format 6
677
working tree: Working tree format 4
676
695
first revision: %s
677
696
latest revision: %s
681
""" % (format.get_branch_format().get_format_description(),
701
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
702
format.get_branch_format().get_format_description(),
682
703
format.repository_format.get_format_description(),
683
704
datestring_first, datestring_first,
705
# poking at _revision_store isn't all that clean, but neither is
706
# having the ui test dependent on the exact overhead of a given store.
707
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
685
709
self.assertEqual('', err)
686
710
tree3.commit('commit two')
688
712
# Out of date lightweight checkout
689
713
rev = repo.get_revision(branch1.revision_history()[-1])
690
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
691
out, err = self.run_bzr('info tree/lightcheckout --verbose')
714
datestring_last = format_date(rev.timestamp, rev.timezone)
715
out, err = self.runbzr('info tree/lightcheckout --verbose')
692
716
self.assertEqualDiff(
693
"""Lightweight checkout (format: %s)
717
"""Lightweight checkout (format: dirstate / dirstate-tags)
695
light checkout root: tree/lightcheckout
696
checkout of branch: repo/branch
697
shared repository: repo
719
light checkout root: %s
720
shared repository: %s
721
repository branch: branch
700
724
control: Meta directory format 1
701
working tree: Working tree format 6
725
working tree: Working tree format 4
720
745
first revision: %s
721
746
latest revision: %s
725
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
751
""" % (tree2.bzrdir.root_transport.base,
752
repo.bzrdir.root_transport.base,
753
format.get_branch_format().get_format_description(),
726
754
format.repository_format.get_format_description(),
727
755
datestring_first, datestring_last,
756
# poking at _revision_store isn't all that clean, but neither is
757
# having the ui test dependent on the exact overhead of a given store.
758
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
729
760
self.assertEqual('', err)
731
762
# Show info about shared branch
732
out, err = self.run_bzr('info repo/branch --verbose')
763
out, err = self.runbzr('info repo/branch --verbose')
733
764
self.assertEqualDiff(
734
"""Repository branch (format: dirstate or knit)
765
"""Repository branch (format: dirstate / knit)
736
shared repository: repo
737
repository branch: repo/branch
767
shared repository: %s
768
repository branch: branch
740
771
control: Meta directory format 1
747
779
first revision: %s
748
780
latest revision: %s
752
""" % (format.get_branch_format().get_format_description(),
785
""" % (repo.bzrdir.root_transport.base,
786
format.get_branch_format().get_format_description(),
753
787
format.repository_format.get_format_description(),
754
788
datestring_first, datestring_last,
789
# poking at _revision_store isn't all that clean, but neither is
790
# having the ui test dependent on the exact overhead of a given store.
791
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
756
793
self.assertEqual('', err)
758
795
# Show info about repository with revisions
759
out, err = self.run_bzr('info -v repo')
796
out, err = self.runbzr('info -v repo')
760
797
self.assertEqualDiff(
761
"""Shared repository (format: dirstate or dirstate-tags or knit)
798
"""Shared repository (format: dirstate / dirstate-tags / knit)
763
shared repository: repo
800
shared repository: %s
766
803
control: Meta directory format 1
771
""" % (format.repository_format.get_format_description(),
809
""" % (repo.bzrdir.root_transport.base,
810
format.repository_format.get_format_description(),
811
# poking at _revision_store isn't all that clean, but neither is
812
# having the ui test dependent on the exact overhead of a given store.
813
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
773
815
self.assertEqual('', err)
779
821
# Create shared repository with working trees
780
822
repo = self.make_repository('repo', shared=True, format=format)
781
823
repo.set_make_working_trees(True)
782
out, err = self.run_bzr('info -v repo')
824
out, err = self.runbzr('info -v repo')
783
825
self.assertEqualDiff(
784
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
826
"""Shared repository with trees (format: dirstate / dirstate-tags / knit)
786
shared repository: repo
828
shared repository: %s
789
831
control: Meta directory format 1
804
848
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
806
850
# Empty first branch
807
out, err = self.run_bzr('info repo/branch1 --verbose')
851
out, err = self.runbzr('info repo/branch1 --verbose')
808
852
self.assertEqualDiff(
809
853
"""Repository tree (format: knit)
811
shared repository: repo
812
repository branch: repo/branch1
855
shared repository: %s
856
repository checkout: branch1
815
859
control: Meta directory format 1
835
""" % (format.get_branch_format().get_format_description(),
881
""" % (repo.bzrdir.root_transport.base,
882
format.get_branch_format().get_format_description(),
836
883
format.repository_format.get_format_description(),
838
885
self.assertEqual('', err)
844
891
tree1.commit('commit one')
845
892
rev = repo.get_revision(branch1.revision_history()[0])
846
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
847
out, err = self.run_bzr('info -v repo/branch1')
893
datestring_first = format_date(rev.timestamp, rev.timezone)
894
out, err = self.runbzr('info -v repo/branch1')
848
895
self.assertEqualDiff(
849
896
"""Repository tree (format: knit)
851
shared repository: repo
852
repository branch: repo/branch1
898
shared repository: %s
899
repository checkout: branch1
855
902
control: Meta directory format 1
873
921
first revision: %s
874
922
latest revision: %s
878
""" % (format.get_branch_format().get_format_description(),
927
""" % (repo.bzrdir.root_transport.base,
928
format.get_branch_format().get_format_description(),
879
929
format.repository_format.get_format_description(),
880
930
datestring_first, datestring_first,
931
# poking at _revision_store isn't all that clean, but neither is
932
# having the ui test dependent on the exact overhead of a given store.
933
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
882
935
self.assertEqual('', err)
884
937
# Out of date second branch
885
out, err = self.run_bzr('info repo/branch2 --verbose')
938
out, err = self.runbzr('info repo/branch2 --verbose')
886
939
self.assertEqualDiff(
887
940
"""Repository tree (format: knit)
889
shared repository: repo
890
repository branch: repo/branch2
942
shared repository: %s
943
repository checkout: branch2
892
945
Related branches:
893
parent branch: repo/branch1
896
949
control: Meta directory format 1
916
""" % (format.get_branch_format().get_format_description(),
971
""" % (repo.bzrdir.root_transport.base,
972
branch1.bzrdir.root_transport.base,
973
format.get_branch_format().get_format_description(),
917
974
format.repository_format.get_format_description(),
975
# poking at _revision_store isn't all that clean, but neither is
976
# having the ui test dependent on the exact overhead of a given store.
977
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
919
979
self.assertEqual('', err)
921
981
# Update second branch
922
982
tree2 = branch2.bzrdir.open_workingtree()
923
983
tree2.pull(branch1)
924
out, err = self.run_bzr('info -v repo/branch2')
984
out, err = self.runbzr('info -v repo/branch2')
925
985
self.assertEqualDiff(
926
986
"""Repository tree (format: knit)
928
shared repository: repo
929
repository branch: repo/branch2
988
shared repository: %s
989
repository checkout: branch2
931
991
Related branches:
932
parent branch: repo/branch1
935
995
control: Meta directory format 1
953
1014
first revision: %s
954
1015
latest revision: %s
958
""" % (format.get_branch_format().get_format_description(),
1020
""" % (repo.bzrdir.root_transport.base,
1021
branch1.bzrdir.root_transport.base,
1022
format.get_branch_format().get_format_description(),
959
1023
format.repository_format.get_format_description(),
960
1024
datestring_first, datestring_first,
1025
# poking at _revision_store isn't all that clean, but neither is
1026
# having the ui test dependent on the exact overhead of a given store.
1027
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
962
1029
self.assertEqual('', err)
964
1031
# Show info about repository with revisions
965
out, err = self.run_bzr('info -v repo')
1032
out, err = self.runbzr('info -v repo')
966
1033
self.assertEqualDiff(
967
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1034
"""Shared repository with trees (format: dirstate / dirstate-tags / knit)
969
shared repository: repo
1036
shared repository: %s
972
1039
control: Meta directory format 1
979
""" % (format.repository_format.get_format_description(),
1047
""" % (repo.bzrdir.root_transport.base,
1048
format.repository_format.get_format_description(),
1049
# poking at _revision_store isn't all that clean, but neither is
1050
# having the ui test dependent on the exact overhead of a given store.
1051
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
982
1054
self.assertEqual('', err)
984
1056
def test_info_shared_repository_with_tree_in_root(self):
985
1057
format = bzrdir.format_registry.make_bzrdir('knit')
986
1058
transport = self.get_transport()
988
1060
# Create shared repository with working trees
989
1061
repo = self.make_repository('repo', shared=True, format=format)
990
1062
repo.set_make_working_trees(True)
991
out, err = self.run_bzr('info -v repo')
1063
out, err = self.runbzr('info -v repo')
992
1064
self.assertEqualDiff(
993
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1065
"""Shared repository with trees (format: dirstate / dirstate-tags / knit)
995
shared repository: repo
1067
shared repository: %s
998
1070
control: Meta directory format 1
1010
1084
control = repo.bzrdir
1011
1085
branch = control.create_branch()
1012
1086
control.create_workingtree()
1013
out, err = self.run_bzr('info -v repo')
1087
out, err = self.runbzr('info -v repo')
1014
1088
self.assertEqualDiff(
1015
1089
"""Repository tree (format: knit)
1017
shared repository: repo
1018
repository branch: repo
1091
shared repository: %s
1092
repository checkout: .
1021
1095
control: Meta directory format 1
1036
1110
Branch history:
1041
""" % (format.get_branch_format().get_format_description(),
1117
""" % (repo.bzrdir.root_transport.base,
1118
format.get_branch_format().get_format_description(),
1042
1119
format.repository_format.get_format_description(),
1044
1121
self.assertEqual('', err)
1046
def test_info_repository_hook(self):
1047
format = bzrdir.format_registry.make_bzrdir('knit')
1048
def repo_info(repo, stats, outf):
1049
outf.write("more info\n")
1050
info.hooks.install_named_hook('repository', repo_info, None)
1051
# Create shared repository with working trees
1052
repo = self.make_repository('repo', shared=True, format=format)
1053
out, err = self.run_bzr('info -v repo')
1054
self.assertEqualDiff(
1055
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1057
shared repository: repo
1060
control: Meta directory format 1
1063
Create working tree for new branches inside the repository.
1068
""" % (format.repository_format.get_format_description(),
1070
self.assertEqual('', err)
1072
def assertCheckoutStatusOutput(self,
1123
def assertCheckoutStatusOutput(self,
1073
1124
command_string, lco_tree, shared_repo=None,
1074
1125
repo_branch=None,
1075
1126
tree_locked=False,
1076
1127
branch_locked=False, repo_locked=False,
1078
light_checkout=True,
1079
checkout_root=None):
1080
"""Check the output of info in a checkout.
1129
light_checkout=True):
1130
"""Check the output of info in a light checkout tree.
1082
1132
This is not quite a mirror of the info code: rather than using the
1083
1133
tree being examined to predict output, it uses a bunch of flags which
1084
1134
allow us, the test writers, to document what *should* be present in
1085
1135
the output. Removing this separation would remove the value of the
1088
1138
:param path: the path to the light checkout.
1089
1139
:param lco_tree: the tree object for the light checkout.
1090
1140
:param shared_repo: A shared repository is in use, expect that in
1094
1144
:param tree_locked: If true, expect the tree to be locked.
1095
1145
:param branch_locked: If true, expect the branch to be locked.
1096
1146
:param repo_locked: If true, expect the repository to be locked.
1097
Note that the lco_tree.branch.repository is inspected, and if is not
1098
actually locked then this parameter is overridden. This is because
1099
pack repositories do not have any public API for obtaining an
1100
exclusive repository wide lock.
1101
:param verbose: verbosity level: 2 or higher to show committers
1147
:param verbose: If true, expect verbose output
1103
def friendly_location(url):
1104
path = urlutils.unescape_for_display(url, 'ascii')
1106
return osutils.relpath(osutils.getcwd(), path)
1107
except errors.PathNotChild:
1111
# We expect this to fail because of locking errors.
1112
# (A write-locked file cannot be read-locked
1113
# in the different process -- either on win32 or on linux).
1149
if tree_locked and sys.platform == 'win32':
1150
# We expect this to fail because of locking errors. (A write-locked
1151
# file cannot be read-locked in the same process).
1114
1152
# This should be removed when the locking errors are fixed.
1115
self.expectFailure('OS locks are exclusive '
1116
'for different processes (Bug #174055)',
1117
self.run_bzr_subprocess,
1118
'info ' + command_string)
1119
out, err = self.run_bzr('info %s' % command_string)
1153
args = command_string.split(' ')
1154
self.run_bzr_error([], 'info', *args)
1156
out, err = self.runbzr('info %s' % command_string)
1120
1157
description = {
1121
1158
(True, True): 'Lightweight checkout',
1122
1159
(True, False): 'Repository checkout',
1123
1160
(False, True): 'Lightweight checkout',
1124
1161
(False, False): 'Checkout',
1125
1162
}[(shared_repo is not None, light_checkout)]
1126
format = {True: self._repo_strings,
1127
False: 'unnamed'}[light_checkout]
1129
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1163
format = {True: 'dirstate / dirstate-tags',
1164
False: 'dirstate'}[light_checkout]
1130
1165
if repo_locked or branch_locked or tree_locked:
1131
1166
def locked_message(a_bool):
1144
1179
locked_message(repo_locked)))
1146
1181
expected_lock_output = ''
1149
1182
if light_checkout:
1150
tree_data = (" light checkout root: %s\n" %
1151
friendly_location(lco_tree.bzrdir.root_transport.base))
1153
if lco_tree.branch.get_bound_location() is not None:
1154
tree_data += ("%s checkout root: %s\n" % (extra_space,
1155
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1183
tree_data = (" light checkout root: %s" %
1184
lco_tree.bzrdir.root_transport.base)
1186
tree_data = (" checkout root: %s" %
1187
lco_tree.bzrdir.root_transport.base)
1156
1188
if shared_repo is not None:
1157
1189
branch_data = (
1158
" checkout of branch: %s\n"
1159
" shared repository: %s\n" %
1160
(friendly_location(repo_branch.bzrdir.root_transport.base),
1161
friendly_location(shared_repo.bzrdir.root_transport.base)))
1190
" shared repository: %s\n"
1191
" repository branch: branch\n" %
1192
shared_repo.bzrdir.root_transport.base)
1162
1193
elif repo_branch is not None:
1163
1194
branch_data = (
1164
"%s checkout of branch: %s\n" %
1166
friendly_location(repo_branch.bzrdir.root_transport.base)))
1195
" checkout of branch: %s\n" %
1196
repo_branch.bzrdir.root_transport.base)
1168
branch_data = (" checkout of branch: %s\n" %
1198
branch_data = (" checkout of branch: %s\n" %
1169
1199
lco_tree.branch.bzrdir.root_transport.base)
1172
1202
verbose_info = ' 0 committers\n'
1174
1204
verbose_info = ''
1176
1206
self.assertEqualDiff(
1177
1207
"""%s (format: %s)
1181
1212
control: Meta directory format 1
1182
1213
working tree: %s
1214
1246
transport = self.get_transport()
1215
1247
# Create shared repository with a branch
1216
1248
repo = self.make_repository('repo', shared=True,
1217
format=bzrdir.BzrDirMetaFormat1())
1249
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1218
1250
repo.set_make_working_trees(False)
1219
1251
repo.bzrdir.root_transport.mkdir('branch')
1220
1252
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1221
format=bzrdir.BzrDirMetaFormat1())
1253
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1222
1254
# Do a heavy checkout
1223
1255
transport.mkdir('tree')
1224
1256
transport.mkdir('tree/checkout')
1225
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
format=bzrdir.BzrDirMetaFormat1())
1257
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1258
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1227
1259
co_branch.bind(repo_branch)
1228
1260
# Do a light checkout of the heavy one
1229
1261
transport.mkdir('tree/lightcheckout')
1230
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1231
branch.BranchReferenceFormat().initialize(lco_dir,
1232
target_branch=co_branch)
1262
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1263
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1233
1264
lco_dir.create_workingtree()
1234
1265
lco_tree = lco_dir.open_workingtree()
1240
1271
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1241
repo_branch=repo_branch,
1242
verbose=True, light_checkout=True)
1244
1274
lco_tree.branch.repository.lock_write()
1246
1276
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1247
lco_tree, repo_branch=repo_branch,
1248
repo_locked=True, verbose=True, light_checkout=True)
1278
repo_locked=True, verbose=True)
1250
1280
lco_tree.branch.repository.unlock()
1326
1355
def test_info_locking_oslocks(self):
1327
1356
if sys.platform == "win32":
1328
self.skip("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()
1357
raise TestSkipped("don't use oslocks on win32 in unix manner")
1335
1359
tree = self.make_branch_and_tree('branch',
1336
format=bzrdir.BzrDirFormat6())
1360
format=bzrlib.bzrdir.BzrDirFormat6())
1338
1362
# Test all permutations of locking the working tree, branch and repository
1339
1363
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1367
1391
Branch history:
1372
""" % ('branch', tree.branch.repository._format.get_format_description(),
1398
""" % (tree.bzrdir.root_transport.base,
1399
tree.branch.repository._format.get_format_description(),
1374
1401
self.assertEqual('', err)
1376
1403
tree.lock_write()
1377
out, err = self.run_bzr('info -v branch')
1404
out, err = self.runbzr('info -v branch')
1378
1405
self.assertEqualDiff(
1379
1406
"""Standalone tree (format: weave)
1399
1426
Branch history:
1404
""" % ('branch', tree.branch.repository._format.get_format_description(),
1433
""" % (tree.bzrdir.root_transport.base,
1434
tree.branch.repository._format.get_format_description(),
1406
1436
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)