1
# Copyright (C) 2006 by Canonical Ltd
2
# -*- coding: utf-8 -*-
1
# Copyright (C) 2006-2010 Canonical Ltd
4
3
# This program is free software; you can redistribute it and/or modify
5
4
# it under the terms of the GNU General Public License as published by
6
5
# the Free Software Foundation; either version 2 of the License, or
7
6
# (at your option) any later version.
9
8
# This program is distributed in the hope that it will be useful,
10
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
11
# GNU General Public License for more details.
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):
32
from bzrlib.transport import memory
35
class TestInfo(tests.TestCaseWithTransport):
38
super(TestInfo, self).setUp()
39
self._repo_strings = "2a"
31
41
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)
42
self.vfs_transport_factory = memory.MemoryServer
43
location = self.get_url()
44
out, err = self.run_bzr('info '+location, retcode=3)
37
45
self.assertEqual(out, '')
38
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
46
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
40
48
def test_info_standalone(self):
41
49
transport = self.get_transport()
43
51
# 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)
52
tree1 = self.make_branch_and_tree('standalone', 'weave')
48
53
self.build_tree(['standalone/a'])
50
55
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)
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
79
126
self.assertEqual('', err)
80
127
tree1.commit('commit one')
81
128
rev = branch1.repository.get_revision(branch1.revision_history()[0])
82
datestring_first = format_date(rev.timestamp, rev.timezone)
129
datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
84
131
# Branch standalone with push location
85
132
branch2 = branch1.bzrdir.sprout('branch').open_branch()
86
133
branch2.set_push_location(branch1.bzrdir.root_transport.base)
87
out, err = self.runbzr('info branch --verbose')
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
97
158
control: All-in-one format 6
116
176
first revision: %s
117
177
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,
181
""" % (datestring_first, datestring_first,
131
183
self.assertEqual('', err)
133
185
# Branch and bind to standalone, needs upgrade to metadir
134
186
# (creates backup as unknown)
135
187
branch1.bzrdir.sprout('bound')
136
bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
137
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
188
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
189
upgrade.upgrade('bound', knit1_format)
190
branch3 = bzrdir.BzrDir.open('bound').open_branch()
138
191
branch3.bind(branch1)
139
192
bound_tree = branch3.bzrdir.open_workingtree()
140
out, err = self.runbzr('info bound')
193
out, err = self.run_bzr('info -v bound')
141
194
self.assertEqualDiff(
144
checkout of branch: %s
195
"""Checkout (format: knit)
198
checkout of branch: standalone
146
200
Related branches:
201
parent branch: standalone
150
204
control: Meta directory format 1
152
branch: Branch format 5
155
209
In the working tree:
168
222
first revision: %s
169
223
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(),
227
""" % (bound_tree._format.get_format_description(),
228
branch3._format.get_format_description(),
178
229
branch3.repository._format.get_format_description(),
179
230
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
232
self.assertEqual('', err)
187
234
# 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)
235
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
192
237
branch4.bind(branch1)
193
238
branch4.bzrdir.open_workingtree().update()
194
out, err = self.runbzr('info checkout --verbose')
239
out, err = self.run_bzr('info checkout --verbose')
195
240
self.assertEqualDiff(
198
checkout of branch: %s
241
"""Checkout (format: knit)
243
checkout root: checkout
244
checkout of branch: standalone
201
247
control: Meta directory format 1
220
265
first revision: %s
221
266
latest revision: %s
226
""" % (branch4.bzrdir.root_transport.base,
227
branch1.bzrdir.root_transport.base,
228
branch4.repository._format.get_format_description(),
270
""" % (branch4.repository._format.get_format_description(),
229
271
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
273
self.assertEqual('', err)
237
275
# 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)
276
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
246
277
branch5 = tree5.branch
247
out, err = self.runbzr('info lightcheckout')
278
out, err = self.run_bzr('info -v lightcheckout')
248
279
self.assertEqualDiff(
250
light checkout root: %s
251
checkout of branch: %s
280
"""Lightweight checkout (format: %s)
282
light checkout root: lightcheckout
283
checkout of branch: standalone
254
286
control: Meta directory format 1
255
working tree: Working tree format 3
287
working tree: Working tree format 6
256
288
branch: Branch format 4
257
289
repository: Weave repository format 6
320
349
first revision: %s
321
350
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,
354
""" % (datestring_first, datestring_first,
331
356
self.assertEqual('', err)
333
358
# Out of date bound branch
334
out, err = self.runbzr('info bound')
359
out, err = self.run_bzr('info -v bound')
335
360
self.assertEqualDiff(
338
checkout of branch: %s
361
"""Checkout (format: knit)
364
checkout of branch: standalone
340
366
Related branches:
367
parent branch: standalone
344
370
control: Meta directory format 1
364
390
first revision: %s
365
391
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(),
395
""" % (branch3.repository._format.get_format_description(),
374
396
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
398
self.assertEqual('', err)
382
400
# Out of date checkout
383
out, err = self.runbzr('info checkout')
401
out, err = self.run_bzr('info -v checkout')
384
402
self.assertEqualDiff(
387
checkout of branch: %s
403
"""Checkout (format: knit)
405
checkout root: checkout
406
checkout of branch: standalone
390
409
control: Meta directory format 1
410
429
first revision: %s
411
430
latest revision: %s
416
""" % (branch4.bzrdir.root_transport.base,
417
branch1.bzrdir.root_transport.base,
418
branch4.repository._format.get_format_description(),
434
""" % (branch4.repository._format.get_format_description(),
419
435
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
437
self.assertEqual('', err)
427
439
# Out of date lightweight checkout
428
out, err = self.runbzr('info lightcheckout --verbose')
440
out, err = self.run_bzr('info lightcheckout --verbose')
429
441
self.assertEqualDiff(
431
light checkout root: %s
432
checkout of branch: %s
442
"""Lightweight checkout (format: %s)
444
light checkout root: lightcheckout
445
checkout of branch: standalone
435
448
control: Meta directory format 1
436
working tree: Working tree format 3
449
working tree: Working tree format 6
437
450
branch: Branch format 4
438
451
repository: Weave repository format 6
456
468
first revision: %s
457
469
latest revision: %s
462
""" % (tree5.bzrdir.root_transport.base,
463
branch1.bzrdir.root_transport.base,
464
datestring_first, datestring_last,
473
""" % (self._repo_strings, datestring_first, datestring_last,), out)
466
474
self.assertEqual('', err)
468
476
def test_info_standalone_no_tree(self):
469
477
# create standalone branch without a working tree
478
format = bzrdir.format_registry.make_bzrdir('default')
470
479
branch = self.make_branch('branch')
471
480
repo = branch.repository
472
out, err = self.runbzr('info branch')
481
out, err = self.run_bzr('info branch -v')
473
482
self.assertEqualDiff(
483
"""Standalone branch (format: %s)
478
488
control: Meta directory format 1
479
branch: Branch format 5
488
""" % (branch.bzrdir.root_transport.base,
489
repo._format.get_format_description(),
497
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
498
format.get_branch_format().get_format_description(),
499
format.repository_format.get_format_description(),
491
501
self.assertEqual('', err)
493
503
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())
504
format = bzrdir.format_registry.make_bzrdir('knit')
496
505
transport = self.get_transport()
498
507
# Create shared repository
499
repo = self.make_repository('repo', shared=True)
508
repo = self.make_repository('repo', shared=True, format=format)
500
509
repo.set_make_working_trees(False)
501
out, err = self.runbzr('info repo')
510
out, err = self.run_bzr('info -v repo')
502
511
self.assertEqualDiff(
512
"""Shared repository (format: dirstate or dirstate-tags or knit)
504
514
shared repository: %s
507
517
control: Meta directory format 1
513
""" % (repo.bzrdir.root_transport.base,
514
repo._format.get_format_description(),
522
""" % ('repo', format.repository_format.get_format_description(),
516
524
self.assertEqual('', err)
518
526
# Create branch inside shared repository
519
527
repo.bzrdir.root_transport.mkdir('branch')
520
branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
521
out, err = self.runbzr('info repo/branch')
528
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
530
out, err = self.run_bzr('info -v repo/branch')
522
531
self.assertEqualDiff(
524
shared repository: %s
525
repository branch: branch
532
"""Repository branch (format: dirstate or knit)
534
shared repository: repo
535
repository branch: repo/branch
528
538
control: Meta directory format 1
529
branch: Branch format 5
538
""" % (repo.bzrdir.root_transport.base,
539
repo._format.get_format_description(),
547
""" % (format.get_branch_format().get_format_description(),
548
format.repository_format.get_format_description(),
541
550
self.assertEqual('', err)
543
552
# Create lightweight checkout
544
553
transport.mkdir('tree')
545
554
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()
555
tree2 = branch1.create_checkout('tree/lightcheckout',
550
557
branch2 = tree2.branch
551
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
558
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
559
shared_repo=repo, repo_branch=branch1, verbose=True)
553
561
# Create normal checkout
554
branch3 = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout')
555
branch3.bind(branch1)
556
tree3 = branch3.bzrdir.open_workingtree()
562
tree3 = branch1.create_checkout('tree/checkout')
558
563
self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
560
565
light_checkout=False, repo_branch=branch1)
594
599
first revision: %s
595
600
latest revision: %s
600
""" % (tree2.bzrdir.root_transport.base,
601
repo.bzrdir.root_transport.base,
602
repo._format.get_format_description(),
604
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
605
format.repository_format.get_format_description(),
603
606
datestring_first, datestring_first,
604
# poking at _revision_store isn't all that clean, but neither is
605
# having the ui test dependent on the exact overhead of a given store.
606
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
608
608
self.assertEqual('', err)
610
610
# Out of date checkout
611
out, err = self.runbzr('info tree/checkout')
611
out, err = self.run_bzr('info -v tree/checkout')
612
612
self.assertEqualDiff(
615
checkout of branch: %s
613
"""Checkout (format: unnamed)
615
checkout root: tree/checkout
616
checkout of branch: repo/branch
618
619
control: Meta directory format 1
619
working tree: Working tree format 3
620
branch: Branch format 5
620
working tree: Working tree format 6
623
624
Branch is out of date: missing 1 revision.
677
676
first revision: %s
678
677
latest revision: %s
683
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
684
repo._format.get_format_description(),
681
""" % (format.get_branch_format().get_format_description(),
682
format.repository_format.get_format_description(),
685
683
datestring_first, datestring_first,
686
# poking at _revision_store isn't all that clean, but neither is
687
# having the ui test dependent on the exact overhead of a given store.
688
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
690
685
self.assertEqual('', err)
691
686
tree3.commit('commit two')
693
688
# Out of date lightweight checkout
694
689
rev = repo.get_revision(branch1.revision_history()[-1])
695
datestring_last = format_date(rev.timestamp, rev.timezone)
696
out, err = self.runbzr('info tree/lightcheckout --verbose')
690
datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
691
out, err = self.run_bzr('info tree/lightcheckout --verbose')
697
692
self.assertEqualDiff(
699
light checkout root: %s
700
shared repository: %s
701
repository branch: branch
693
"""Lightweight checkout (format: %s)
695
light checkout root: tree/lightcheckout
696
checkout of branch: repo/branch
697
shared repository: repo
704
700
control: Meta directory format 1
705
working tree: Working tree format 3
706
branch: Branch format 5
701
working tree: Working tree format 6
709
705
Working tree is out of date: missing 1 revision.
725
720
first revision: %s
726
721
latest revision: %s
731
""" % (tree2.bzrdir.root_transport.base,
732
repo.bzrdir.root_transport.base,
733
repo._format.get_format_description(),
725
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
726
format.repository_format.get_format_description(),
734
727
datestring_first, datestring_last,
735
# poking at _revision_store isn't all that clean, but neither is
736
# having the ui test dependent on the exact overhead of a given store.
737
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
739
729
self.assertEqual('', err)
741
731
# Show info about shared branch
742
out, err = self.runbzr('info repo/branch --verbose')
732
out, err = self.run_bzr('info repo/branch --verbose')
743
733
self.assertEqualDiff(
745
shared repository: %s
746
repository branch: branch
734
"""Repository branch (format: dirstate or knit)
736
shared repository: repo
737
repository branch: repo/branch
749
740
control: Meta directory format 1
750
branch: Branch format 5
757
747
first revision: %s
758
748
latest revision: %s
763
""" % (repo.bzrdir.root_transport.base,
764
repo._format.get_format_description(),
752
""" % (format.get_branch_format().get_format_description(),
753
format.repository_format.get_format_description(),
765
754
datestring_first, datestring_last,
766
# poking at _revision_store isn't all that clean, but neither is
767
# having the ui test dependent on the exact overhead of a given store.
768
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
770
756
self.assertEqual('', err)
772
758
# Show info about repository with revisions
773
out, err = self.runbzr('info repo')
759
out, err = self.run_bzr('info -v repo')
774
760
self.assertEqualDiff(
776
shared repository: %s
761
"""Shared repository (format: dirstate or dirstate-tags or knit)
763
shared repository: repo
779
766
control: Meta directory format 1
785
""" % (repo.bzrdir.root_transport.base,
786
repo._format.get_format_description(),
787
# poking at _revision_store isn't all that clean, but neither is
788
# having the ui test dependent on the exact overhead of a given store.
789
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
771
""" % (format.repository_format.get_format_description(),
791
773
self.assertEqual('', err)
793
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
795
775
def test_info_shared_repository_with_trees(self):
796
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
797
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
776
format = bzrdir.format_registry.make_bzrdir('knit')
798
777
transport = self.get_transport()
800
779
# Create shared repository with working trees
801
repo = self.make_repository('repo', shared=True)
780
repo = self.make_repository('repo', shared=True, format=format)
802
781
repo.set_make_working_trees(True)
803
out, err = self.runbzr('info repo')
782
out, err = self.run_bzr('info -v repo')
804
783
self.assertEqualDiff(
806
shared repository: %s
784
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
786
shared repository: repo
809
789
control: Meta directory format 1
812
792
Create working tree for new branches inside the repository.
817
""" % (repo.bzrdir.root_transport.base,
818
repo._format.get_format_description(),
796
""" % (format.repository_format.get_format_description(),
820
798
self.assertEqual('', err)
822
800
# Create two branches
823
801
repo.bzrdir.root_transport.mkdir('branch1')
824
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
802
branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
825
804
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
827
806
# Empty first branch
828
out, err = self.runbzr('info repo/branch1 --verbose')
807
out, err = self.run_bzr('info repo/branch1 --verbose')
829
808
self.assertEqualDiff(
831
shared repository: %s
832
repository checkout: branch1
809
"""Repository tree (format: knit)
811
shared repository: repo
812
repository branch: repo/branch1
835
815
control: Meta directory format 1
836
816
working tree: Working tree format 3
837
branch: Branch format 5
840
820
In the working tree:
894
873
first revision: %s
895
874
latest revision: %s
900
""" % (repo.bzrdir.root_transport.base,
901
repo._format.get_format_description(),
878
""" % (format.get_branch_format().get_format_description(),
879
format.repository_format.get_format_description(),
902
880
datestring_first, datestring_first,
903
# poking at _revision_store isn't all that clean, but neither is
904
# having the ui test dependent on the exact overhead of a given store.
905
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
907
882
self.assertEqual('', err)
909
884
# Out of date second branch
910
out, err = self.runbzr('info repo/branch2 --verbose')
885
out, err = self.run_bzr('info repo/branch2 --verbose')
911
886
self.assertEqualDiff(
913
shared repository: %s
914
repository checkout: branch2
887
"""Repository tree (format: knit)
889
shared repository: repo
890
repository branch: repo/branch2
916
892
Related branches:
893
parent branch: repo/branch1
920
896
control: Meta directory format 1
921
897
working tree: Working tree format 3
922
branch: Branch format 5
925
901
In the working tree:
942
""" % (repo.bzrdir.root_transport.base,
943
branch1.bzrdir.root_transport.base,
944
repo._format.get_format_description(),
945
# poking at _revision_store isn't all that clean, but neither is
946
# having the ui test dependent on the exact overhead of a given store.
947
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
916
""" % (format.get_branch_format().get_format_description(),
917
format.repository_format.get_format_description(),
949
919
self.assertEqual('', err)
951
921
# Update second branch
952
922
tree2 = branch2.bzrdir.open_workingtree()
953
923
tree2.pull(branch1)
954
out, err = self.runbzr('info repo/branch2')
924
out, err = self.run_bzr('info -v repo/branch2')
955
925
self.assertEqualDiff(
957
shared repository: %s
958
repository checkout: branch2
926
"""Repository tree (format: knit)
928
shared repository: repo
929
repository branch: repo/branch2
960
931
Related branches:
932
parent branch: repo/branch1
964
935
control: Meta directory format 1
965
936
working tree: Working tree format 3
966
branch: Branch format 5
969
940
In the working tree:
982
953
first revision: %s
983
954
latest revision: %s
988
""" % (repo.bzrdir.root_transport.base,
989
branch1.bzrdir.root_transport.base,
990
repo._format.get_format_description(),
958
""" % (format.get_branch_format().get_format_description(),
959
format.repository_format.get_format_description(),
991
960
datestring_first, datestring_first,
992
# poking at _revision_store isn't all that clean, but neither is
993
# having the ui test dependent on the exact overhead of a given store.
994
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
996
962
self.assertEqual('', err)
998
964
# Show info about repository with revisions
999
out, err = self.runbzr('info repo')
965
out, err = self.run_bzr('info -v repo')
1000
966
self.assertEqualDiff(
1002
shared repository: %s
967
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
969
shared repository: repo
1005
972
control: Meta directory format 1
1008
975
Create working tree for new branches inside the repository.
1013
""" % (repo.bzrdir.root_transport.base,
1014
repo._format.get_format_description(),
1015
# poking at _revision_store isn't all that clean, but neither is
1016
# having the ui test dependent on the exact overhead of a given store.
1017
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
979
""" % (format.repository_format.get_format_description(),
1020
982
self.assertEqual('', err)
1022
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1024
984
def test_info_shared_repository_with_tree_in_root(self):
1025
old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1026
bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
985
format = bzrdir.format_registry.make_bzrdir('knit')
1027
986
transport = self.get_transport()
1029
988
# Create shared repository with working trees
1030
repo = self.make_repository('repo', shared=True)
989
repo = self.make_repository('repo', shared=True, format=format)
1031
990
repo.set_make_working_trees(True)
1032
out, err = self.runbzr('info repo')
991
out, err = self.run_bzr('info -v repo')
1033
992
self.assertEqualDiff(
1035
shared repository: %s
993
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
995
shared repository: repo
1038
998
control: Meta directory format 1
1077
1036
Branch history:
1083
""" % (repo.bzrdir.root_transport.base,
1084
repo._format.get_format_description(),
1086
self.assertEqual('', err)
1088
bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1090
def assertCheckoutStatusOutput(self,
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,
1091
1073
command_string, lco_tree, shared_repo=None,
1092
1074
repo_branch=None,
1093
1075
tree_locked=False,
1094
1076
branch_locked=False, repo_locked=False,
1096
light_checkout=True):
1097
"""Check the output of info in a light checkout tree.
1078
light_checkout=True,
1079
checkout_root=None):
1080
"""Check the output of info in a checkout.
1099
1082
This is not quite a mirror of the info code: rather than using the
1100
1083
tree being examined to predict output, it uses a bunch of flags which
1101
1084
allow us, the test writers, to document what *should* be present in
1102
1085
the output. Removing this separation would remove the value of the
1105
1088
:param path: the path to the light checkout.
1106
1089
:param lco_tree: the tree object for the light checkout.
1107
1090
:param shared_repo: A shared repository is in use, expect that in
1111
1094
:param tree_locked: If true, expect the tree to be locked.
1112
1095
:param branch_locked: If true, expect the branch to be locked.
1113
1096
:param repo_locked: If true, expect the repository to be locked.
1114
:param verbose: If true, expect verbose output
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
1116
out, err = self.runbzr('info %s' % command_string)
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()
1117
1130
if repo_locked or branch_locked or tree_locked:
1118
1131
def locked_message(a_bool):
1131
1144
locked_message(repo_locked)))
1133
1146
expected_lock_output = ''
1134
1149
if light_checkout:
1135
tree_data = (" light checkout root: %s" %
1136
lco_tree.bzrdir.root_transport.base)
1138
tree_data = (" checkout root: %s" %
1139
lco_tree.bzrdir.root_transport.base)
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)))
1140
1156
if shared_repo is not None:
1141
1157
branch_data = (
1142
" shared repository: %s\n"
1143
" repository branch: branch\n" %
1144
shared_repo.bzrdir.root_transport.base)
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)))
1145
1162
elif repo_branch is not None:
1146
1163
branch_data = (
1147
" checkout of branch: %s\n" %
1148
repo_branch.bzrdir.root_transport.base)
1164
"%s checkout of branch: %s\n" %
1166
friendly_location(repo_branch.bzrdir.root_transport.base)))
1150
branch_data = (" checkout of branch: %s\n" %
1168
branch_data = (" checkout of branch: %s\n" %
1151
1169
lco_tree.branch.bzrdir.root_transport.base)
1154
1172
verbose_info = ' 0 committers\n'
1156
1174
verbose_info = ''
1158
1176
self.assertEqualDiff(
1163
1181
control: Meta directory format 1
1164
1182
working tree: %s
1165
branch: Branch format 5
1168
1186
In the working tree:
1194
1214
transport = self.get_transport()
1195
1215
# Create shared repository with a branch
1196
1216
repo = self.make_repository('repo', shared=True,
1197
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1217
format=bzrdir.BzrDirMetaFormat1())
1198
1218
repo.set_make_working_trees(False)
1199
1219
repo.bzrdir.root_transport.mkdir('branch')
1200
1220
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1201
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1221
format=bzrdir.BzrDirMetaFormat1())
1202
1222
# Do a heavy checkout
1203
1223
transport.mkdir('tree')
1204
1224
transport.mkdir('tree/checkout')
1205
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1206
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1225
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
format=bzrdir.BzrDirMetaFormat1())
1207
1227
co_branch.bind(repo_branch)
1208
1228
# Do a light checkout of the heavy one
1209
1229
transport.mkdir('tree/lightcheckout')
1210
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1211
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1230
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1231
branch.BranchReferenceFormat().initialize(lco_dir,
1232
target_branch=co_branch)
1212
1233
lco_dir.create_workingtree()
1213
1234
lco_tree = lco_dir.open_workingtree()
1219
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1240
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1241
repo_branch=repo_branch,
1242
verbose=True, light_checkout=True)
1221
1244
lco_tree.branch.repository.lock_write()
1223
self.assertCheckoutStatusOutput('tree/lightcheckout',
1246
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1247
lco_tree, repo_branch=repo_branch,
1248
repo_locked=True, verbose=True, light_checkout=True)
1227
1250
lco_tree.branch.repository.unlock()
1229
1252
lco_tree.branch.lock_write()
1231
self.assertCheckoutStatusOutput('tree/lightcheckout',
1254
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1233
1256
branch_locked=True,
1258
repo_branch=repo_branch,
1236
1261
lco_tree.branch.unlock()
1238
1263
lco_tree.lock_write()
1240
self.assertCheckoutStatusOutput('tree/lightcheckout',
1265
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1266
lco_tree, repo_branch=repo_branch,
1242
1267
tree_locked=True,
1243
1268
branch_locked=True,
1246
1272
lco_tree.unlock()
1248
1274
lco_tree.lock_write()
1249
1275
lco_tree.branch.repository.unlock()
1251
self.assertCheckoutStatusOutput('tree/lightcheckout',
1277
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1278
lco_tree, repo_branch=repo_branch,
1253
1279
tree_locked=True,
1256
1283
lco_tree.branch.repository.lock_write()
1257
1284
lco_tree.unlock()
1282
1311
lco_tree.branch.lock_write()
1283
1312
lco_tree.branch.repository.unlock()
1285
self.assertCheckoutStatusOutput('tree/lightcheckout',
1314
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1315
lco_tree, repo_branch=repo_branch,
1289
1319
lco_tree.branch.repository.lock_write()
1290
1320
lco_tree.branch.unlock()
1322
if sys.platform == 'win32':
1323
self.knownFailure('Win32 cannot run "bzr info"'
1324
' when the tree is locked.')
1292
1326
def test_info_locking_oslocks(self):
1293
1327
if sys.platform == "win32":
1294
raise TestSkipped("don't use oslocks on win32 in unix manner")
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()
1296
1335
tree = self.make_branch_and_tree('branch',
1297
format=bzrlib.bzrdir.BzrDirFormat6())
1336
format=bzrdir.BzrDirFormat6())
1299
1338
# Test all permutations of locking the working tree, branch and repository
1300
1339
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's