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.osutils import format_date
25
from bzrlib.tests import TestSkipped
26
from bzrlib.tests.blackbox import ExternalBase
29
class TestInfo(ExternalBase):
41
31
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)
32
if sys.platform == "win32":
33
location = "C:/i/do/not/exist/"
35
location = "/i/do/not/exist/"
36
out, err = self.runbzr('info '+location, retcode=3)
45
37
self.assertEqual(out, '')
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
38
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
48
40
def test_info_standalone(self):
49
41
transport = self.get_transport()
51
43
# Create initial standalone branch
52
tree1 = self.make_branch_and_tree('standalone', 'weave')
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)
53
48
self.build_tree(['standalone/a'])
55
50
branch1 = tree1.branch
57
out, err = self.run_bzr('info standalone')
59
"""Standalone tree (format: weave)
61
branch root: standalone
63
self.assertEqual('', err)
65
# Standalone branch - verbose mode
66
out, err = self.run_bzr('info standalone -v')
68
"""Standalone tree (format: weave)
70
branch root: standalone
73
control: All-in-one format 6
74
working tree: Working tree format 2
75
branch: Branch format 4
76
repository: Weave repository format 6
86
0 versioned subdirectories
94
self.assertEqual('', err)
96
# Standalone branch - really verbose mode
97
out, err = self.run_bzr('info standalone -vv')
99
"""Standalone tree (format: weave)
101
branch root: standalone
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
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)
126
79
self.assertEqual('', err)
127
80
tree1.commit('commit one')
128
81
rev = branch1.repository.get_revision(branch1.revision_history()[0])
129
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
82
datestring_first = format_date(rev.timestamp, rev.timezone)
131
84
# Branch standalone with push location
132
85
branch2 = branch1.bzrdir.sprout('branch').open_branch()
133
86
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
87
out, err = self.runbzr('info branch --verbose')
158
97
control: All-in-one format 6
176
116
first revision: %s
177
117
latest revision: %s
181
""" % (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,
183
131
self.assertEqual('', err)
185
133
# Branch and bind to standalone, needs upgrade to metadir
186
134
# (creates backup as unknown)
187
135
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()
136
bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
137
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
191
138
branch3.bind(branch1)
192
139
bound_tree = branch3.bzrdir.open_workingtree()
193
out, err = self.run_bzr('info -v bound')
140
out, err = self.runbzr('info bound')
194
141
self.assertEqualDiff(
195
"""Checkout (format: knit)
198
checkout of branch: standalone
144
checkout of branch: %s
200
146
Related branches:
201
parent branch: standalone
204
150
control: Meta directory format 1
152
branch: Branch format 5
209
155
In the working tree:
222
168
first revision: %s
223
169
latest revision: %s
227
""" % (bound_tree._format.get_format_description(),
228
branch3._format.get_format_description(),
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(),
229
178
branch3.repository._format.get_format_description(),
230
179
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,
232
185
self.assertEqual('', err)
234
187
# Checkout standalone (same as above, but does not have parent set)
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
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)
237
192
branch4.bind(branch1)
238
193
branch4.bzrdir.open_workingtree().update()
239
out, err = self.run_bzr('info checkout --verbose')
194
out, err = self.runbzr('info checkout --verbose')
240
195
self.assertEqualDiff(
241
"""Checkout (format: knit)
243
checkout root: checkout
244
checkout of branch: standalone
198
checkout of branch: %s
247
201
control: Meta directory format 1
265
220
first revision: %s
266
221
latest revision: %s
270
""" % (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(),
271
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,
273
235
self.assertEqual('', err)
275
237
# Lightweight checkout (same as above, different branch and repository)
276
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
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)
277
246
branch5 = tree5.branch
278
out, err = self.run_bzr('info -v lightcheckout')
247
out, err = self.runbzr('info lightcheckout')
279
248
self.assertEqualDiff(
280
"""Lightweight checkout (format: %s)
282
light checkout root: lightcheckout
283
checkout of branch: standalone
250
light checkout root: %s
251
checkout of branch: %s
286
254
control: Meta directory format 1
287
working tree: Working tree format 6
255
working tree: Working tree format 3
288
256
branch: Branch format 4
289
257
repository: Weave repository format 6
349
320
first revision: %s
350
321
latest revision: %s
354
""" % (datestring_first, datestring_first,
326
""" % (branch2.bzrdir.root_transport.base,
327
branch1.bzrdir.root_transport.base,
328
branch1.bzrdir.root_transport.base,
329
datestring_first, datestring_first,
356
331
self.assertEqual('', err)
358
333
# Out of date bound branch
359
out, err = self.run_bzr('info -v bound')
334
out, err = self.runbzr('info bound')
360
335
self.assertEqualDiff(
361
"""Checkout (format: knit)
364
checkout of branch: standalone
338
checkout of branch: %s
366
340
Related branches:
367
parent branch: standalone
370
344
control: Meta directory format 1
390
364
first revision: %s
391
365
latest revision: %s
395
""" % (branch3.repository._format.get_format_description(),
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(),
396
374
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,
398
380
self.assertEqual('', err)
400
382
# Out of date checkout
401
out, err = self.run_bzr('info -v checkout')
383
out, err = self.runbzr('info checkout')
402
384
self.assertEqualDiff(
403
"""Checkout (format: knit)
405
checkout root: checkout
406
checkout of branch: standalone
387
checkout of branch: %s
409
390
control: Meta directory format 1
429
410
first revision: %s
430
411
latest revision: %s
434
""" % (branch4.repository._format.get_format_description(),
416
""" % (branch4.bzrdir.root_transport.base,
417
branch1.bzrdir.root_transport.base,
418
branch4.repository._format.get_format_description(),
435
419
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,
437
425
self.assertEqual('', err)
439
427
# Out of date lightweight checkout
440
out, err = self.run_bzr('info lightcheckout --verbose')
428
out, err = self.runbzr('info lightcheckout --verbose')
441
429
self.assertEqualDiff(
442
"""Lightweight checkout (format: %s)
444
light checkout root: lightcheckout
445
checkout of branch: standalone
431
light checkout root: %s
432
checkout of branch: %s
448
435
control: Meta directory format 1
449
working tree: Working tree format 6
436
working tree: Working tree format 3
450
437
branch: Branch format 4
451
438
repository: Weave repository format 6
468
456
first revision: %s
469
457
latest revision: %s
473
""" % (self._repo_strings, datestring_first, datestring_last,), out)
462
""" % (tree5.bzrdir.root_transport.base,
463
branch1.bzrdir.root_transport.base,
464
datestring_first, datestring_last,
474
466
self.assertEqual('', err)
476
468
def test_info_standalone_no_tree(self):
477
469
# create standalone branch without a working tree
478
format = bzrdir.format_registry.make_bzrdir('default')
479
470
branch = self.make_branch('branch')
480
471
repo = branch.repository
481
out, err = self.run_bzr('info branch -v')
472
out, err = self.runbzr('info branch')
482
473
self.assertEqualDiff(
483
"""Standalone branch (format: %s)
488
478
control: Meta directory format 1
479
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(),
488
""" % (branch.bzrdir.root_transport.base,
489
repo._format.get_format_description(),
501
491
self.assertEqual('', err)
503
493
def test_info_shared_repository(self):
504
format = bzrdir.format_registry.make_bzrdir('knit')
494
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
495
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
505
496
transport = self.get_transport()
507
498
# Create shared repository
508
repo = self.make_repository('repo', shared=True, format=format)
499
repo = self.make_repository('repo', shared=True)
509
500
repo.set_make_working_trees(False)
510
out, err = self.run_bzr('info -v repo')
501
out, err = self.runbzr('info repo')
511
502
self.assertEqualDiff(
512
"""Shared repository (format: dirstate or dirstate-tags or knit)
514
504
shared repository: %s
517
507
control: Meta directory format 1
522
""" % ('repo', format.repository_format.get_format_description(),
513
""" % (repo.bzrdir.root_transport.base,
514
repo._format.get_format_description(),
524
516
self.assertEqual('', err)
526
518
# Create branch inside shared repository
527
519
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')
520
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
521
out, err = self.runbzr('info repo/branch')
531
522
self.assertEqualDiff(
532
"""Repository branch (format: dirstate or knit)
534
shared repository: repo
535
repository branch: repo/branch
524
shared repository: %s
525
repository branch: branch
538
528
control: Meta directory format 1
529
branch: Branch format 5
547
""" % (format.get_branch_format().get_format_description(),
548
format.repository_format.get_format_description(),
538
""" % (repo.bzrdir.root_transport.base,
539
repo._format.get_format_description(),
550
541
self.assertEqual('', err)
552
543
# Create lightweight checkout
553
544
transport.mkdir('tree')
554
545
transport.mkdir('tree/lightcheckout')
555
tree2 = branch1.create_checkout('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()
557
550
branch2 = tree2.branch
558
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
559
shared_repo=repo, repo_branch=branch1, verbose=True)
551
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
561
553
# Create normal checkout
562
554
tree3 = branch1.create_checkout('tree/checkout')
569
561
tree2.commit('commit one')
570
562
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')
563
datestring_first = format_date(rev.timestamp, rev.timezone)
564
out, err = self.runbzr('info tree/lightcheckout --verbose')
573
565
self.assertEqualDiff(
574
"""Lightweight checkout (format: %s)
576
light checkout root: tree/lightcheckout
577
checkout of branch: repo/branch
578
shared repository: repo
567
light checkout root: %s
568
shared repository: %s
569
repository branch: branch
581
572
control: Meta directory format 1
582
working tree: Working tree format 6
573
working tree: Working tree format 3
574
branch: Branch format 5
586
577
In the working tree:
599
591
first revision: %s
600
592
latest revision: %s
604
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
605
format.repository_format.get_format_description(),
597
""" % (tree2.bzrdir.root_transport.base,
598
repo.bzrdir.root_transport.base,
599
repo._format.get_format_description(),
606
600
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,
608
605
self.assertEqual('', err)
610
607
# Out of date checkout
611
out, err = self.run_bzr('info -v tree/checkout')
608
out, err = self.runbzr('info tree/checkout')
612
609
self.assertEqualDiff(
613
"""Checkout (format: unnamed)
615
checkout root: tree/checkout
616
checkout of branch: repo/branch
612
checkout of branch: %s
619
615
control: Meta directory format 1
620
working tree: Working tree format 6
616
working tree: Working tree format 3
617
branch: Branch format 5
624
620
Branch is out of date: missing 1 revision.
676
674
first revision: %s
677
675
latest revision: %s
681
""" % (format.get_branch_format().get_format_description(),
682
format.repository_format.get_format_description(),
680
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
681
repo._format.get_format_description(),
683
682
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,
685
687
self.assertEqual('', err)
686
688
tree3.commit('commit two')
688
690
# Out of date lightweight checkout
689
691
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')
692
datestring_last = format_date(rev.timestamp, rev.timezone)
693
out, err = self.runbzr('info tree/lightcheckout --verbose')
692
694
self.assertEqualDiff(
693
"""Lightweight checkout (format: %s)
695
light checkout root: tree/lightcheckout
696
checkout of branch: repo/branch
697
shared repository: repo
696
light checkout root: %s
697
shared repository: %s
698
repository branch: branch
700
701
control: Meta directory format 1
701
working tree: Working tree format 6
702
working tree: Working tree format 3
703
branch: Branch format 5
705
706
Working tree is out of date: missing 1 revision.
720
722
first revision: %s
721
723
latest revision: %s
725
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
726
format.repository_format.get_format_description(),
728
""" % (tree2.bzrdir.root_transport.base,
729
repo.bzrdir.root_transport.base,
730
repo._format.get_format_description(),
727
731
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,
729
736
self.assertEqual('', err)
731
738
# Show info about shared branch
732
out, err = self.run_bzr('info repo/branch --verbose')
739
out, err = self.runbzr('info repo/branch --verbose')
733
740
self.assertEqualDiff(
734
"""Repository branch (format: dirstate or knit)
736
shared repository: repo
737
repository branch: repo/branch
742
shared repository: %s
743
repository branch: branch
740
746
control: Meta directory format 1
747
branch: Branch format 5
747
754
first revision: %s
748
755
latest revision: %s
752
""" % (format.get_branch_format().get_format_description(),
753
format.repository_format.get_format_description(),
760
""" % (repo.bzrdir.root_transport.base,
761
repo._format.get_format_description(),
754
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,
756
767
self.assertEqual('', err)
758
769
# Show info about repository with revisions
759
out, err = self.run_bzr('info -v repo')
770
out, err = self.runbzr('info repo')
760
771
self.assertEqualDiff(
761
"""Shared repository (format: dirstate or dirstate-tags or knit)
763
shared repository: repo
773
shared repository: %s
766
776
control: Meta directory format 1
771
""" % (format.repository_format.get_format_description(),
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,
773
788
self.assertEqual('', err)
790
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
775
792
def test_info_shared_repository_with_trees(self):
776
format = bzrdir.format_registry.make_bzrdir('knit')
793
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
794
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
777
795
transport = self.get_transport()
779
797
# Create shared repository with working trees
780
repo = self.make_repository('repo', shared=True, format=format)
798
repo = self.make_repository('repo', shared=True)
781
799
repo.set_make_working_trees(True)
782
out, err = self.run_bzr('info -v repo')
800
out, err = self.runbzr('info repo')
783
801
self.assertEqualDiff(
784
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
786
shared repository: repo
803
shared repository: %s
789
806
control: Meta directory format 1
792
809
Create working tree for new branches inside the repository.
796
""" % (format.repository_format.get_format_description(),
814
""" % (repo.bzrdir.root_transport.base,
815
repo._format.get_format_description(),
798
817
self.assertEqual('', err)
800
819
# Create two branches
801
820
repo.bzrdir.root_transport.mkdir('branch1')
802
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
821
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
804
822
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
806
824
# Empty first branch
807
out, err = self.run_bzr('info repo/branch1 --verbose')
825
out, err = self.runbzr('info repo/branch1 --verbose')
808
826
self.assertEqualDiff(
809
"""Repository tree (format: knit)
811
shared repository: repo
812
repository branch: repo/branch1
828
shared repository: %s
829
repository checkout: branch1
815
832
control: Meta directory format 1
816
833
working tree: Working tree format 3
834
branch: Branch format 5
820
837
In the working tree:
873
891
first revision: %s
874
892
latest revision: %s
878
""" % (format.get_branch_format().get_format_description(),
879
format.repository_format.get_format_description(),
897
""" % (repo.bzrdir.root_transport.base,
898
repo._format.get_format_description(),
880
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,
882
904
self.assertEqual('', err)
884
906
# Out of date second branch
885
out, err = self.run_bzr('info repo/branch2 --verbose')
907
out, err = self.runbzr('info repo/branch2 --verbose')
886
908
self.assertEqualDiff(
887
"""Repository tree (format: knit)
889
shared repository: repo
890
repository branch: repo/branch2
910
shared repository: %s
911
repository checkout: branch2
892
913
Related branches:
893
parent branch: repo/branch1
896
917
control: Meta directory format 1
897
918
working tree: Working tree format 3
919
branch: Branch format 5
901
922
In the working tree:
916
""" % (format.get_branch_format().get_format_description(),
917
format.repository_format.get_format_description(),
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,
919
946
self.assertEqual('', err)
921
948
# Update second branch
922
949
tree2 = branch2.bzrdir.open_workingtree()
923
950
tree2.pull(branch1)
924
out, err = self.run_bzr('info -v repo/branch2')
951
out, err = self.runbzr('info repo/branch2')
925
952
self.assertEqualDiff(
926
"""Repository tree (format: knit)
928
shared repository: repo
929
repository branch: repo/branch2
954
shared repository: %s
955
repository checkout: branch2
931
957
Related branches:
932
parent branch: repo/branch1
935
961
control: Meta directory format 1
936
962
working tree: Working tree format 3
963
branch: Branch format 5
940
966
In the working tree:
953
979
first revision: %s
954
980
latest revision: %s
958
""" % (format.get_branch_format().get_format_description(),
959
format.repository_format.get_format_description(),
985
""" % (repo.bzrdir.root_transport.base,
986
branch1.bzrdir.root_transport.base,
987
repo._format.get_format_description(),
960
988
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,
962
993
self.assertEqual('', err)
964
995
# Show info about repository with revisions
965
out, err = self.run_bzr('info -v repo')
996
out, err = self.runbzr('info repo')
966
997
self.assertEqualDiff(
967
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
969
shared repository: repo
999
shared repository: %s
972
1002
control: Meta directory format 1
975
1005
Create working tree for new branches inside the repository.
979
""" % (format.repository_format.get_format_description(),
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,
982
1017
self.assertEqual('', err)
1019
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
984
1021
def test_info_shared_repository_with_tree_in_root(self):
985
format = bzrdir.format_registry.make_bzrdir('knit')
1022
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1023
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
986
1024
transport = self.get_transport()
988
1026
# Create shared repository with working trees
989
repo = self.make_repository('repo', shared=True, format=format)
1027
repo = self.make_repository('repo', shared=True)
990
1028
repo.set_make_working_trees(True)
991
out, err = self.run_bzr('info -v repo')
1029
out, err = self.runbzr('info repo')
992
1030
self.assertEqualDiff(
993
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
995
shared repository: repo
1032
shared repository: %s
998
1035
control: Meta directory format 1
1036
1074
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,
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,
1073
1088
command_string, lco_tree, shared_repo=None,
1074
1089
repo_branch=None,
1075
1090
tree_locked=False,
1076
1091
branch_locked=False, repo_locked=False,
1078
light_checkout=True,
1079
checkout_root=None):
1080
"""Check the output of info in a checkout.
1093
light_checkout=True):
1094
"""Check the output of info in a light checkout tree.
1082
1096
This is not quite a mirror of the info code: rather than using the
1083
1097
tree being examined to predict output, it uses a bunch of flags which
1084
1098
allow us, the test writers, to document what *should* be present in
1085
1099
the output. Removing this separation would remove the value of the
1088
1102
:param path: the path to the light checkout.
1089
1103
:param lco_tree: the tree object for the light checkout.
1090
1104
:param shared_repo: A shared repository is in use, expect that in
1094
1108
:param tree_locked: If true, expect the tree to be locked.
1095
1109
:param branch_locked: If true, expect the branch to be locked.
1096
1110
: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
1111
: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()
1113
out, err = self.runbzr('info %s' % command_string)
1130
1114
if repo_locked or branch_locked or tree_locked:
1131
1115
def locked_message(a_bool):
1144
1128
locked_message(repo_locked)))
1146
1130
expected_lock_output = ''
1149
1131
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)))
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)
1156
1137
if shared_repo is not None:
1157
1138
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)))
1139
" shared repository: %s\n"
1140
" repository branch: branch\n" %
1141
shared_repo.bzrdir.root_transport.base)
1162
1142
elif repo_branch is not None:
1163
1143
branch_data = (
1164
"%s checkout of branch: %s\n" %
1166
friendly_location(repo_branch.bzrdir.root_transport.base)))
1144
" checkout of branch: %s\n" %
1145
repo_branch.bzrdir.root_transport.base)
1168
branch_data = (" checkout of branch: %s\n" %
1147
branch_data = (" checkout of branch: %s\n" %
1169
1148
lco_tree.branch.bzrdir.root_transport.base)
1172
1151
verbose_info = ' 0 committers\n'
1174
1153
verbose_info = ''
1176
1155
self.assertEqualDiff(
1181
1160
control: Meta directory format 1
1182
1161
working tree: %s
1162
branch: Branch format 5
1186
1165
In the working tree:
1214
1191
transport = self.get_transport()
1215
1192
# Create shared repository with a branch
1216
1193
repo = self.make_repository('repo', shared=True,
1217
format=bzrdir.BzrDirMetaFormat1())
1194
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1218
1195
repo.set_make_working_trees(False)
1219
1196
repo.bzrdir.root_transport.mkdir('branch')
1220
1197
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1221
format=bzrdir.BzrDirMetaFormat1())
1198
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1222
1199
# Do a heavy checkout
1223
1200
transport.mkdir('tree')
1224
1201
transport.mkdir('tree/checkout')
1225
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
format=bzrdir.BzrDirMetaFormat1())
1202
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1203
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1227
1204
co_branch.bind(repo_branch)
1228
1205
# Do a light checkout of the heavy one
1229
1206
transport.mkdir('tree/lightcheckout')
1230
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1231
branch.BranchReferenceFormat().initialize(lco_dir,
1232
target_branch=co_branch)
1207
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1208
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1233
1209
lco_dir.create_workingtree()
1234
1210
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)
1216
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1244
1218
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)
1220
self.assertCheckoutStatusOutput('tree/lightcheckout',
1250
1224
lco_tree.branch.repository.unlock()
1252
1226
lco_tree.branch.lock_write()
1254
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1228
self.assertCheckoutStatusOutput('tree/lightcheckout',
1256
1230
branch_locked=True,
1258
repo_branch=repo_branch,
1261
1233
lco_tree.branch.unlock()
1263
1235
lco_tree.lock_write()
1265
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1266
lco_tree, repo_branch=repo_branch,
1237
self.assertCheckoutStatusOutput('tree/lightcheckout',
1267
1239
tree_locked=True,
1268
1240
branch_locked=True,
1272
1243
lco_tree.unlock()
1274
1245
lco_tree.lock_write()
1275
1246
lco_tree.branch.repository.unlock()
1277
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1278
lco_tree, repo_branch=repo_branch,
1248
self.assertCheckoutStatusOutput('tree/lightcheckout',
1279
1250
tree_locked=True,
1283
1253
lco_tree.branch.repository.lock_write()
1284
1254
lco_tree.unlock()
1311
1279
lco_tree.branch.lock_write()
1312
1280
lco_tree.branch.repository.unlock()
1314
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1315
lco_tree, repo_branch=repo_branch,
1282
self.assertCheckoutStatusOutput('tree/lightcheckout',
1319
1286
lco_tree.branch.repository.lock_write()
1320
1287
lco_tree.branch.unlock()
1322
if sys.platform == 'win32':
1323
self.knownFailure('Win32 cannot run "bzr info"'
1324
' when the tree is locked.')
1326
1289
def test_info_locking_oslocks(self):
1327
1290
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()
1291
raise TestSkipped("don't use oslocks on win32 in unix manner")
1335
1293
tree = self.make_branch_and_tree('branch',
1336
format=bzrdir.BzrDirFormat6())
1294
format=bzrlib.bzrdir.BzrDirFormat6())
1338
1296
# Test all permutations of locking the working tree, branch and repository
1339
1297
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1399
1357
Branch history:
1404
""" % ('branch', tree.branch.repository._format.get_format_description(),
1363
""" % (tree.bzrdir.root_transport.base,
1364
tree.branch.repository._format.get_format_description(),
1406
1366
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)