13
14
# You should have received a copy of the GNU General Public License
14
15
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19
"""Tests for the info command of bzr."""
32
from bzrlib.transport import memory
35
class TestInfo(tests.TestCaseWithTransport):
38
super(TestInfo, self).setUp()
39
self._repo_strings = "2a"
24
from bzrlib import repository
25
from bzrlib.osutils import format_date
26
from bzrlib.tests import TestSkipped
27
from bzrlib.tests.blackbox import ExternalBase
30
class TestInfo(ExternalBase):
41
32
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)
33
if sys.platform == "win32":
34
location = "C:/i/do/not/exist/"
36
location = "/i/do/not/exist/"
37
out, err = self.runbzr('info '+location, retcode=3)
45
38
self.assertEqual(out, '')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
39
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
48
41
def test_info_standalone(self):
49
42
transport = self.get_transport()
51
44
# Create initial standalone branch
52
tree1 = self.make_branch_and_tree('standalone', 'weave')
45
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
46
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
47
tree1 = self.make_branch_and_tree('standalone')
48
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
53
49
self.build_tree(['standalone/a'])
55
51
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
104
control: All-in-one format 6
105
working tree: Working tree format 2
106
branch: Branch format 4
107
repository: Weave repository format 6
117
0 versioned subdirectories
52
out, err = self.runbzr('info standalone')
58
control: All-in-one format 6
59
working tree: Working tree format 2
60
branch: Branch format 4
61
repository: Weave repository format 6
71
0 versioned subdirectories
79
""" % branch1.bzrdir.root_transport.base, out)
126
80
self.assertEqual('', err)
127
81
tree1.commit('commit one')
128
82
rev = branch1.repository.get_revision(branch1.revision_history()[0])
129
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
83
datestring_first = format_date(rev.timestamp, rev.timezone)
131
85
# Branch standalone with push location
132
86
branch2 = branch1.bzrdir.sprout('branch').open_branch()
133
87
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
88
out, err = self.runbzr('info branch --verbose')
158
98
control: All-in-one format 6
176
117
first revision: %s
177
118
latest revision: %s
181
""" % (datestring_first, datestring_first,
123
""" % (branch2.bzrdir.root_transport.base,
124
branch1.bzrdir.root_transport.base,
125
branch1.bzrdir.root_transport.base,
126
datestring_first, datestring_first,
127
# poking at _revision_store isn't all that clean, but neither is
128
# having the ui test dependent on the exact overhead of a given store.
129
branch2.repository._revision_store.total_size(
130
branch2.repository.get_transaction())[1] / 1024,
183
132
self.assertEqual('', err)
185
134
# Branch and bind to standalone, needs upgrade to metadir
186
135
# (creates backup as unknown)
187
136
branch1.bzrdir.sprout('bound')
188
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
189
upgrade.upgrade('bound', knit1_format)
190
branch3 = bzrdir.BzrDir.open('bound').open_branch()
137
knit1_format = bzrlib.bzrdir.BzrDirMetaFormat1()
138
knit1_format.repository_format = repository.RepositoryFormatKnit1()
139
bzrlib.upgrade.upgrade('bound', knit1_format)
140
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
191
141
branch3.bind(branch1)
192
142
bound_tree = branch3.bzrdir.open_workingtree()
193
out, err = self.run_bzr('info -v bound')
143
out, err = self.runbzr('info bound')
194
144
self.assertEqualDiff(
195
"""Checkout (format: knit)
198
checkout of branch: standalone
147
checkout of branch: %s
200
149
Related branches:
201
parent branch: standalone
204
153
control: Meta directory format 1
155
branch: Branch format 5
209
158
In the working tree:
222
171
first revision: %s
223
172
latest revision: %s
227
""" % (bound_tree._format.get_format_description(),
228
branch3._format.get_format_description(),
177
""" % (branch3.bzrdir.root_transport.base,
178
branch1.bzrdir.root_transport.base,
179
branch1.bzrdir.root_transport.base,
180
bound_tree._format.get_format_description(),
229
181
branch3.repository._format.get_format_description(),
230
182
datestring_first, datestring_first,
183
# poking at _revision_store isn't all that clean, but neither is
184
# having the ui test dependent on the exact overhead of a given store.
185
branch3.repository._revision_store.total_size(
186
branch3.repository.get_transaction())[1] / 1024,
232
188
self.assertEqual('', err)
234
190
# Checkout standalone (same as above, but does not have parent set)
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
191
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
192
bzrlib.bzrdir.BzrDirFormat.set_default_format(knit1_format)
193
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout')
194
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
237
195
branch4.bind(branch1)
238
196
branch4.bzrdir.open_workingtree().update()
239
out, err = self.run_bzr('info checkout --verbose')
197
out, err = self.runbzr('info checkout --verbose')
240
198
self.assertEqualDiff(
241
"""Checkout (format: knit)
243
checkout root: checkout
244
checkout of branch: standalone
201
checkout of branch: %s
247
204
control: Meta directory format 1
265
223
first revision: %s
266
224
latest revision: %s
270
""" % (branch4.repository._format.get_format_description(),
229
""" % (branch4.bzrdir.root_transport.base,
230
branch1.bzrdir.root_transport.base,
231
branch4.repository._format.get_format_description(),
271
232
datestring_first, datestring_first,
233
# poking at _revision_store isn't all that clean, but neither is
234
# having the ui test dependent on the exact overhead of a given store.
235
branch4.repository._revision_store.total_size(
236
branch4.repository.get_transaction())[1] / 1024,
273
238
self.assertEqual('', err)
275
240
# Lightweight checkout (same as above, different branch and repository)
276
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
241
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
242
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
243
transport.mkdir('lightcheckout')
244
dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
245
bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
246
dir5.create_workingtree()
247
tree5 = dir5.open_workingtree()
248
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
277
249
branch5 = tree5.branch
278
out, err = self.run_bzr('info -v lightcheckout')
250
out, err = self.runbzr('info lightcheckout')
279
251
self.assertEqualDiff(
280
"""Lightweight checkout (format: %s)
282
light checkout root: lightcheckout
283
checkout of branch: standalone
253
light checkout root: %s
254
checkout of branch: %s
286
257
control: Meta directory format 1
287
working tree: Working tree format 6
258
working tree: Working tree format 3
288
259
branch: Branch format 4
289
260
repository: Weave repository 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 bound')
360
338
self.assertEqualDiff(
361
"""Checkout (format: knit)
364
checkout of branch: standalone
341
checkout of branch: %s
366
343
Related branches:
367
parent branch: standalone
370
347
control: Meta directory format 1
390
367
first revision: %s
391
368
latest revision: %s
395
""" % (branch3.repository._format.get_format_description(),
373
""" % (branch3.bzrdir.root_transport.base,
374
branch1.bzrdir.root_transport.base,
375
branch1.bzrdir.root_transport.base,
376
branch3.repository._format.get_format_description(),
396
377
datestring_first, datestring_first,
378
# poking at _revision_store isn't all that clean, but neither is
379
# having the ui test dependent on the exact overhead of a given store.
380
branch3.repository._revision_store.total_size(
381
branch3.repository.get_transaction())[1] / 1024,
398
383
self.assertEqual('', err)
400
385
# Out of date checkout
401
out, err = self.run_bzr('info -v checkout')
386
out, err = self.runbzr('info checkout')
402
387
self.assertEqualDiff(
403
"""Checkout (format: knit)
405
checkout root: checkout
406
checkout of branch: standalone
390
checkout of branch: %s
409
393
control: Meta directory format 1
429
413
first revision: %s
430
414
latest revision: %s
434
""" % (branch4.repository._format.get_format_description(),
419
""" % (branch4.bzrdir.root_transport.base,
420
branch1.bzrdir.root_transport.base,
421
branch4.repository._format.get_format_description(),
435
422
datestring_first, datestring_first,
423
# poking at _revision_store isn't all that clean, but neither is
424
# having the ui test dependent on the exact overhead of a given store.
425
branch4.repository._revision_store.total_size(
426
branch4.repository.get_transaction())[1] / 1024,
437
428
self.assertEqual('', err)
439
430
# Out of date lightweight checkout
440
out, err = self.run_bzr('info lightcheckout --verbose')
431
out, err = self.runbzr('info lightcheckout --verbose')
441
432
self.assertEqualDiff(
442
"""Lightweight checkout (format: %s)
444
light checkout root: lightcheckout
445
checkout of branch: standalone
434
light checkout root: %s
435
checkout of branch: %s
448
438
control: Meta directory format 1
449
working tree: Working tree format 6
439
working tree: Working tree format 3
450
440
branch: Branch format 4
451
441
repository: Weave repository format 6
468
459
first revision: %s
469
460
latest revision: %s
473
""" % (self._repo_strings, datestring_first, datestring_last,), out)
465
""" % (tree5.bzrdir.root_transport.base,
466
branch1.bzrdir.root_transport.base,
467
datestring_first, datestring_last,
474
469
self.assertEqual('', err)
476
471
def test_info_standalone_no_tree(self):
477
472
# create standalone branch without a working tree
478
format = bzrdir.format_registry.make_bzrdir('default')
479
473
branch = self.make_branch('branch')
480
474
repo = branch.repository
481
out, err = self.run_bzr('info branch -v')
475
out, err = self.runbzr('info branch')
482
476
self.assertEqualDiff(
483
"""Standalone branch (format: %s)
488
481
control: Meta directory format 1
482
branch: Branch format 5
497
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
498
format.get_branch_format().get_format_description(),
499
format.repository_format.get_format_description(),
491
""" % (branch.bzrdir.root_transport.base,
492
repo._format.get_format_description(),
501
494
self.assertEqual('', err)
503
496
def test_info_shared_repository(self):
504
format = bzrdir.format_registry.make_bzrdir('knit')
497
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
498
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
505
499
transport = self.get_transport()
507
501
# Create shared repository
508
repo = self.make_repository('repo', shared=True, format=format)
502
repo = self.make_repository('repo', shared=True)
509
503
repo.set_make_working_trees(False)
510
out, err = self.run_bzr('info -v repo')
504
out, err = self.runbzr('info repo')
511
505
self.assertEqualDiff(
512
"""Shared repository (format: dirstate or dirstate-tags or knit)
514
507
shared repository: %s
517
510
control: Meta directory format 1
522
""" % ('repo', format.repository_format.get_format_description(),
516
""" % (repo.bzrdir.root_transport.base,
517
repo._format.get_format_description(),
524
519
self.assertEqual('', err)
526
521
# Create branch inside shared repository
527
522
repo.bzrdir.root_transport.mkdir('branch')
528
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
530
out, err = self.run_bzr('info -v repo/branch')
523
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
524
out, err = self.runbzr('info repo/branch')
531
525
self.assertEqualDiff(
532
"""Repository branch (format: dirstate or knit)
534
shared repository: repo
535
repository branch: repo/branch
527
shared repository: %s
528
repository branch: branch
538
531
control: Meta directory format 1
532
branch: Branch format 5
547
""" % (format.get_branch_format().get_format_description(),
548
format.repository_format.get_format_description(),
541
""" % (repo.bzrdir.root_transport.base,
542
repo._format.get_format_description(),
550
544
self.assertEqual('', err)
552
546
# Create lightweight checkout
553
547
transport.mkdir('tree')
554
548
transport.mkdir('tree/lightcheckout')
555
tree2 = branch1.create_checkout('tree/lightcheckout',
549
dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
550
bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
551
dir2.create_workingtree()
552
tree2 = dir2.open_workingtree()
557
553
branch2 = tree2.branch
558
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
559
shared_repo=repo, repo_branch=branch1, verbose=True)
554
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
561
556
# Create normal checkout
562
557
tree3 = branch1.create_checkout('tree/checkout')
569
564
tree2.commit('commit one')
570
565
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')
566
datestring_first = format_date(rev.timestamp, rev.timezone)
567
out, err = self.runbzr('info tree/lightcheckout --verbose')
573
568
self.assertEqualDiff(
574
"""Lightweight checkout (format: %s)
576
light checkout root: tree/lightcheckout
577
checkout of branch: repo/branch
578
shared repository: repo
570
light checkout root: %s
571
shared repository: %s
572
repository branch: branch
581
575
control: Meta directory format 1
582
working tree: Working tree format 6
576
working tree: Working tree format 3
577
branch: Branch format 5
586
580
In the working tree:
599
594
first revision: %s
600
595
latest revision: %s
604
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
605
format.repository_format.get_format_description(),
600
""" % (tree2.bzrdir.root_transport.base,
601
repo.bzrdir.root_transport.base,
602
repo._format.get_format_description(),
606
603
datestring_first, datestring_first,
604
# poking at _revision_store isn't all that clean, but neither is
605
# having the ui test dependent on the exact overhead of a given store.
606
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
608
608
self.assertEqual('', err)
610
610
# Out of date checkout
611
out, err = self.run_bzr('info -v tree/checkout')
611
out, err = self.runbzr('info tree/checkout')
612
612
self.assertEqualDiff(
613
"""Checkout (format: unnamed)
615
checkout root: tree/checkout
616
checkout of branch: repo/branch
615
checkout of branch: %s
619
618
control: Meta directory format 1
620
working tree: Working tree format 6
619
working tree: Working tree format 3
620
branch: Branch format 5
624
623
Branch is out of date: missing 1 revision.
676
677
first revision: %s
677
678
latest revision: %s
681
""" % (format.get_branch_format().get_format_description(),
682
format.repository_format.get_format_description(),
683
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
684
repo._format.get_format_description(),
683
685
datestring_first, datestring_first,
686
# poking at _revision_store isn't all that clean, but neither is
687
# having the ui test dependent on the exact overhead of a given store.
688
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
685
690
self.assertEqual('', err)
686
691
tree3.commit('commit two')
688
693
# Out of date lightweight checkout
689
694
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')
695
datestring_last = format_date(rev.timestamp, rev.timezone)
696
out, err = self.runbzr('info tree/lightcheckout --verbose')
692
697
self.assertEqualDiff(
693
"""Lightweight checkout (format: %s)
695
light checkout root: tree/lightcheckout
696
checkout of branch: repo/branch
697
shared repository: repo
699
light checkout root: %s
700
shared repository: %s
701
repository branch: branch
700
704
control: Meta directory format 1
701
working tree: Working tree format 6
705
working tree: Working tree format 3
706
branch: Branch format 5
705
709
Working tree is out of date: missing 1 revision.
720
725
first revision: %s
721
726
latest revision: %s
725
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
726
format.repository_format.get_format_description(),
731
""" % (tree2.bzrdir.root_transport.base,
732
repo.bzrdir.root_transport.base,
733
repo._format.get_format_description(),
727
734
datestring_first, datestring_last,
735
# poking at _revision_store isn't all that clean, but neither is
736
# having the ui test dependent on the exact overhead of a given store.
737
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
729
739
self.assertEqual('', err)
731
741
# Show info about shared branch
732
out, err = self.run_bzr('info repo/branch --verbose')
742
out, err = self.runbzr('info repo/branch --verbose')
733
743
self.assertEqualDiff(
734
"""Repository branch (format: dirstate or knit)
736
shared repository: repo
737
repository branch: repo/branch
745
shared repository: %s
746
repository branch: branch
740
749
control: Meta directory format 1
750
branch: Branch format 5
747
757
first revision: %s
748
758
latest revision: %s
752
""" % (format.get_branch_format().get_format_description(),
753
format.repository_format.get_format_description(),
763
""" % (repo.bzrdir.root_transport.base,
764
repo._format.get_format_description(),
754
765
datestring_first, datestring_last,
766
# poking at _revision_store isn't all that clean, but neither is
767
# having the ui test dependent on the exact overhead of a given store.
768
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
756
770
self.assertEqual('', err)
758
772
# Show info about repository with revisions
759
out, err = self.run_bzr('info -v repo')
773
out, err = self.runbzr('info repo')
760
774
self.assertEqualDiff(
761
"""Shared repository (format: dirstate or dirstate-tags or knit)
763
shared repository: repo
776
shared repository: %s
766
779
control: Meta directory format 1
771
""" % (format.repository_format.get_format_description(),
785
""" % (repo.bzrdir.root_transport.base,
786
repo._format.get_format_description(),
787
# poking at _revision_store isn't all that clean, but neither is
788
# having the ui test dependent on the exact overhead of a given store.
789
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
773
791
self.assertEqual('', err)
793
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
775
795
def test_info_shared_repository_with_trees(self):
776
format = bzrdir.format_registry.make_bzrdir('knit')
796
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
797
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
777
798
transport = self.get_transport()
779
800
# Create shared repository with working trees
780
repo = self.make_repository('repo', shared=True, format=format)
801
repo = self.make_repository('repo', shared=True)
781
802
repo.set_make_working_trees(True)
782
out, err = self.run_bzr('info -v repo')
803
out, err = self.runbzr('info repo')
783
804
self.assertEqualDiff(
784
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
786
shared repository: repo
806
shared repository: %s
789
809
control: Meta directory format 1
792
812
Create working tree for new branches inside the repository.
796
""" % (format.repository_format.get_format_description(),
817
""" % (repo.bzrdir.root_transport.base,
818
repo._format.get_format_description(),
798
820
self.assertEqual('', err)
800
822
# Create two branches
801
823
repo.bzrdir.root_transport.mkdir('branch1')
802
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
824
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
804
825
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
806
827
# Empty first branch
807
out, err = self.run_bzr('info repo/branch1 --verbose')
828
out, err = self.runbzr('info repo/branch1 --verbose')
808
829
self.assertEqualDiff(
809
"""Repository tree (format: knit)
811
shared repository: repo
812
repository branch: repo/branch1
831
shared repository: %s
832
repository checkout: branch1
815
835
control: Meta directory format 1
816
836
working tree: Working tree format 3
837
branch: Branch format 5
820
840
In the working tree:
873
894
first revision: %s
874
895
latest revision: %s
878
""" % (format.get_branch_format().get_format_description(),
879
format.repository_format.get_format_description(),
900
""" % (repo.bzrdir.root_transport.base,
901
repo._format.get_format_description(),
880
902
datestring_first, datestring_first,
903
# poking at _revision_store isn't all that clean, but neither is
904
# having the ui test dependent on the exact overhead of a given store.
905
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
882
907
self.assertEqual('', err)
884
909
# Out of date second branch
885
out, err = self.run_bzr('info repo/branch2 --verbose')
910
out, err = self.runbzr('info repo/branch2 --verbose')
886
911
self.assertEqualDiff(
887
"""Repository tree (format: knit)
889
shared repository: repo
890
repository branch: repo/branch2
913
shared repository: %s
914
repository checkout: branch2
892
916
Related branches:
893
parent branch: repo/branch1
896
920
control: Meta directory format 1
897
921
working tree: Working tree format 3
922
branch: Branch format 5
901
925
In the working tree:
916
""" % (format.get_branch_format().get_format_description(),
917
format.repository_format.get_format_description(),
942
""" % (repo.bzrdir.root_transport.base,
943
branch1.bzrdir.root_transport.base,
944
repo._format.get_format_description(),
945
# poking at _revision_store isn't all that clean, but neither is
946
# having the ui test dependent on the exact overhead of a given store.
947
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
919
949
self.assertEqual('', err)
921
951
# Update second branch
922
952
tree2 = branch2.bzrdir.open_workingtree()
923
953
tree2.pull(branch1)
924
out, err = self.run_bzr('info -v repo/branch2')
954
out, err = self.runbzr('info repo/branch2')
925
955
self.assertEqualDiff(
926
"""Repository tree (format: knit)
928
shared repository: repo
929
repository branch: repo/branch2
957
shared repository: %s
958
repository checkout: branch2
931
960
Related branches:
932
parent branch: repo/branch1
935
964
control: Meta directory format 1
936
965
working tree: Working tree format 3
966
branch: Branch format 5
940
969
In the working tree:
953
982
first revision: %s
954
983
latest revision: %s
958
""" % (format.get_branch_format().get_format_description(),
959
format.repository_format.get_format_description(),
988
""" % (repo.bzrdir.root_transport.base,
989
branch1.bzrdir.root_transport.base,
990
repo._format.get_format_description(),
960
991
datestring_first, datestring_first,
992
# poking at _revision_store isn't all that clean, but neither is
993
# having the ui test dependent on the exact overhead of a given store.
994
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
962
996
self.assertEqual('', err)
964
998
# Show info about repository with revisions
965
out, err = self.run_bzr('info -v repo')
999
out, err = self.runbzr('info repo')
966
1000
self.assertEqualDiff(
967
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
969
shared repository: repo
1002
shared repository: %s
972
1005
control: Meta directory format 1
975
1008
Create working tree for new branches inside the repository.
979
""" % (format.repository_format.get_format_description(),
1013
""" % (repo.bzrdir.root_transport.base,
1014
repo._format.get_format_description(),
1015
# poking at _revision_store isn't all that clean, but neither is
1016
# having the ui test dependent on the exact overhead of a given store.
1017
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
982
1020
self.assertEqual('', err)
1022
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
984
1024
def test_info_shared_repository_with_tree_in_root(self):
985
format = bzrdir.format_registry.make_bzrdir('knit')
1025
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1026
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
986
1027
transport = self.get_transport()
988
1029
# Create shared repository with working trees
989
repo = self.make_repository('repo', shared=True, format=format)
1030
repo = self.make_repository('repo', shared=True)
990
1031
repo.set_make_working_trees(True)
991
out, err = self.run_bzr('info -v repo')
1032
out, err = self.runbzr('info repo')
992
1033
self.assertEqualDiff(
993
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
995
shared repository: repo
1035
shared repository: %s
998
1038
control: Meta directory format 1
1036
1077
Branch history:
1041
""" % (format.get_branch_format().get_format_description(),
1042
format.repository_format.get_format_description(),
1044
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,
1083
""" % (repo.bzrdir.root_transport.base,
1084
repo._format.get_format_description(),
1086
self.assertEqual('', err)
1088
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1090
def assertCheckoutStatusOutput(self,
1073
1091
command_string, lco_tree, shared_repo=None,
1074
1092
repo_branch=None,
1075
1093
tree_locked=False,
1076
1094
branch_locked=False, repo_locked=False,
1078
light_checkout=True,
1079
checkout_root=None):
1080
"""Check the output of info in a checkout.
1096
light_checkout=True):
1097
"""Check the output of info in a light checkout tree.
1082
1099
This is not quite a mirror of the info code: rather than using the
1083
1100
tree being examined to predict output, it uses a bunch of flags which
1084
1101
allow us, the test writers, to document what *should* be present in
1085
1102
the output. Removing this separation would remove the value of the
1088
1105
:param path: the path to the light checkout.
1089
1106
:param lco_tree: the tree object for the light checkout.
1090
1107
:param shared_repo: A shared repository is in use, expect that in
1094
1111
:param tree_locked: If true, expect the tree to be locked.
1095
1112
:param branch_locked: If true, expect the branch to be locked.
1096
1113
: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
1114
: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).
1114
# 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)
1121
(True, True): 'Lightweight checkout',
1122
(True, False): 'Repository checkout',
1123
(False, True): 'Lightweight checkout',
1124
(False, False): 'Checkout',
1125
}[(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()
1116
out, err = self.runbzr('info %s' % command_string)
1130
1117
if repo_locked or branch_locked or tree_locked:
1131
1118
def locked_message(a_bool):
1144
1131
locked_message(repo_locked)))
1146
1133
expected_lock_output = ''
1149
1134
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)))
1135
tree_data = (" light checkout root: %s" %
1136
lco_tree.bzrdir.root_transport.base)
1138
tree_data = (" checkout root: %s" %
1139
lco_tree.bzrdir.root_transport.base)
1156
1140
if shared_repo is not None:
1157
1141
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)))
1142
" shared repository: %s\n"
1143
" repository branch: branch\n" %
1144
shared_repo.bzrdir.root_transport.base)
1162
1145
elif repo_branch is not None:
1163
1146
branch_data = (
1164
"%s checkout of branch: %s\n" %
1166
friendly_location(repo_branch.bzrdir.root_transport.base)))
1147
" checkout of branch: %s\n" %
1148
repo_branch.bzrdir.root_transport.base)
1168
branch_data = (" checkout of branch: %s\n" %
1150
branch_data = (" checkout of branch: %s\n" %
1169
1151
lco_tree.branch.bzrdir.root_transport.base)
1172
1154
verbose_info = ' 0 committers\n'
1174
1156
verbose_info = ''
1176
1158
self.assertEqualDiff(
1181
1163
control: Meta directory format 1
1182
1164
working tree: %s
1165
branch: Branch format 5
1186
1168
In the working tree:
1214
1194
transport = self.get_transport()
1215
1195
# Create shared repository with a branch
1216
1196
repo = self.make_repository('repo', shared=True,
1217
format=bzrdir.BzrDirMetaFormat1())
1197
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1218
1198
repo.set_make_working_trees(False)
1219
1199
repo.bzrdir.root_transport.mkdir('branch')
1220
1200
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1221
format=bzrdir.BzrDirMetaFormat1())
1201
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1222
1202
# Do a heavy checkout
1223
1203
transport.mkdir('tree')
1224
1204
transport.mkdir('tree/checkout')
1225
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
format=bzrdir.BzrDirMetaFormat1())
1205
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1206
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1227
1207
co_branch.bind(repo_branch)
1228
1208
# Do a light checkout of the heavy one
1229
1209
transport.mkdir('tree/lightcheckout')
1230
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1231
branch.BranchReferenceFormat().initialize(lco_dir,
1232
target_branch=co_branch)
1210
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1211
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1233
1212
lco_dir.create_workingtree()
1234
1213
lco_tree = lco_dir.open_workingtree()
1240
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1241
repo_branch=repo_branch,
1242
verbose=True, light_checkout=True)
1219
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1244
1221
lco_tree.branch.repository.lock_write()
1246
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1247
lco_tree, repo_branch=repo_branch,
1248
repo_locked=True, verbose=True, light_checkout=True)
1223
self.assertCheckoutStatusOutput('tree/lightcheckout',
1250
1227
lco_tree.branch.repository.unlock()
1252
1229
lco_tree.branch.lock_write()
1254
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1231
self.assertCheckoutStatusOutput('tree/lightcheckout',
1256
1233
branch_locked=True,
1258
repo_branch=repo_branch,
1261
1236
lco_tree.branch.unlock()
1263
1238
lco_tree.lock_write()
1265
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1266
lco_tree, repo_branch=repo_branch,
1240
self.assertCheckoutStatusOutput('tree/lightcheckout',
1267
1242
tree_locked=True,
1268
1243
branch_locked=True,
1272
1246
lco_tree.unlock()
1274
1248
lco_tree.lock_write()
1275
1249
lco_tree.branch.repository.unlock()
1277
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1278
lco_tree, repo_branch=repo_branch,
1251
self.assertCheckoutStatusOutput('tree/lightcheckout',
1279
1253
tree_locked=True,
1283
1256
lco_tree.branch.repository.lock_write()
1284
1257
lco_tree.unlock()
1311
1282
lco_tree.branch.lock_write()
1312
1283
lco_tree.branch.repository.unlock()
1314
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1315
lco_tree, repo_branch=repo_branch,
1285
self.assertCheckoutStatusOutput('tree/lightcheckout',
1319
1289
lco_tree.branch.repository.lock_write()
1320
1290
lco_tree.branch.unlock()
1322
if sys.platform == 'win32':
1323
self.knownFailure('Win32 cannot run "bzr info"'
1324
' when the tree is locked.')
1326
1292
def test_info_locking_oslocks(self):
1327
1293
if sys.platform == "win32":
1328
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()
1294
raise TestSkipped("don't use oslocks on win32 in unix manner")
1335
1296
tree = self.make_branch_and_tree('branch',
1336
format=bzrdir.BzrDirFormat6())
1297
format=bzrlib.bzrdir.BzrDirFormat6())
1338
1299
# Test all permutations of locking the working tree, branch and repository
1339
1300
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1399
1360
Branch history:
1404
""" % ('branch', tree.branch.repository._format.get_format_description(),
1366
""" % (tree.bzrdir.root_transport.base,
1367
tree.branch.repository._format.get_format_description(),
1406
1369
self.assertEqual('', err)
1409
def test_info_stacked(self):
1410
# We have a mainline
1411
trunk_tree = self.make_branch_and_tree('mainline',
1413
trunk_tree.commit('mainline')
1414
# and a branch from it which is stacked
1415
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1416
out, err = self.run_bzr('info newbranch')
1418
"""Standalone tree (format: 1.6)
1420
branch root: newbranch
1423
parent branch: mainline
1424
stacked on: mainline
1426
self.assertEqual("", err)