1
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
1
# Copyright (C) 2006, 2007 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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
527
""" % ('repo', format.repository_format.get_format_description(),
507
""" % (repo.bzrdir.root_transport.base,
508
format.repository_format.get_format_description(),
529
510
self.assertEqual('', err)
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
807
""" % (format.repository_format.get_format_description(),
811
""" % (repo.bzrdir.root_transport.base,
812
format.repository_format.get_format_description(),
809
814
self.assertEqual('', err)
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
1016
""" % (format.repository_format.get_format_description(),
1042
""" % (repo.bzrdir.root_transport.base,
1043
format.repository_format.get_format_description(),
1018
1045
self.assertEqual('', err)
1021
1048
control = repo.bzrdir
1022
1049
branch = control.create_branch()
1023
1050
control.create_workingtree()
1024
out, err = self.run_bzr('info -v repo')
1051
out, err = self.runbzr('info repo')
1025
1052
self.assertEqualDiff(
1026
"""Repository tree (format: knit)
1028
shared repository: repo
1029
repository branch: repo
1054
shared repository: %s
1055
repository checkout: .
1032
1058
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 test_info_repository_hook(self):
1058
format = bzrdir.format_registry.make_bzrdir('knit')
1059
def repo_info(repo, stats, outf):
1060
outf.write("more info\n")
1061
info.hooks.install_named_hook('repository', repo_info, None)
1062
# Create shared repository with working trees
1063
repo = self.make_repository('repo', shared=True, format=format)
1064
out, err = self.run_bzr('info -v repo')
1065
self.assertEqualDiff(
1066
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1068
shared repository: repo
1071
control: Meta directory format 1
1074
Create working tree for new branches inside the repository.
1079
""" % (format.repository_format.get_format_description(),
1081
self.assertEqual('', err)
1083
def assertCheckoutStatusOutput(self,
1085
def assertCheckoutStatusOutput(self,
1084
1086
command_string, lco_tree, shared_repo=None,
1085
1087
repo_branch=None,
1086
1088
tree_locked=False,
1087
1089
branch_locked=False, repo_locked=False,
1089
light_checkout=True,
1090
checkout_root=None):
1091
"""Check the output of info in a checkout.
1091
light_checkout=True):
1092
"""Check the output of info in a light checkout tree.
1093
1094
This is not quite a mirror of the info code: rather than using the
1094
1095
tree being examined to predict output, it uses a bunch of flags which
1095
1096
allow us, the test writers, to document what *should* be present in
1096
1097
the output. Removing this separation would remove the value of the
1099
1100
:param path: the path to the light checkout.
1100
1101
:param lco_tree: the tree object for the light checkout.
1101
1102
:param shared_repo: A shared repository is in use, expect that in
1105
1106
:param tree_locked: If true, expect the tree to be locked.
1106
1107
:param branch_locked: If true, expect the branch to be locked.
1107
1108
:param repo_locked: If true, expect the repository to be locked.
1108
Note that the lco_tree.branch.repository is inspected, and if is not
1109
actually locked then this parameter is overridden. This is because
1110
pack repositories do not have any public API for obtaining an
1111
exclusive repository wide lock.
1112
:param verbose: verbosity level: 2 or higher to show committers
1109
:param verbose: If true, expect verbose output
1114
def friendly_location(url):
1115
path = urlutils.unescape_for_display(url, 'ascii')
1117
return osutils.relpath(osutils.getcwd(), path)
1118
except errors.PathNotChild:
1122
# We expect this to fail because of locking errors.
1123
# (A write-locked file cannot be read-locked
1124
# in the different process -- either on win32 or on linux).
1125
# This should be removed when the locking errors are fixed.
1126
self.expectFailure('OS locks are exclusive '
1127
'for different processes (Bug #174055)',
1128
self.run_bzr_subprocess,
1129
'info ' + command_string)
1130
out, err = self.run_bzr('info %s' % command_string)
1132
(True, True): 'Lightweight checkout',
1133
(True, False): 'Repository checkout',
1134
(False, True): 'Lightweight checkout',
1135
(False, False): 'Checkout',
1136
}[(shared_repo is not None, light_checkout)]
1137
format = {True: '1.6 or 1.6.1-rich-root'
1138
' or 1.9 or 1.9-rich-root'
1139
' or dirstate or dirstate-tags or pack-0.92'
1140
' or rich-root or rich-root-pack',
1141
False: 'dirstate'}[light_checkout]
1143
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1111
out, err = self.runbzr('info %s' % command_string)
1144
1112
if repo_locked or branch_locked or tree_locked:
1145
1113
def locked_message(a_bool):
1158
1126
locked_message(repo_locked)))
1160
1128
expected_lock_output = ''
1163
1129
if light_checkout:
1164
tree_data = (" light checkout root: %s\n" %
1165
friendly_location(lco_tree.bzrdir.root_transport.base))
1167
if lco_tree.branch.get_bound_location() is not None:
1168
tree_data += ("%s checkout root: %s\n" % (extra_space,
1169
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1130
tree_data = (" light checkout root: %s" %
1131
lco_tree.bzrdir.root_transport.base)
1133
tree_data = (" checkout root: %s" %
1134
lco_tree.bzrdir.root_transport.base)
1170
1135
if shared_repo is not None:
1171
1136
branch_data = (
1172
" checkout of branch: %s\n"
1173
" shared repository: %s\n" %
1174
(friendly_location(repo_branch.bzrdir.root_transport.base),
1175
friendly_location(shared_repo.bzrdir.root_transport.base)))
1137
" shared repository: %s\n"
1138
" repository branch: branch\n" %
1139
shared_repo.bzrdir.root_transport.base)
1176
1140
elif repo_branch is not None:
1177
1141
branch_data = (
1178
"%s checkout of branch: %s\n" %
1180
friendly_location(repo_branch.bzrdir.root_transport.base)))
1142
" checkout of branch: %s\n" %
1143
repo_branch.bzrdir.root_transport.base)
1182
branch_data = (" checkout of branch: %s\n" %
1145
branch_data = (" checkout of branch: %s\n" %
1183
1146
lco_tree.branch.bzrdir.root_transport.base)
1186
1149
verbose_info = ' 0 committers\n'
1188
1151
verbose_info = ''
1190
1153
self.assertEqualDiff(
1195
1158
control: Meta directory format 1
1196
1159
working tree: %s
1228
1190
transport = self.get_transport()
1229
1191
# Create shared repository with a branch
1230
1192
repo = self.make_repository('repo', shared=True,
1231
format=bzrdir.BzrDirMetaFormat1())
1193
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1232
1194
repo.set_make_working_trees(False)
1233
1195
repo.bzrdir.root_transport.mkdir('branch')
1234
1196
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1235
format=bzrdir.BzrDirMetaFormat1())
1197
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1236
1198
# Do a heavy checkout
1237
1199
transport.mkdir('tree')
1238
1200
transport.mkdir('tree/checkout')
1239
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1240
format=bzrdir.BzrDirMetaFormat1())
1201
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1202
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1241
1203
co_branch.bind(repo_branch)
1242
1204
# Do a light checkout of the heavy one
1243
1205
transport.mkdir('tree/lightcheckout')
1244
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1245
branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1206
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1207
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1246
1208
lco_dir.create_workingtree()
1247
1209
lco_tree = lco_dir.open_workingtree()
1253
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1254
repo_branch=repo_branch,
1255
verbose=True, light_checkout=True)
1215
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1257
1217
lco_tree.branch.repository.lock_write()
1259
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1260
lco_tree, repo_branch=repo_branch,
1261
repo_locked=True, verbose=True, light_checkout=True)
1219
self.assertCheckoutStatusOutput('tree/lightcheckout',
1263
1223
lco_tree.branch.repository.unlock()
1265
1225
lco_tree.branch.lock_write()
1267
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1227
self.assertCheckoutStatusOutput('tree/lightcheckout',
1269
1229
branch_locked=True,
1271
repo_branch=repo_branch,
1274
1232
lco_tree.branch.unlock()
1276
1234
lco_tree.lock_write()
1278
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1279
lco_tree, repo_branch=repo_branch,
1236
self.assertCheckoutStatusOutput('tree/lightcheckout',
1280
1238
tree_locked=True,
1281
1239
branch_locked=True,
1285
1242
lco_tree.unlock()
1287
1244
lco_tree.lock_write()
1288
1245
lco_tree.branch.repository.unlock()
1290
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1291
lco_tree, repo_branch=repo_branch,
1247
self.assertCheckoutStatusOutput('tree/lightcheckout',
1292
1249
tree_locked=True,
1296
1252
lco_tree.branch.repository.lock_write()
1297
1253
lco_tree.unlock()
1299
1255
lco_tree.lock_write()
1300
1256
lco_tree.branch.unlock()
1302
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1303
lco_tree, repo_branch=repo_branch,
1258
self.assertCheckoutStatusOutput('tree/lightcheckout',
1307
1262
lco_tree.branch.lock_write()
1308
1263
lco_tree.unlock()
1311
1266
lco_tree.branch.unlock()
1312
1267
lco_tree.branch.repository.lock_write()
1314
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1315
lco_tree, repo_branch=repo_branch,
1269
self.assertCheckoutStatusOutput('tree/lightcheckout',
1316
1271
tree_locked=True,
1320
1274
lco_tree.branch.repository.unlock()
1321
1275
lco_tree.branch.lock_write()
1324
1278
lco_tree.branch.lock_write()
1325
1279
lco_tree.branch.repository.unlock()
1327
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1328
lco_tree, repo_branch=repo_branch,
1281
self.assertCheckoutStatusOutput('tree/lightcheckout',
1332
1285
lco_tree.branch.repository.lock_write()
1333
1286
lco_tree.branch.unlock()
1335
if sys.platform == 'win32':
1336
self.knownFailure('Win32 cannot run "bzr info"'
1337
' when the tree is locked.')
1339
1288
def test_info_locking_oslocks(self):
1340
1289
if sys.platform == "win32":
1341
1290
raise TestSkipped("don't use oslocks on win32 in unix manner")
1343
1292
tree = self.make_branch_and_tree('branch',
1344
format=bzrdir.BzrDirFormat6())
1293
format=bzrlib.bzrdir.BzrDirFormat6())
1346
1295
# Test all permutations of locking the working tree, branch and repository
1347
1296
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1380
""" % ('branch', tree.branch.repository._format.get_format_description(),
1329
""" % (tree.bzrdir.root_transport.base,
1330
tree.branch.repository._format.get_format_description(),
1382
1332
self.assertEqual('', err)
1384
1334
tree.lock_write()
1385
out, err = self.run_bzr('info -v branch')
1335
out, err = self.runbzr('info branch')
1386
1336
self.assertEqualDiff(
1387
"""Standalone tree (format: weave)
1389
1338
branch root: %s
1412
""" % ('branch', tree.branch.repository._format.get_format_description(),
1362
""" % (tree.bzrdir.root_transport.base,
1363
tree.branch.repository._format.get_format_description(),
1414
1365
self.assertEqual('', err)
1417
def test_info_stacked(self):
1418
# We have a mainline
1419
trunk_tree = self.make_branch_and_tree('mainline',
1421
trunk_tree.commit('mainline')
1422
# and a branch from it which is stacked
1423
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1424
out, err = self.run_bzr('info newbranch')
1426
"""Standalone tree (format: 1.6)
1428
branch root: newbranch
1431
parent branch: mainline
1432
stacked on: mainline
1434
self.assertEqual("", err)