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
from bzrlib.osutils import format_date
25
from bzrlib.tests import TestSkipped
26
from bzrlib.tests.blackbox import ExternalBase
29
class TestInfo(ExternalBase):
34
from bzrlib.tests.matchers import ContainsNoVfsCalls
35
from bzrlib.transport import memory
38
class TestInfo(tests.TestCaseWithTransport):
41
super(TestInfo, self).setUp()
42
self._repo_strings = "2a"
31
44
def test_info_non_existing(self):
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
self.vfs_transport_factory = memory.MemoryServer
46
location = self.get_url()
47
out, err = self.run_bzr('info '+location, retcode=3)
37
48
self.assertEqual(out, '')
38
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
49
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
51
def test_info_empty_controldir(self):
52
self.make_bzrdir('ctrl')
53
out, err = self.run_bzr('info ctrl')
54
self.assertEquals(out,
55
'Empty control directory (format: 2a or pack-0.92)\n'
57
' control directory: ctrl\n')
58
self.assertEquals(err, '')
60
def test_info_empty_controldir_verbose(self):
61
self.make_bzrdir('ctrl')
62
out, err = self.run_bzr('info -v ctrl')
63
self.assertEqualDiff(out,
64
'Empty control directory (format: 2a or pack-0.92)\n'
66
' control directory: ctrl\n\n'
68
' control: Meta directory format 1\n\n'
69
'Control directory:\n'
71
self.assertEquals(err, '')
73
def test_info_dangling_branch_reference(self):
74
br = self.make_branch('target')
75
br.create_checkout('from', lightweight=True)
76
shutil.rmtree('target')
77
out, err = self.run_bzr('info from')
78
self.assertEquals(out,
79
'Dangling branch reference (format: 2a or pack-0.92)\n'
81
' control directory: from\n'
82
' checkout of branch: target\n')
83
self.assertEquals(err, '')
40
85
def test_info_standalone(self):
41
86
transport = self.get_transport()
43
88
# 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)
89
tree1 = self.make_branch_and_tree('standalone', 'knit')
48
90
self.build_tree(['standalone/a'])
50
92
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)
94
out, err = self.run_bzr('info standalone')
96
"""Standalone tree (format: knit)
98
branch root: standalone
100
self.assertEqual('', err)
102
# Standalone branch - verbose mode
103
out, err = self.run_bzr('info standalone -v')
104
self.assertEqualDiff(
105
"""Standalone tree (format: knit)
107
branch root: standalone
110
control: Meta directory format 1
111
working tree: Working tree format 3
112
branch: Branch format 5
113
repository: Knit repository format 1
126
0 versioned subdirectories
134
self.assertEqual('', err)
136
# Standalone branch - really verbose mode
137
out, err = self.run_bzr('info standalone -vv')
138
self.assertEqualDiff(
139
"""Standalone tree (format: knit)
141
branch root: standalone
144
control: Meta directory format 1
145
working tree: Working tree format 3
146
branch: Branch format 5
147
repository: Knit repository format 1
160
0 versioned subdirectories
79
169
self.assertEqual('', err)
80
170
tree1.commit('commit one')
81
rev = branch1.repository.get_revision(branch1.revision_history()[0])
82
datestring_first = format_date(rev.timestamp, rev.timezone)
171
rev = branch1.repository.get_revision(branch1.last_revision())
172
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
84
174
# Branch standalone with push location
85
175
branch2 = branch1.bzrdir.sprout('branch').open_branch()
86
176
branch2.set_push_location(branch1.bzrdir.root_transport.base)
87
out, err = self.runbzr('info branch --verbose')
178
out, err = self.run_bzr('info branch')
179
self.assertEqualDiff(
180
"""Standalone tree (format: knit)
185
push branch: standalone
186
parent branch: standalone
188
self.assertEqual('', err)
190
out, err = self.run_bzr('info branch --verbose')
191
self.assertEqualDiff(
192
"""Standalone tree (format: knit)
197
push branch: standalone
198
parent branch: standalone
97
control: All-in-one format 6
98
working tree: Working tree format 2
99
branch: Branch format 4
100
repository: Weave repository format 6
201
control: Meta directory format 1
202
working tree: Working tree format 3
203
branch: Branch format 5
204
repository: Knit repository format 1
102
209
In the working tree:
116
222
first revision: %s
117
223
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,
227
""" % (datestring_first, datestring_first,
131
229
self.assertEqual('', err)
133
231
# Branch and bind to standalone, needs upgrade to metadir
134
232
# (creates backup as unknown)
135
233
branch1.bzrdir.sprout('bound')
136
bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
137
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
234
knit1_format = controldir.format_registry.make_bzrdir('knit')
235
upgrade.upgrade('bound', knit1_format)
236
branch3 = controldir.ControlDir.open('bound').open_branch()
138
237
branch3.bind(branch1)
139
238
bound_tree = branch3.bzrdir.open_workingtree()
140
out, err = self.runbzr('info bound')
239
out, err = self.run_bzr('info -v bound')
141
240
self.assertEqualDiff(
144
checkout of branch: %s
241
"""Checkout (format: knit)
244
checkout of branch: standalone
146
246
Related branches:
247
parent branch: standalone
150
250
control: Meta directory format 1
152
branch: Branch format 5
155
258
In the working tree:
163
266
0 versioned subdirectories
168
271
first revision: %s
169
272
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(),
276
""" % (bound_tree._format.get_format_description(),
277
branch3._format.get_format_description(),
178
278
branch3.repository._format.get_format_description(),
179
279
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
281
self.assertEqual('', err)
187
283
# 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)
284
branch4 = controldir.ControlDir.create_branch_convenience('checkout',
192
286
branch4.bind(branch1)
193
287
branch4.bzrdir.open_workingtree().update()
194
out, err = self.runbzr('info checkout --verbose')
288
out, err = self.run_bzr('info checkout --verbose')
195
289
self.assertEqualDiff(
198
checkout of branch: %s
290
"""Checkout (format: knit)
292
checkout root: checkout
293
checkout of branch: standalone
201
296
control: Meta directory format 1
220
317
first revision: %s
221
318
latest revision: %s
226
""" % (branch4.bzrdir.root_transport.base,
227
branch1.bzrdir.root_transport.base,
228
branch4.repository._format.get_format_description(),
322
""" % (branch4.repository._format.get_format_description(),
229
323
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
325
self.assertEqual('', err)
237
327
# 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)
328
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
246
329
branch5 = tree5.branch
247
out, err = self.runbzr('info lightcheckout')
330
out, err = self.run_bzr('info -v lightcheckout')
331
if "metaweave" in controldir.format_registry:
332
format_description = "knit or metaweave"
334
format_description = "knit"
248
335
self.assertEqualDiff(
250
light checkout root: %s
251
checkout of branch: %s
336
"""Lightweight checkout (format: %s)
338
light checkout root: lightcheckout
339
checkout of branch: standalone
254
342
control: Meta directory format 1
255
343
working tree: Working tree format 3
256
branch: Branch format 4
257
repository: Weave repository format 6
344
branch: Branch format 5
345
repository: Knit repository format 1
259
350
In the working tree:
272
363
first revision: %s
273
364
latest revision: %s
278
""" % (tree5.bzrdir.root_transport.base,
279
branch1.bzrdir.root_transport.base,
280
datestring_first, datestring_first,
368
""" % (format_description, datestring_first, datestring_first,), out)
282
369
self.assertEqual('', err)
284
371
# Update initial standalone branch
285
372
self.build_tree(['standalone/b'])
287
374
tree1.commit('commit two')
288
rev = branch1.repository.get_revision(branch1.revision_history()[-1])
289
datestring_last = format_date(rev.timestamp, rev.timezone)
375
rev = branch1.repository.get_revision(branch1.last_revision())
376
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
291
378
# Out of date branched standalone branch will not be detected
292
out, err = self.runbzr('info branch')
379
out, err = self.run_bzr('info -v branch')
293
380
self.assertEqualDiff(
381
"""Standalone tree (format: knit)
297
385
Related branches:
299
publish to branch: %s
386
push branch: standalone
387
parent branch: standalone
302
control: All-in-one format 6
303
working tree: Working tree format 2
304
branch: Branch format 4
305
repository: Weave repository format 6
390
control: Meta directory format 1
391
working tree: Working tree format 3
392
branch: Branch format 5
393
repository: Knit repository format 1
307
398
In the working tree:
364
455
first revision: %s
365
456
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(),
460
""" % (branch3.repository._format.get_format_description(),
374
461
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
463
self.assertEqual('', err)
382
465
# Out of date checkout
383
out, err = self.runbzr('info checkout')
466
out, err = self.run_bzr('info -v checkout')
384
467
self.assertEqualDiff(
387
checkout of branch: %s
468
"""Checkout (format: knit)
470
checkout root: checkout
471
checkout of branch: standalone
390
474
control: Meta directory format 1
410
497
first revision: %s
411
498
latest revision: %s
416
""" % (branch4.bzrdir.root_transport.base,
417
branch1.bzrdir.root_transport.base,
418
branch4.repository._format.get_format_description(),
502
""" % (branch4.repository._format.get_format_description(),
419
503
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
505
self.assertEqual('', err)
427
507
# Out of date lightweight checkout
428
out, err = self.runbzr('info lightcheckout --verbose')
508
out, err = self.run_bzr('info lightcheckout --verbose')
429
509
self.assertEqualDiff(
431
light checkout root: %s
432
checkout of branch: %s
510
"""Lightweight checkout (format: %s)
512
light checkout root: lightcheckout
513
checkout of branch: standalone
435
516
control: Meta directory format 1
436
517
working tree: Working tree format 3
437
branch: Branch format 4
438
repository: Weave repository format 6
518
branch: Branch format 5
519
repository: Knit repository format 1
440
524
Working tree is out of date: missing 1 revision.
456
539
first revision: %s
457
540
latest revision: %s
462
""" % (tree5.bzrdir.root_transport.base,
463
branch1.bzrdir.root_transport.base,
464
datestring_first, datestring_last,
544
""" % (format_description, datestring_first, datestring_last,), out)
466
545
self.assertEqual('', err)
468
547
def test_info_standalone_no_tree(self):
469
548
# create standalone branch without a working tree
549
format = controldir.format_registry.make_bzrdir('default')
470
550
branch = self.make_branch('branch')
471
551
repo = branch.repository
472
out, err = self.runbzr('info branch')
552
out, err = self.run_bzr('info branch -v')
473
553
self.assertEqualDiff(
554
"""Standalone branch (format: %s)
478
559
control: Meta directory format 1
479
branch: Branch format 5
488
""" % (branch.bzrdir.root_transport.base,
489
repo._format.get_format_description(),
571
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
572
format.get_branch_format().get_format_description(),
573
format.repository_format.get_format_description(),
491
575
self.assertEqual('', err)
493
577
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())
578
format = controldir.format_registry.make_bzrdir('knit')
496
579
transport = self.get_transport()
498
581
# Create shared repository
499
repo = self.make_repository('repo', shared=True)
582
repo = self.make_repository('repo', shared=True, format=format)
500
583
repo.set_make_working_trees(False)
501
out, err = self.runbzr('info repo')
584
out, err = self.run_bzr('info -v repo')
502
585
self.assertEqualDiff(
586
"""Shared repository (format: dirstate or dirstate-tags or knit)
504
588
shared repository: %s
507
591
control: Meta directory format 1
513
""" % (repo.bzrdir.root_transport.base,
514
repo._format.get_format_description(),
599
""" % ('repo', format.repository_format.get_format_description(),
516
601
self.assertEqual('', err)
518
603
# Create branch inside shared repository
519
604
repo.bzrdir.root_transport.mkdir('branch')
520
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
521
out, err = self.runbzr('info repo/branch')
605
branch1 = controldir.ControlDir.create_branch_convenience(
606
'repo/branch', format=format)
607
out, err = self.run_bzr('info -v repo/branch')
522
608
self.assertEqualDiff(
524
shared repository: %s
525
repository branch: branch
609
"""Repository branch (format: dirstate or knit)
611
shared repository: repo
612
repository branch: repo/branch
528
615
control: Meta directory format 1
529
branch: Branch format 5
538
""" % (repo.bzrdir.root_transport.base,
539
repo._format.get_format_description(),
627
""" % (format.get_branch_format().get_format_description(),
628
format.repository_format.get_format_description(),
541
630
self.assertEqual('', err)
543
632
# Create lightweight checkout
544
633
transport.mkdir('tree')
545
634
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()
635
tree2 = branch1.create_checkout('tree/lightcheckout',
550
637
branch2 = tree2.branch
551
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
638
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
639
shared_repo=repo, repo_branch=branch1, verbose=True)
553
641
# Create normal checkout
554
642
tree3 = branch1.create_checkout('tree/checkout')
591
682
first revision: %s
592
683
latest revision: %s
597
""" % (tree2.bzrdir.root_transport.base,
598
repo.bzrdir.root_transport.base,
599
repo._format.get_format_description(),
687
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
688
format.repository_format.get_format_description(),
600
689
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
691
self.assertEqual('', err)
607
693
# Out of date checkout
608
out, err = self.runbzr('info tree/checkout')
694
out, err = self.run_bzr('info -v tree/checkout')
609
695
self.assertEqualDiff(
612
checkout of branch: %s
696
"""Checkout (format: unnamed)
698
checkout root: tree/checkout
699
checkout of branch: repo/branch
615
702
control: Meta directory format 1
616
working tree: Working tree format 3
617
branch: Branch format 5
703
working tree: Working tree format 6
620
710
Branch is out of date: missing 1 revision.
622
712
In the working tree:
674
765
first revision: %s
675
766
latest revision: %s
680
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
681
repo._format.get_format_description(),
770
""" % (format.get_branch_format().get_format_description(),
771
format.repository_format.get_format_description(),
682
772
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
774
self.assertEqual('', err)
688
775
tree3.commit('commit two')
690
777
# Out of date lightweight checkout
691
rev = repo.get_revision(branch1.revision_history()[-1])
692
datestring_last = format_date(rev.timestamp, rev.timezone)
693
out, err = self.runbzr('info tree/lightcheckout --verbose')
778
rev = repo.get_revision(branch1.last_revision())
779
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
780
out, err = self.run_bzr('info tree/lightcheckout --verbose')
694
781
self.assertEqualDiff(
696
light checkout root: %s
697
shared repository: %s
698
repository branch: branch
782
"""Lightweight checkout (format: %s)
784
light checkout root: tree/lightcheckout
785
checkout of branch: repo/branch
786
shared repository: repo
701
789
control: Meta directory format 1
702
working tree: Working tree format 3
703
branch: Branch format 5
790
working tree: Working tree format 6
706
797
Working tree is out of date: missing 1 revision.
708
799
In the working tree:
722
812
first revision: %s
723
813
latest revision: %s
728
""" % (tree2.bzrdir.root_transport.base,
729
repo.bzrdir.root_transport.base,
730
repo._format.get_format_description(),
817
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
818
format.repository_format.get_format_description(),
731
819
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
821
self.assertEqual('', err)
738
823
# Show info about shared branch
739
out, err = self.runbzr('info repo/branch --verbose')
824
out, err = self.run_bzr('info repo/branch --verbose')
740
825
self.assertEqualDiff(
742
shared repository: %s
743
repository branch: branch
826
"""Repository branch (format: dirstate or knit)
828
shared repository: repo
829
repository branch: repo/branch
746
832
control: Meta directory format 1
747
branch: Branch format 5
754
842
first revision: %s
755
843
latest revision: %s
760
""" % (repo.bzrdir.root_transport.base,
761
repo._format.get_format_description(),
847
""" % (format.get_branch_format().get_format_description(),
848
format.repository_format.get_format_description(),
762
849
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
851
self.assertEqual('', err)
769
853
# Show info about repository with revisions
770
out, err = self.runbzr('info repo')
854
out, err = self.run_bzr('info -v repo')
771
855
self.assertEqualDiff(
773
shared repository: %s
856
"""Shared repository (format: dirstate or dirstate-tags or knit)
858
shared repository: repo
776
861
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,
869
""" % (format.repository_format.get_format_description(),
788
871
self.assertEqual('', err)
790
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
792
873
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())
874
format = controldir.format_registry.make_bzrdir('knit')
795
875
transport = self.get_transport()
797
877
# Create shared repository with working trees
798
repo = self.make_repository('repo', shared=True)
878
repo = self.make_repository('repo', shared=True, format=format)
799
879
repo.set_make_working_trees(True)
800
out, err = self.runbzr('info repo')
880
out, err = self.run_bzr('info -v repo')
801
881
self.assertEqualDiff(
803
shared repository: %s
882
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
884
shared repository: repo
806
887
control: Meta directory format 1
809
893
Create working tree for new branches inside the repository.
814
""" % (repo.bzrdir.root_transport.base,
815
repo._format.get_format_description(),
897
""" % (format.repository_format.get_format_description(),
817
899
self.assertEqual('', err)
819
901
# Create two branches
820
902
repo.bzrdir.root_transport.mkdir('branch1')
821
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
903
branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
822
905
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
824
907
# Empty first branch
825
out, err = self.runbzr('info repo/branch1 --verbose')
908
out, err = self.run_bzr('info repo/branch1 --verbose')
826
909
self.assertEqualDiff(
828
shared repository: %s
829
repository checkout: branch1
910
"""Repository tree (format: knit)
912
shared repository: repo
913
repository branch: repo/branch1
832
916
control: Meta directory format 1
833
917
working tree: Working tree format 3
834
branch: Branch format 5
837
924
In the working tree:
891
980
first revision: %s
892
981
latest revision: %s
897
""" % (repo.bzrdir.root_transport.base,
898
repo._format.get_format_description(),
985
""" % (format.get_branch_format().get_format_description(),
986
format.repository_format.get_format_description(),
899
987
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
989
self.assertEqual('', err)
906
991
# Out of date second branch
907
out, err = self.runbzr('info repo/branch2 --verbose')
992
out, err = self.run_bzr('info repo/branch2 --verbose')
908
993
self.assertEqualDiff(
910
shared repository: %s
911
repository checkout: branch2
994
"""Repository tree (format: knit)
996
shared repository: repo
997
repository branch: repo/branch2
913
999
Related branches:
1000
parent branch: repo/branch1
917
1003
control: Meta directory format 1
918
1004
working tree: Working tree format 3
919
branch: Branch format 5
922
1011
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,
1026
""" % (format.get_branch_format().get_format_description(),
1027
format.repository_format.get_format_description(),
946
1029
self.assertEqual('', err)
948
1031
# Update second branch
949
1032
tree2 = branch2.bzrdir.open_workingtree()
950
1033
tree2.pull(branch1)
951
out, err = self.runbzr('info repo/branch2')
1034
out, err = self.run_bzr('info -v repo/branch2')
952
1035
self.assertEqualDiff(
954
shared repository: %s
955
repository checkout: branch2
1036
"""Repository tree (format: knit)
1038
shared repository: repo
1039
repository branch: repo/branch2
957
1041
Related branches:
1042
parent branch: repo/branch1
961
1045
control: Meta directory format 1
962
1046
working tree: Working tree format 3
963
branch: Branch format 5
966
1053
In the working tree:
979
1066
first revision: %s
980
1067
latest revision: %s
985
""" % (repo.bzrdir.root_transport.base,
986
branch1.bzrdir.root_transport.base,
987
repo._format.get_format_description(),
1071
""" % (format.get_branch_format().get_format_description(),
1072
format.repository_format.get_format_description(),
988
1073
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
1075
self.assertEqual('', err)
995
1077
# Show info about repository with revisions
996
out, err = self.runbzr('info repo')
1078
out, err = self.run_bzr('info -v repo')
997
1079
self.assertEqualDiff(
999
shared repository: %s
1080
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1082
shared repository: repo
1002
1085
control: Meta directory format 1
1005
1091
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,
1095
""" % (format.repository_format.get_format_description(),
1017
1098
self.assertEqual('', err)
1019
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1021
1100
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())
1101
format = controldir.format_registry.make_bzrdir('knit')
1024
1102
transport = self.get_transport()
1026
1104
# Create shared repository with working trees
1027
repo = self.make_repository('repo', shared=True)
1105
repo = self.make_repository('repo', shared=True, format=format)
1028
1106
repo.set_make_working_trees(True)
1029
out, err = self.runbzr('info repo')
1107
out, err = self.run_bzr('info -v repo')
1030
1108
self.assertEqualDiff(
1032
shared repository: %s
1109
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1111
shared repository: repo
1035
1114
control: Meta directory format 1
1038
1120
Create working tree for new branches inside the repository.
1043
""" % (repo.bzrdir.root_transport.base,
1044
repo._format.get_format_description(),
1124
""" % (format.repository_format.get_format_description(),
1046
1126
self.assertEqual('', err)
1074
1158
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,
1163
""" % (format.get_branch_format().get_format_description(),
1164
format.repository_format.get_format_description(),
1166
self.assertEqual('', err)
1168
def test_info_repository_hook(self):
1169
format = controldir.format_registry.make_bzrdir('knit')
1170
def repo_info(repo, stats, outf):
1171
outf.write("more info\n")
1172
info.hooks.install_named_hook('repository', repo_info, None)
1173
# Create shared repository with working trees
1174
repo = self.make_repository('repo', shared=True, format=format)
1175
out, err = self.run_bzr('info -v repo')
1176
self.assertEqualDiff(
1177
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1179
shared repository: repo
1182
control: Meta directory format 1
1188
Create working tree for new branches inside the repository.
1193
""" % (format.repository_format.get_format_description(),
1195
self.assertEqual('', err)
1197
def test_info_unshared_repository_with_colocated_branches(self):
1198
format = controldir.format_registry.make_bzrdir('development-colo')
1199
transport = self.get_transport()
1201
# Create unshared repository
1202
repo = self.make_repository('repo', shared=False, format=format)
1203
repo.set_make_working_trees(True)
1204
repo.bzrdir.create_branch(name='foo')
1205
out, err = self.run_bzr('info repo')
1206
self.assertEqualDiff(
1207
"""Unshared repository with trees and colocated branches (format: development-colo)
1211
self.assertEqual('', err)
1213
def assertCheckoutStatusOutput(self,
1088
1214
command_string, lco_tree, shared_repo=None,
1089
1215
repo_branch=None,
1090
1216
tree_locked=False,
1091
1217
branch_locked=False, repo_locked=False,
1093
light_checkout=True):
1094
"""Check the output of info in a light checkout tree.
1219
light_checkout=True,
1220
checkout_root=None):
1221
"""Check the output of info in a checkout.
1096
1223
This is not quite a mirror of the info code: rather than using the
1097
1224
tree being examined to predict output, it uses a bunch of flags which
1098
1225
allow us, the test writers, to document what *should* be present in
1099
1226
the output. Removing this separation would remove the value of the
1102
1229
:param path: the path to the light checkout.
1103
1230
:param lco_tree: the tree object for the light checkout.
1104
1231
:param shared_repo: A shared repository is in use, expect that in
1108
1235
:param tree_locked: If true, expect the tree to be locked.
1109
1236
:param branch_locked: If true, expect the branch to be locked.
1110
1237
:param repo_locked: If true, expect the repository to be locked.
1111
:param verbose: If true, expect verbose output
1238
Note that the lco_tree.branch.repository is inspected, and if is not
1239
actually locked then this parameter is overridden. This is because
1240
pack repositories do not have any public API for obtaining an
1241
exclusive repository wide lock.
1242
:param verbose: verbosity level: 2 or higher to show committers
1113
out, err = self.runbzr('info %s' % command_string)
1244
def friendly_location(url):
1245
path = urlutils.unescape_for_display(url, 'ascii')
1247
return osutils.relpath(osutils.getcwd(), path)
1248
except errors.PathNotChild:
1252
# We expect this to fail because of locking errors.
1253
# (A write-locked file cannot be read-locked
1254
# in the different process -- either on win32 or on linux).
1255
# This should be removed when the locking errors are fixed.
1256
self.expectFailure('OS locks are exclusive '
1257
'for different processes (Bug #174055)',
1258
self.run_bzr_subprocess,
1259
'info ' + command_string)
1260
out, err = self.run_bzr('info %s' % command_string)
1262
(True, True): 'Lightweight checkout',
1263
(True, False): 'Repository checkout',
1264
(False, True): 'Lightweight checkout',
1265
(False, False): 'Checkout',
1266
}[(shared_repo is not None, light_checkout)]
1267
format = {True: self._repo_strings,
1268
False: 'unnamed'}[light_checkout]
1270
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1114
1271
if repo_locked or branch_locked or tree_locked:
1115
1272
def locked_message(a_bool):
1128
1285
locked_message(repo_locked)))
1130
1287
expected_lock_output = ''
1131
1290
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)
1291
tree_data = (" light checkout root: %s\n" %
1292
friendly_location(lco_tree.bzrdir.root_transport.base))
1294
if lco_tree.branch.get_bound_location() is not None:
1295
tree_data += ("%s checkout root: %s\n" % (extra_space,
1296
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1137
1297
if shared_repo is not None:
1138
1298
branch_data = (
1139
" shared repository: %s\n"
1140
" repository branch: branch\n" %
1141
shared_repo.bzrdir.root_transport.base)
1299
" checkout of branch: %s\n"
1300
" shared repository: %s\n" %
1301
(friendly_location(repo_branch.bzrdir.root_transport.base),
1302
friendly_location(shared_repo.bzrdir.root_transport.base)))
1142
1303
elif repo_branch is not None:
1143
1304
branch_data = (
1144
" checkout of branch: %s\n" %
1145
repo_branch.bzrdir.root_transport.base)
1305
"%s checkout of branch: %s\n" %
1307
friendly_location(repo_branch.bzrdir.root_transport.base)))
1147
branch_data = (" checkout of branch: %s\n" %
1309
branch_data = (" checkout of branch: %s\n" %
1148
1310
lco_tree.branch.bzrdir.root_transport.base)
1151
1313
verbose_info = ' 0 committers\n'
1153
1315
verbose_info = ''
1155
1317
self.assertEqualDiff(
1160
1322
control: Meta directory format 1
1161
1323
working tree: %s
1162
branch: Branch format 5
1165
1330
In the working tree:
1191
1358
transport = self.get_transport()
1192
1359
# Create shared repository with a branch
1193
1360
repo = self.make_repository('repo', shared=True,
1194
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1361
format=bzrdir.BzrDirMetaFormat1())
1195
1362
repo.set_make_working_trees(False)
1196
1363
repo.bzrdir.root_transport.mkdir('branch')
1197
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1198
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1364
repo_branch = controldir.ControlDir.create_branch_convenience(
1365
'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1199
1366
# Do a heavy checkout
1200
1367
transport.mkdir('tree')
1201
1368
transport.mkdir('tree/checkout')
1202
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1203
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1369
co_branch = controldir.ControlDir.create_branch_convenience(
1370
'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1204
1371
co_branch.bind(repo_branch)
1205
1372
# Do a light checkout of the heavy one
1206
1373
transport.mkdir('tree/lightcheckout')
1207
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1208
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1374
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1375
lco_dir.set_branch_reference(co_branch)
1209
1376
lco_dir.create_workingtree()
1210
1377
lco_tree = lco_dir.open_workingtree()
1216
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1383
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1384
repo_branch=repo_branch,
1385
verbose=True, light_checkout=True)
1218
1387
lco_tree.branch.repository.lock_write()
1220
self.assertCheckoutStatusOutput('tree/lightcheckout',
1389
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1390
lco_tree, repo_branch=repo_branch,
1391
repo_locked=True, verbose=True, light_checkout=True)
1224
1393
lco_tree.branch.repository.unlock()
1226
1395
lco_tree.branch.lock_write()
1228
self.assertCheckoutStatusOutput('tree/lightcheckout',
1397
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1230
1399
branch_locked=True,
1401
repo_branch=repo_branch,
1233
1404
lco_tree.branch.unlock()
1235
1406
lco_tree.lock_write()
1237
self.assertCheckoutStatusOutput('tree/lightcheckout',
1408
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1409
lco_tree, repo_branch=repo_branch,
1239
1410
tree_locked=True,
1240
1411
branch_locked=True,
1243
1415
lco_tree.unlock()
1245
1417
lco_tree.lock_write()
1246
1418
lco_tree.branch.repository.unlock()
1248
self.assertCheckoutStatusOutput('tree/lightcheckout',
1420
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1421
lco_tree, repo_branch=repo_branch,
1250
1422
tree_locked=True,
1253
1426
lco_tree.branch.repository.lock_write()
1254
1427
lco_tree.unlock()
1279
1454
lco_tree.branch.lock_write()
1280
1455
lco_tree.branch.repository.unlock()
1282
self.assertCheckoutStatusOutput('tree/lightcheckout',
1457
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1458
lco_tree, repo_branch=repo_branch,
1286
1462
lco_tree.branch.repository.lock_write()
1287
1463
lco_tree.branch.unlock()
1289
def test_info_locking_oslocks(self):
1290
if sys.platform == "win32":
1291
raise TestSkipped("don't use oslocks on win32 in unix manner")
1293
tree = self.make_branch_and_tree('branch',
1294
format=bzrlib.bzrdir.BzrDirFormat6())
1296
# Test all permutations of locking the working tree, branch and repository
1297
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1298
# implemented by raising NotImplementedError and get_physical_lock_status()
1299
# always returns false. This makes bzr info hide the lock status. (Olaf)
1303
out, err = self.runbzr('info branch')
1304
self.assertEqualDiff(
1309
control: All-in-one format 6
1310
working tree: Working tree format 2
1311
branch: Branch format 4
1314
In the working tree:
1322
0 versioned subdirectories
1330
""" % (tree.bzrdir.root_transport.base,
1331
tree.branch.repository._format.get_format_description(),
1333
self.assertEqual('', err)
1336
out, err = self.runbzr('info branch')
1337
self.assertEqualDiff(
1342
control: All-in-one format 6
1343
working tree: Working tree format 2
1344
branch: Branch format 4
1347
In the working tree:
1355
0 versioned subdirectories
1363
""" % (tree.bzrdir.root_transport.base,
1364
tree.branch.repository._format.get_format_description(),
1366
self.assertEqual('', err)
1465
if sys.platform == 'win32':
1466
self.knownFailure('Win32 cannot run "bzr info"'
1467
' when the tree is locked.')
1469
def test_info_stacked(self):
1470
# We have a mainline
1471
trunk_tree = self.make_branch_and_tree('mainline',
1473
trunk_tree.commit('mainline')
1474
# and a branch from it which is stacked
1475
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1476
out, err = self.run_bzr('info newbranch')
1478
"""Standalone tree (format: 1.6)
1480
branch root: newbranch
1483
parent branch: mainline
1484
stacked on: mainline
1486
self.assertEqual("", err)
1488
def test_info_revinfo_optional(self):
1489
tree = self.make_branch_and_tree('.')
1490
def last_revision_info(self):
1491
raise errors.UnsupportedOperation(last_revision_info, self)
1493
branch.Branch, "last_revision_info", last_revision_info)
1494
out, err = self.run_bzr('info -v .')
1496
"""Standalone tree (format: 2a)
1501
control: Meta directory format 1
1502
working tree: Working tree format 6
1503
branch: Branch format 7
1504
repository: Repository format 2a - rich roots, group compression and chk inventories
1509
In the working tree:
1517
0 versioned subdirectories
1519
self.assertEqual("", err)
1521
def test_info_shows_colocated_branches(self):
1522
bzrdir = self.make_branch('.', format='development-colo').bzrdir
1523
bzrdir.create_branch(name="colo1")
1524
bzrdir.create_branch(name="colo2")
1525
bzrdir.create_branch(name="colo3")
1526
out, err = self.run_bzr('info -v .')
1527
self.assertEqualDiff(
1528
"""Standalone branch (format: development-colo)
1533
control: Meta directory format 1 with support for colocated branches
1534
branch: Branch format 7
1535
repository: Repository format 2a - rich roots, group compression and chk inventories
1546
self.assertEqual("", err)
1549
class TestSmartServerInfo(tests.TestCaseWithTransport):
1551
def test_simple_branch_info(self):
1552
self.setup_smart_server_with_call_log()
1553
t = self.make_branch_and_tree('branch')
1554
self.build_tree_contents([('branch/foo', 'thecontents')])
1557
self.reset_smart_call_log()
1558
out, err = self.run_bzr(['info', self.get_url('branch')])
1559
# This figure represent the amount of work to perform this use case. It
1560
# is entirely ok to reduce this number if a test fails due to rpc_count
1561
# being too low. If rpc_count increases, more network roundtrips have
1562
# become necessary for this use case. Please do not adjust this number
1563
# upwards without agreement from bzr's network support maintainers.
1564
self.assertLength(10, self.hpss_calls)
1565
self.assertLength(1, self.hpss_connections)
1566
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
1568
def test_verbose_branch_info(self):
1569
self.setup_smart_server_with_call_log()
1570
t = self.make_branch_and_tree('branch')
1571
self.build_tree_contents([('branch/foo', 'thecontents')])
1574
self.reset_smart_call_log()
1575
out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
1576
# This figure represent the amount of work to perform this use case. It
1577
# is entirely ok to reduce this number if a test fails due to rpc_count
1578
# being too low. If rpc_count increases, more network roundtrips have
1579
# become necessary for this use case. Please do not adjust this number
1580
# upwards without agreement from bzr's network support maintainers.
1581
self.assertLength(14, self.hpss_calls)
1582
self.assertLength(1, self.hpss_connections)
1583
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)