14
13
# You should have received a copy of the GNU General Public License
15
14
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
18
"""Tests for the info command of bzr."""
24
31
from bzrlib.osutils import format_date
25
32
from bzrlib.tests import TestSkipped
26
33
from bzrlib.tests.blackbox import ExternalBase
33
40
location = "C:/i/do/not/exist/"
35
42
location = "/i/do/not/exist/"
36
out, err = self.runbzr('info '+location, retcode=3)
43
out, err = self.run_bzr('info '+location, retcode=3)
37
44
self.assertEqual(out, '')
38
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
45
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
40
47
def test_info_standalone(self):
41
48
transport = self.get_transport()
43
50
# Create initial standalone branch
44
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
45
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
46
tree1 = self.make_branch_and_tree('standalone')
47
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
51
tree1 = self.make_branch_and_tree('standalone', 'weave')
48
52
self.build_tree(['standalone/a'])
50
54
branch1 = tree1.branch
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)
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
79
125
self.assertEqual('', err)
80
126
tree1.commit('commit one')
81
127
rev = branch1.repository.get_revision(branch1.revision_history()[0])
84
130
# Branch standalone with push location
85
131
branch2 = branch1.bzrdir.sprout('branch').open_branch()
86
132
branch2.set_push_location(branch1.bzrdir.root_transport.base)
87
out, err = self.runbzr('info branch --verbose')
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
97
157
control: All-in-one format 6
116
175
first revision: %s
117
176
latest revision: %s
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,
180
""" % (datestring_first, datestring_first,
131
182
self.assertEqual('', err)
133
184
# Branch and bind to standalone, needs upgrade to metadir
134
185
# (creates backup as unknown)
135
186
branch1.bzrdir.sprout('bound')
136
bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
137
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
187
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
188
upgrade.upgrade('bound', knit1_format)
189
branch3 = bzrdir.BzrDir.open('bound').open_branch()
138
190
branch3.bind(branch1)
139
191
bound_tree = branch3.bzrdir.open_workingtree()
140
out, err = self.runbzr('info bound')
192
out, err = self.run_bzr('info -v bound')
141
193
self.assertEqualDiff(
144
checkout of branch: %s
194
"""Checkout (format: knit)
197
checkout of branch: standalone
146
199
Related branches:
200
parent branch: standalone
150
203
control: Meta directory format 1
152
branch: Branch format 5
155
208
In the working tree:
168
221
first revision: %s
169
222
latest revision: %s
174
""" % (branch3.bzrdir.root_transport.base,
175
branch1.bzrdir.root_transport.base,
176
branch1.bzrdir.root_transport.base,
177
bound_tree._format.get_format_description(),
226
""" % (bound_tree._format.get_format_description(),
227
branch3._format.get_format_description(),
178
228
branch3.repository._format.get_format_description(),
179
229
datestring_first, datestring_first,
180
# poking at _revision_store isn't all that clean, but neither is
181
# having the ui test dependent on the exact overhead of a given store.
182
branch3.repository._revision_store.total_size(
183
branch3.repository.get_transaction())[1] / 1024,
185
231
self.assertEqual('', err)
187
233
# Checkout standalone (same as above, but does not have parent set)
188
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
189
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
190
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout')
191
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
234
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
192
236
branch4.bind(branch1)
193
237
branch4.bzrdir.open_workingtree().update()
194
out, err = self.runbzr('info checkout --verbose')
238
out, err = self.run_bzr('info checkout --verbose')
195
239
self.assertEqualDiff(
198
checkout of branch: %s
240
"""Checkout (format: knit)
242
checkout root: checkout
243
checkout of branch: standalone
201
246
control: Meta directory format 1
220
264
first revision: %s
221
265
latest revision: %s
226
""" % (branch4.bzrdir.root_transport.base,
227
branch1.bzrdir.root_transport.base,
228
branch4.repository._format.get_format_description(),
269
""" % (branch4.repository._format.get_format_description(),
229
270
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,
235
272
self.assertEqual('', err)
237
274
# Lightweight checkout (same as above, different branch and repository)
238
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
239
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
240
transport.mkdir('lightcheckout')
241
dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
242
bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
243
dir5.create_workingtree()
244
tree5 = dir5.open_workingtree()
245
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
275
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
246
276
branch5 = tree5.branch
247
out, err = self.runbzr('info lightcheckout')
277
out, err = self.run_bzr('info -v lightcheckout')
248
278
self.assertEqualDiff(
250
light checkout root: %s
251
checkout of branch: %s
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
254
288
control: Meta directory format 1
255
working tree: Working tree format 3
289
working tree: Working tree format 4
256
290
branch: Branch format 4
257
291
repository: Weave repository format 6
320
351
first revision: %s
321
352
latest revision: %s
326
""" % (branch2.bzrdir.root_transport.base,
327
branch1.bzrdir.root_transport.base,
328
branch1.bzrdir.root_transport.base,
329
datestring_first, datestring_first,
356
""" % (datestring_first, datestring_first,
331
358
self.assertEqual('', err)
333
360
# Out of date bound branch
334
out, err = self.runbzr('info bound')
361
out, err = self.run_bzr('info -v bound')
335
362
self.assertEqualDiff(
338
checkout of branch: %s
363
"""Checkout (format: knit)
366
checkout of branch: standalone
340
368
Related branches:
369
parent branch: standalone
344
372
control: Meta directory format 1
364
392
first revision: %s
365
393
latest revision: %s
370
""" % (branch3.bzrdir.root_transport.base,
371
branch1.bzrdir.root_transport.base,
372
branch1.bzrdir.root_transport.base,
373
branch3.repository._format.get_format_description(),
397
""" % (branch3.repository._format.get_format_description(),
374
398
datestring_first, datestring_first,
375
# poking at _revision_store isn't all that clean, but neither is
376
# having the ui test dependent on the exact overhead of a given store.
377
branch3.repository._revision_store.total_size(
378
branch3.repository.get_transaction())[1] / 1024,
380
400
self.assertEqual('', err)
382
402
# Out of date checkout
383
out, err = self.runbzr('info checkout')
403
out, err = self.run_bzr('info -v checkout')
384
404
self.assertEqualDiff(
387
checkout of branch: %s
405
"""Checkout (format: knit)
407
checkout root: checkout
408
checkout of branch: standalone
390
411
control: Meta directory format 1
410
431
first revision: %s
411
432
latest revision: %s
416
""" % (branch4.bzrdir.root_transport.base,
417
branch1.bzrdir.root_transport.base,
418
branch4.repository._format.get_format_description(),
436
""" % (branch4.repository._format.get_format_description(),
419
437
datestring_first, datestring_first,
420
# poking at _revision_store isn't all that clean, but neither is
421
# having the ui test dependent on the exact overhead of a given store.
422
branch4.repository._revision_store.total_size(
423
branch4.repository.get_transaction())[1] / 1024,
425
439
self.assertEqual('', err)
427
441
# Out of date lightweight checkout
428
out, err = self.runbzr('info lightcheckout --verbose')
442
out, err = self.run_bzr('info lightcheckout --verbose')
429
443
self.assertEqualDiff(
431
light checkout root: %s
432
checkout of branch: %s
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
435
453
control: Meta directory format 1
436
working tree: Working tree format 3
454
working tree: Working tree format 4
437
455
branch: Branch format 4
438
456
repository: Weave repository format 6
456
473
first revision: %s
457
474
latest revision: %s
462
""" % (tree5.bzrdir.root_transport.base,
463
branch1.bzrdir.root_transport.base,
464
datestring_first, datestring_last,
478
""" % (datestring_first, datestring_last,), out)
466
479
self.assertEqual('', err)
468
481
def test_info_standalone_no_tree(self):
469
482
# create standalone branch without a working tree
483
format = bzrdir.format_registry.make_bzrdir('default')
470
484
branch = self.make_branch('branch')
471
485
repo = branch.repository
472
out, err = self.runbzr('info branch')
486
out, err = self.run_bzr('info branch -v')
473
487
self.assertEqualDiff(
488
"""Standalone branch (format: %s)
478
493
control: Meta directory format 1
479
branch: Branch format 5
488
""" % (branch.bzrdir.root_transport.base,
489
repo._format.get_format_description(),
502
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
503
format.get_branch_format().get_format_description(),
504
format.repository_format.get_format_description(),
491
506
self.assertEqual('', err)
493
508
def test_info_shared_repository(self):
494
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
495
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
509
format = bzrdir.format_registry.make_bzrdir('knit')
496
510
transport = self.get_transport()
498
512
# Create shared repository
499
repo = self.make_repository('repo', shared=True)
513
repo = self.make_repository('repo', shared=True, format=format)
500
514
repo.set_make_working_trees(False)
501
out, err = self.runbzr('info repo')
515
out, err = self.run_bzr('info -v repo')
502
516
self.assertEqualDiff(
517
"""Shared repository (format: dirstate or dirstate-tags or knit)
504
519
shared repository: %s
507
522
control: Meta directory format 1
513
""" % (repo.bzrdir.root_transport.base,
514
repo._format.get_format_description(),
527
""" % ('repo', format.repository_format.get_format_description(),
516
529
self.assertEqual('', err)
518
531
# Create branch inside shared repository
519
532
repo.bzrdir.root_transport.mkdir('branch')
520
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
521
out, err = self.runbzr('info repo/branch')
533
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
535
out, err = self.run_bzr('info -v repo/branch')
522
536
self.assertEqualDiff(
524
shared repository: %s
525
repository branch: branch
537
"""Repository branch (format: dirstate or knit)
539
shared repository: repo
540
repository branch: repo/branch
528
543
control: Meta directory format 1
529
branch: Branch format 5
538
""" % (repo.bzrdir.root_transport.base,
539
repo._format.get_format_description(),
552
""" % (format.get_branch_format().get_format_description(),
553
format.repository_format.get_format_description(),
541
555
self.assertEqual('', err)
543
557
# Create lightweight checkout
544
558
transport.mkdir('tree')
545
559
transport.mkdir('tree/lightcheckout')
546
dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
547
bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
548
dir2.create_workingtree()
549
tree2 = dir2.open_workingtree()
560
tree2 = branch1.create_checkout('tree/lightcheckout',
550
562
branch2 = tree2.branch
551
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
563
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
564
shared_repo=repo, repo_branch=branch1, verbose=True)
553
566
# Create normal checkout
554
567
tree3 = branch1.create_checkout('tree/checkout')
561
574
tree2.commit('commit one')
562
575
rev = repo.get_revision(branch2.revision_history()[0])
563
576
datestring_first = format_date(rev.timestamp, rev.timezone)
564
out, err = self.runbzr('info tree/lightcheckout --verbose')
577
out, err = self.run_bzr('info tree/lightcheckout --verbose')
565
578
self.assertEqualDiff(
567
light checkout root: %s
568
shared repository: %s
569
repository branch: branch
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
572
589
control: Meta directory format 1
573
working tree: Working tree format 3
574
branch: Branch format 5
590
working tree: Working tree format 4
577
594
In the working tree:
591
607
first revision: %s
592
608
latest revision: %s
597
""" % (tree2.bzrdir.root_transport.base,
598
repo.bzrdir.root_transport.base,
599
repo._format.get_format_description(),
612
""" % (format.get_branch_format().get_format_description(),
613
format.repository_format.get_format_description(),
600
614
datestring_first, datestring_first,
601
# poking at _revision_store isn't all that clean, but neither is
602
# having the ui test dependent on the exact overhead of a given store.
603
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
605
616
self.assertEqual('', err)
607
618
# Out of date checkout
608
out, err = self.runbzr('info tree/checkout')
619
out, err = self.run_bzr('info -v tree/checkout')
609
620
self.assertEqualDiff(
612
checkout of branch: %s
621
"""Checkout (format: dirstate)
623
checkout root: tree/checkout
624
checkout of branch: repo/branch
615
627
control: Meta directory format 1
616
working tree: Working tree format 3
617
branch: Branch format 5
628
working tree: Working tree format 4
620
632
Branch is out of date: missing 1 revision.
674
684
first revision: %s
675
685
latest revision: %s
680
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
681
repo._format.get_format_description(),
689
""" % (format.get_branch_format().get_format_description(),
690
format.repository_format.get_format_description(),
682
691
datestring_first, datestring_first,
683
# poking at _revision_store isn't all that clean, but neither is
684
# having the ui test dependent on the exact overhead of a given store.
685
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
687
693
self.assertEqual('', err)
688
694
tree3.commit('commit two')
690
696
# Out of date lightweight checkout
691
697
rev = repo.get_revision(branch1.revision_history()[-1])
692
698
datestring_last = format_date(rev.timestamp, rev.timezone)
693
out, err = self.runbzr('info tree/lightcheckout --verbose')
699
out, err = self.run_bzr('info tree/lightcheckout --verbose')
694
700
self.assertEqualDiff(
696
light checkout root: %s
697
shared repository: %s
698
repository branch: branch
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
701
711
control: Meta directory format 1
702
working tree: Working tree format 3
703
branch: Branch format 5
712
working tree: Working tree format 4
706
716
Working tree is out of date: missing 1 revision.
722
731
first revision: %s
723
732
latest revision: %s
728
""" % (tree2.bzrdir.root_transport.base,
729
repo.bzrdir.root_transport.base,
730
repo._format.get_format_description(),
736
""" % (format.get_branch_format().get_format_description(),
737
format.repository_format.get_format_description(),
731
738
datestring_first, datestring_last,
732
# poking at _revision_store isn't all that clean, but neither is
733
# having the ui test dependent on the exact overhead of a given store.
734
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
736
740
self.assertEqual('', err)
738
742
# Show info about shared branch
739
out, err = self.runbzr('info repo/branch --verbose')
743
out, err = self.run_bzr('info repo/branch --verbose')
740
744
self.assertEqualDiff(
742
shared repository: %s
743
repository branch: branch
745
"""Repository branch (format: dirstate or knit)
747
shared repository: repo
748
repository branch: repo/branch
746
751
control: Meta directory format 1
747
branch: Branch format 5
754
758
first revision: %s
755
759
latest revision: %s
760
""" % (repo.bzrdir.root_transport.base,
761
repo._format.get_format_description(),
763
""" % (format.get_branch_format().get_format_description(),
764
format.repository_format.get_format_description(),
762
765
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.runbzr('info repo')
770
out, err = self.run_bzr('info -v repo')
771
771
self.assertEqualDiff(
773
shared repository: %s
772
"""Shared repository (format: dirstate or dirstate-tags or knit)
774
shared repository: repo
776
777
control: Meta directory format 1
782
""" % (repo.bzrdir.root_transport.base,
783
repo._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,
782
""" % (format.repository_format.get_format_description(),
788
784
self.assertEqual('', err)
790
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
792
786
def test_info_shared_repository_with_trees(self):
793
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
794
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
787
format = bzrdir.format_registry.make_bzrdir('knit')
795
788
transport = self.get_transport()
797
790
# Create shared repository with working trees
798
repo = self.make_repository('repo', shared=True)
791
repo = self.make_repository('repo', shared=True, format=format)
799
792
repo.set_make_working_trees(True)
800
out, err = self.runbzr('info repo')
793
out, err = self.run_bzr('info -v repo')
801
794
self.assertEqualDiff(
803
shared repository: %s
795
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
797
shared repository: repo
806
800
control: Meta directory format 1
809
803
Create working tree for new branches inside the repository.
814
""" % (repo.bzrdir.root_transport.base,
815
repo._format.get_format_description(),
807
""" % (format.repository_format.get_format_description(),
817
809
self.assertEqual('', err)
819
811
# Create two branches
820
812
repo.bzrdir.root_transport.mkdir('branch1')
821
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
813
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
822
815
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
824
817
# Empty first branch
825
out, err = self.runbzr('info repo/branch1 --verbose')
818
out, err = self.run_bzr('info repo/branch1 --verbose')
826
819
self.assertEqualDiff(
828
shared repository: %s
829
repository checkout: branch1
820
"""Repository tree (format: knit)
822
shared repository: repo
823
repository branch: repo/branch1
832
826
control: Meta directory format 1
833
827
working tree: Working tree format 3
834
branch: Branch format 5
837
831
In the working tree:
891
884
first revision: %s
892
885
latest revision: %s
897
""" % (repo.bzrdir.root_transport.base,
898
repo._format.get_format_description(),
889
""" % (format.get_branch_format().get_format_description(),
890
format.repository_format.get_format_description(),
899
891
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,
904
893
self.assertEqual('', err)
906
895
# Out of date second branch
907
out, err = self.runbzr('info repo/branch2 --verbose')
896
out, err = self.run_bzr('info repo/branch2 --verbose')
908
897
self.assertEqualDiff(
910
shared repository: %s
911
repository checkout: branch2
898
"""Repository tree (format: knit)
900
shared repository: repo
901
repository branch: repo/branch2
913
903
Related branches:
904
parent branch: repo/branch1
917
907
control: Meta directory format 1
918
908
working tree: Working tree format 3
919
branch: Branch format 5
922
912
In the working tree:
939
""" % (repo.bzrdir.root_transport.base,
940
branch1.bzrdir.root_transport.base,
941
repo._format.get_format_description(),
942
# poking at _revision_store isn't all that clean, but neither is
943
# having the ui test dependent on the exact overhead of a given store.
944
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
927
""" % (format.get_branch_format().get_format_description(),
928
format.repository_format.get_format_description(),
946
930
self.assertEqual('', err)
948
932
# Update second branch
949
933
tree2 = branch2.bzrdir.open_workingtree()
950
934
tree2.pull(branch1)
951
out, err = self.runbzr('info repo/branch2')
935
out, err = self.run_bzr('info -v repo/branch2')
952
936
self.assertEqualDiff(
954
shared repository: %s
955
repository checkout: branch2
937
"""Repository tree (format: knit)
939
shared repository: repo
940
repository branch: repo/branch2
957
942
Related branches:
943
parent branch: repo/branch1
961
946
control: Meta directory format 1
962
947
working tree: Working tree format 3
963
branch: Branch format 5
966
951
In the working tree:
979
964
first revision: %s
980
965
latest revision: %s
985
""" % (repo.bzrdir.root_transport.base,
986
branch1.bzrdir.root_transport.base,
987
repo._format.get_format_description(),
969
""" % (format.get_branch_format().get_format_description(),
970
format.repository_format.get_format_description(),
988
971
datestring_first, datestring_first,
989
# poking at _revision_store isn't all that clean, but neither is
990
# having the ui test dependent on the exact overhead of a given store.
991
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
993
973
self.assertEqual('', err)
995
975
# Show info about repository with revisions
996
out, err = self.runbzr('info repo')
976
out, err = self.run_bzr('info -v repo')
997
977
self.assertEqualDiff(
999
shared repository: %s
978
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
980
shared repository: repo
1002
983
control: Meta directory format 1
1005
986
Create working tree for new branches inside the repository.
1010
""" % (repo.bzrdir.root_transport.base,
1011
repo._format.get_format_description(),
1012
# poking at _revision_store isn't all that clean, but neither is
1013
# having the ui test dependent on the exact overhead of a given store.
1014
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
990
""" % (format.repository_format.get_format_description(),
1017
993
self.assertEqual('', err)
1019
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1021
995
def test_info_shared_repository_with_tree_in_root(self):
1022
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1023
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
996
format = bzrdir.format_registry.make_bzrdir('knit')
1024
997
transport = self.get_transport()
1026
999
# Create shared repository with working trees
1027
repo = self.make_repository('repo', shared=True)
1000
repo = self.make_repository('repo', shared=True, format=format)
1028
1001
repo.set_make_working_trees(True)
1029
out, err = self.runbzr('info repo')
1002
out, err = self.run_bzr('info -v repo')
1030
1003
self.assertEqualDiff(
1032
shared repository: %s
1004
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1006
shared repository: repo
1035
1009
control: Meta directory format 1
1074
1047
Branch history:
1080
""" % (repo.bzrdir.root_transport.base,
1081
repo._format.get_format_description(),
1083
self.assertEqual('', err)
1085
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1087
def assertCheckoutStatusOutput(self,
1052
""" % (format.get_branch_format().get_format_description(),
1053
format.repository_format.get_format_description(),
1055
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,
1088
1084
command_string, lco_tree, shared_repo=None,
1089
1085
repo_branch=None,
1090
1086
tree_locked=False,
1091
1087
branch_locked=False, repo_locked=False,
1093
light_checkout=True):
1094
"""Check the output of info in a light checkout tree.
1089
light_checkout=True,
1090
checkout_root=None):
1091
"""Check the output of info in a checkout.
1096
1093
This is not quite a mirror of the info code: rather than using the
1097
1094
tree being examined to predict output, it uses a bunch of flags which
1098
1095
allow us, the test writers, to document what *should* be present in
1099
1096
the output. Removing this separation would remove the value of the
1102
1099
:param path: the path to the light checkout.
1103
1100
:param lco_tree: the tree object for the light checkout.
1104
1101
:param shared_repo: A shared repository is in use, expect that in
1108
1105
:param tree_locked: If true, expect the tree to be locked.
1109
1106
:param branch_locked: If true, expect the branch to be locked.
1110
1107
:param repo_locked: If true, expect the repository to be locked.
1111
:param verbose: If true, expect verbose output
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
1113
out, err = self.runbzr('info %s' % command_string)
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()
1114
1144
if repo_locked or branch_locked or tree_locked:
1115
1145
def locked_message(a_bool):
1128
1158
locked_message(repo_locked)))
1130
1160
expected_lock_output = ''
1131
1163
if light_checkout:
1132
tree_data = (" light checkout root: %s" %
1133
lco_tree.bzrdir.root_transport.base)
1135
tree_data = (" checkout root: %s" %
1136
lco_tree.bzrdir.root_transport.base)
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)))
1137
1170
if shared_repo is not None:
1138
1171
branch_data = (
1139
" shared repository: %s\n"
1140
" repository branch: branch\n" %
1141
shared_repo.bzrdir.root_transport.base)
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)))
1142
1176
elif repo_branch is not None:
1143
1177
branch_data = (
1144
" checkout of branch: %s\n" %
1145
repo_branch.bzrdir.root_transport.base)
1178
"%s checkout of branch: %s\n" %
1180
friendly_location(repo_branch.bzrdir.root_transport.base)))
1147
branch_data = (" checkout of branch: %s\n" %
1182
branch_data = (" checkout of branch: %s\n" %
1148
1183
lco_tree.branch.bzrdir.root_transport.base)
1151
1186
verbose_info = ' 0 committers\n'
1153
1188
verbose_info = ''
1155
1190
self.assertEqualDiff(
1160
1195
control: Meta directory format 1
1161
1196
working tree: %s
1162
branch: Branch format 5
1165
1200
In the working tree:
1191
1228
transport = self.get_transport()
1192
1229
# Create shared repository with a branch
1193
1230
repo = self.make_repository('repo', shared=True,
1194
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1231
format=bzrdir.BzrDirMetaFormat1())
1195
1232
repo.set_make_working_trees(False)
1196
1233
repo.bzrdir.root_transport.mkdir('branch')
1197
1234
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1198
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1235
format=bzrdir.BzrDirMetaFormat1())
1199
1236
# Do a heavy checkout
1200
1237
transport.mkdir('tree')
1201
1238
transport.mkdir('tree/checkout')
1202
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1203
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1239
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1240
format=bzrdir.BzrDirMetaFormat1())
1204
1241
co_branch.bind(repo_branch)
1205
1242
# Do a light checkout of the heavy one
1206
1243
transport.mkdir('tree/lightcheckout')
1207
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1208
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1244
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1245
branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1209
1246
lco_dir.create_workingtree()
1210
1247
lco_tree = lco_dir.open_workingtree()
1216
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1253
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1254
repo_branch=repo_branch,
1255
verbose=True, light_checkout=True)
1218
1257
lco_tree.branch.repository.lock_write()
1220
self.assertCheckoutStatusOutput('tree/lightcheckout',
1259
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1260
lco_tree, repo_branch=repo_branch,
1261
repo_locked=True, verbose=True, light_checkout=True)
1224
1263
lco_tree.branch.repository.unlock()
1226
1265
lco_tree.branch.lock_write()
1228
self.assertCheckoutStatusOutput('tree/lightcheckout',
1267
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1230
1269
branch_locked=True,
1271
repo_branch=repo_branch,
1233
1274
lco_tree.branch.unlock()
1235
1276
lco_tree.lock_write()
1237
self.assertCheckoutStatusOutput('tree/lightcheckout',
1278
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1279
lco_tree, repo_branch=repo_branch,
1239
1280
tree_locked=True,
1240
1281
branch_locked=True,
1243
1285
lco_tree.unlock()
1245
1287
lco_tree.lock_write()
1246
1288
lco_tree.branch.repository.unlock()
1248
self.assertCheckoutStatusOutput('tree/lightcheckout',
1290
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1291
lco_tree, repo_branch=repo_branch,
1250
1292
tree_locked=True,
1253
1296
lco_tree.branch.repository.lock_write()
1254
1297
lco_tree.unlock()
1279
1324
lco_tree.branch.lock_write()
1280
1325
lco_tree.branch.repository.unlock()
1282
self.assertCheckoutStatusOutput('tree/lightcheckout',
1327
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1328
lco_tree, repo_branch=repo_branch,
1286
1332
lco_tree.branch.repository.lock_write()
1287
1333
lco_tree.branch.unlock()
1335
if sys.platform == 'win32':
1336
self.knownFailure('Win32 cannot run "bzr info"'
1337
' when the tree is locked.')
1289
1339
def test_info_locking_oslocks(self):
1290
1340
if sys.platform == "win32":
1291
1341
raise TestSkipped("don't use oslocks on win32 in unix manner")
1293
1343
tree = self.make_branch_and_tree('branch',
1294
format=bzrlib.bzrdir.BzrDirFormat6())
1344
format=bzrdir.BzrDirFormat6())
1296
1346
# Test all permutations of locking the working tree, branch and repository
1297
1347
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1357
1407
Branch history:
1363
""" % (tree.bzrdir.root_transport.base,
1364
tree.branch.repository._format.get_format_description(),
1412
""" % ('branch', tree.branch.repository._format.get_format_description(),
1366
1414
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)