1
# Copyright (C) 2006, 2007 Canonical Ltd
1
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
36
40
location = "C:/i/do/not/exist/"
38
42
location = "/i/do/not/exist/"
39
out, err = self.runbzr('info '+location, retcode=3)
43
out, err = self.run_bzr('info '+location, retcode=3)
40
44
self.assertEqual(out, '')
41
self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
45
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
43
47
def test_info_standalone(self):
44
48
transport = self.get_transport()
48
52
self.build_tree(['standalone/a'])
50
54
branch1 = tree1.branch
51
out, err = self.runbzr('info standalone')
56
out, err = self.run_bzr('info standalone')
58
"""Standalone tree (format: weave)
60
branch root: standalone
62
self.assertEqual('', err)
64
out, err = self.run_bzr('info standalone -v')
66
"""Standalone tree (format: weave)
68
branch root: standalone
57
71
control: All-in-one format 6
84
98
# Branch standalone with push location
85
99
branch2 = branch1.bzrdir.sprout('branch').open_branch()
86
100
branch2.set_push_location(branch1.bzrdir.root_transport.base)
87
out, err = self.runbzr('info branch --verbose')
102
out, err = self.run_bzr('info branch')
103
self.assertEqualDiff(
104
"""Standalone tree (format: weave)
109
push branch: standalone
110
parent branch: standalone
112
self.assertEqual('', err)
114
out, err = self.run_bzr('info branch --verbose')
115
self.assertEqualDiff(
116
"""Standalone tree (format: weave)
121
push branch: standalone
122
parent branch: standalone
97
125
control: All-in-one format 6
116
144
first revision: %s
117
145
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,
149
""" % (datestring_first, datestring_first,
131
151
self.assertEqual('', err)
134
154
# (creates backup as unknown)
135
155
branch1.bzrdir.sprout('bound')
136
156
knit1_format = bzrdir.format_registry.make_bzrdir('knit')
137
bzrlib.upgrade.upgrade('bound', knit1_format)
138
branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
157
upgrade.upgrade('bound', knit1_format)
158
branch3 = bzrdir.BzrDir.open('bound').open_branch()
139
159
branch3.bind(branch1)
140
160
bound_tree = branch3.bzrdir.open_workingtree()
141
out, err = self.runbzr('info bound')
161
out, err = self.run_bzr('info -v bound')
142
162
self.assertEqualDiff(
145
checkout of branch: %s
163
"""Checkout (format: knit)
166
checkout of branch: standalone
147
168
Related branches:
169
parent branch: standalone
151
172
control: Meta directory format 1
169
191
first revision: %s
170
192
latest revision: %s
175
""" % (branch3.bzrdir.root_transport.base,
176
branch1.bzrdir.root_transport.base,
177
branch1.bzrdir.root_transport.base,
178
bound_tree._format.get_format_description(),
196
""" % (bound_tree._format.get_format_description(),
179
197
branch3._format.get_format_description(),
180
198
branch3.repository._format.get_format_description(),
181
199
datestring_first, datestring_first,
182
# poking at _revision_store isn't all that clean, but neither is
183
# having the ui test dependent on the exact overhead of a given store.
184
branch3.repository._revision_store.total_size(
185
branch3.repository.get_transaction())[1] / 1024,
187
201
self.assertEqual('', err)
189
203
# Checkout standalone (same as above, but does not have parent set)
190
branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
204
branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
191
205
format=knit1_format)
192
206
branch4.bind(branch1)
193
207
branch4.bzrdir.open_workingtree().update()
194
out, err = self.runbzr('info checkout --verbose')
208
out, err = self.run_bzr('info checkout --verbose')
195
209
self.assertEqualDiff(
198
checkout of branch: %s
210
"""Checkout (format: knit)
212
checkout root: checkout
213
checkout of branch: standalone
201
216
control: Meta directory format 1
220
235
first revision: %s
221
236
latest revision: %s
226
""" % (branch4.bzrdir.root_transport.base,
227
branch1.bzrdir.root_transport.base,
228
branch4.repository._format.get_format_description(),
240
""" % (branch4.repository._format.get_format_description(),
229
241
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
243
self.assertEqual('', err)
237
245
# Lightweight checkout (same as above, different branch and repository)
238
246
tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
239
247
branch5 = tree5.branch
240
out, err = self.runbzr('info lightcheckout')
248
out, err = self.run_bzr('info -v lightcheckout')
241
249
self.assertEqualDiff(
243
light checkout root: %s
244
checkout of branch: %s
250
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root \
251
or 1.9 or 1.9-rich-root \
252
or dirstate or dirstate-tags or \
253
pack-0.92 or rich-root or rich-root-pack)
255
light checkout root: lightcheckout
256
checkout of branch: standalone
247
259
control: Meta directory format 1
248
working tree: Working tree format 3
260
working tree: Working tree format 4
249
261
branch: Branch format 4
250
262
repository: Weave repository format 6
265
278
first revision: %s
266
279
latest revision: %s
271
""" % (tree5.bzrdir.root_transport.base,
272
branch1.bzrdir.root_transport.base,
273
datestring_first, datestring_first,
283
""" % (datestring_first, datestring_first,), out)
275
284
self.assertEqual('', err)
277
286
# Update initial standalone branch
282
291
datestring_last = format_date(rev.timestamp, rev.timezone)
284
293
# Out of date branched standalone branch will not be detected
285
out, err = self.runbzr('info branch')
294
out, err = self.run_bzr('info -v branch')
286
295
self.assertEqualDiff(
296
"""Standalone tree (format: weave)
290
300
Related branches:
292
publish to branch: %s
301
push branch: standalone
302
parent branch: standalone
295
305
control: All-in-one format 6
313
324
first revision: %s
314
325
latest revision: %s
319
""" % (branch2.bzrdir.root_transport.base,
320
branch1.bzrdir.root_transport.base,
321
branch1.bzrdir.root_transport.base,
322
datestring_first, datestring_first,
329
""" % (datestring_first, datestring_first,
324
331
self.assertEqual('', err)
326
333
# Out of date bound branch
327
out, err = self.runbzr('info bound')
334
out, err = self.run_bzr('info -v bound')
328
335
self.assertEqualDiff(
331
checkout of branch: %s
336
"""Checkout (format: knit)
339
checkout of branch: standalone
333
341
Related branches:
342
parent branch: standalone
337
345
control: Meta directory format 1
357
366
first revision: %s
358
367
latest revision: %s
363
""" % (branch3.bzrdir.root_transport.base,
364
branch1.bzrdir.root_transport.base,
365
branch1.bzrdir.root_transport.base,
366
branch3.repository._format.get_format_description(),
371
""" % (branch3.repository._format.get_format_description(),
367
372
datestring_first, datestring_first,
368
# poking at _revision_store isn't all that clean, but neither is
369
# having the ui test dependent on the exact overhead of a given store.
370
branch3.repository._revision_store.total_size(
371
branch3.repository.get_transaction())[1] / 1024,
373
374
self.assertEqual('', err)
375
376
# Out of date checkout
376
out, err = self.runbzr('info checkout')
377
out, err = self.run_bzr('info -v checkout')
377
378
self.assertEqualDiff(
380
checkout of branch: %s
379
"""Checkout (format: knit)
381
checkout root: checkout
382
checkout of branch: standalone
383
385
control: Meta directory format 1
403
406
first revision: %s
404
407
latest revision: %s
409
""" % (branch4.bzrdir.root_transport.base,
410
branch1.bzrdir.root_transport.base,
411
branch4.repository._format.get_format_description(),
411
""" % (branch4.repository._format.get_format_description(),
412
412
datestring_first, datestring_first,
413
# poking at _revision_store isn't all that clean, but neither is
414
# having the ui test dependent on the exact overhead of a given store.
415
branch4.repository._revision_store.total_size(
416
branch4.repository.get_transaction())[1] / 1024,
418
414
self.assertEqual('', err)
420
416
# Out of date lightweight checkout
421
out, err = self.runbzr('info lightcheckout --verbose')
417
out, err = self.run_bzr('info lightcheckout --verbose')
422
418
self.assertEqualDiff(
424
light checkout root: %s
425
checkout of branch: %s
419
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
420
1.9 or 1.9-rich-root or \
421
dirstate or dirstate-tags or \
422
pack-0.92 or rich-root or rich-root-pack)
424
light checkout root: lightcheckout
425
checkout of branch: standalone
428
428
control: Meta directory format 1
429
working tree: Working tree format 3
429
working tree: Working tree format 4
430
430
branch: Branch format 4
431
431
repository: Weave repository format 6
449
449
first revision: %s
450
450
latest revision: %s
455
""" % (tree5.bzrdir.root_transport.base,
456
branch1.bzrdir.root_transport.base,
457
datestring_first, datestring_last,
454
""" % (datestring_first, datestring_last,), out)
459
455
self.assertEqual('', err)
461
457
def test_info_standalone_no_tree(self):
463
459
format = bzrdir.format_registry.make_bzrdir('default')
464
460
branch = self.make_branch('branch')
465
461
repo = branch.repository
466
out, err = self.runbzr('info branch')
462
out, err = self.run_bzr('info branch -v')
467
463
self.assertEqualDiff(
464
"""Standalone branch (format: %s)
472
469
control: Meta directory format 1
482
""" % (branch.bzrdir.root_transport.base,
479
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
483
480
format.get_branch_format().get_format_description(),
484
481
format.repository_format.get_format_description(),
492
489
# Create shared repository
493
490
repo = self.make_repository('repo', shared=True, format=format)
494
491
repo.set_make_working_trees(False)
495
out, err = self.runbzr('info repo')
492
out, err = self.run_bzr('info -v repo')
496
493
self.assertEqualDiff(
494
"""Shared repository (format: dirstate or dirstate-tags or knit)
498
496
shared repository: %s
501
499
control: Meta directory format 1
507
""" % (repo.bzrdir.root_transport.base,
508
format.repository_format.get_format_description(),
504
""" % ('repo', format.repository_format.get_format_description(),
510
506
self.assertEqual('', err)
513
509
repo.bzrdir.root_transport.mkdir('branch')
514
510
branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
516
out, err = self.runbzr('info repo/branch')
512
out, err = self.run_bzr('info -v repo/branch')
517
513
self.assertEqualDiff(
519
shared repository: %s
520
repository branch: branch
514
"""Repository branch (format: dirstate or knit)
516
shared repository: repo
517
repository branch: repo/branch
523
520
control: Meta directory format 1
533
""" % (repo.bzrdir.root_transport.base,
534
format.get_branch_format().get_format_description(),
530
""" % (format.get_branch_format().get_format_description(),
535
531
format.repository_format.get_format_description(),
537
533
self.assertEqual('', err)
542
538
tree2 = branch1.create_checkout('tree/lightcheckout',
543
539
lightweight=True)
544
540
branch2 = tree2.branch
545
self.assertCheckoutStatusOutput('tree/lightcheckout', tree2,
541
self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
542
shared_repo=repo, repo_branch=branch1, verbose=True)
548
544
# Create normal checkout
549
545
tree3 = branch1.create_checkout('tree/checkout')
556
552
tree2.commit('commit one')
557
553
rev = repo.get_revision(branch2.revision_history()[0])
558
554
datestring_first = format_date(rev.timestamp, rev.timezone)
559
out, err = self.runbzr('info tree/lightcheckout --verbose')
555
out, err = self.run_bzr('info tree/lightcheckout --verbose')
560
556
self.assertEqualDiff(
562
light checkout root: %s
563
shared repository: %s
564
repository branch: branch
557
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
558
1.9 or 1.9-rich-root or \
559
dirstate or dirstate-tags or \
560
pack-0.92 or rich-root or rich-root-pack)
562
light checkout root: tree/lightcheckout
563
checkout of branch: repo/branch
564
shared repository: repo
567
567
control: Meta directory format 1
568
working tree: Working tree format 3
568
working tree: Working tree format 4
586
586
first revision: %s
587
587
latest revision: %s
592
""" % (tree2.bzrdir.root_transport.base,
593
repo.bzrdir.root_transport.base,
594
format.get_branch_format().get_format_description(),
591
""" % (format.get_branch_format().get_format_description(),
595
592
format.repository_format.get_format_description(),
596
593
datestring_first, datestring_first,
597
# poking at _revision_store isn't all that clean, but neither is
598
# having the ui test dependent on the exact overhead of a given store.
599
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
601
595
self.assertEqual('', err)
603
597
# Out of date checkout
604
out, err = self.runbzr('info tree/checkout')
598
out, err = self.run_bzr('info -v tree/checkout')
605
599
self.assertEqualDiff(
608
checkout of branch: %s
600
"""Checkout (format: dirstate)
602
checkout root: tree/checkout
603
checkout of branch: repo/branch
611
606
control: Meta directory format 1
612
working tree: Working tree format 3
607
working tree: Working tree format 4
634
""" % (tree3.bzrdir.root_transport.base,
635
branch1.bzrdir.root_transport.base,
636
format.get_branch_format().get_format_description(),
629
""" % (format.get_branch_format().get_format_description(),
637
630
format.repository_format.get_format_description(),
639
632
self.assertEqual('', err)
643
636
self.build_tree(['tree/checkout/b'])
645
out, err = self.runbzr('info tree/checkout --verbose')
638
out, err = self.run_bzr('info tree/checkout --verbose')
646
639
self.assertEqualDiff(
649
checkout of branch: %s
640
"""Checkout (format: dirstate)
642
checkout root: tree/checkout
643
checkout of branch: repo/branch
652
646
control: Meta directory format 1
653
working tree: Working tree format 3
647
working tree: Working tree format 4
671
665
first revision: %s
672
666
latest revision: %s
677
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
678
format.get_branch_format().get_format_description(),
670
""" % (format.get_branch_format().get_format_description(),
679
671
format.repository_format.get_format_description(),
680
672
datestring_first, datestring_first,
681
# poking at _revision_store isn't all that clean, but neither is
682
# having the ui test dependent on the exact overhead of a given store.
683
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
685
674
self.assertEqual('', err)
686
675
tree3.commit('commit two')
688
677
# Out of date lightweight checkout
689
678
rev = repo.get_revision(branch1.revision_history()[-1])
690
679
datestring_last = format_date(rev.timestamp, rev.timezone)
691
out, err = self.runbzr('info tree/lightcheckout --verbose')
680
out, err = self.run_bzr('info tree/lightcheckout --verbose')
692
681
self.assertEqualDiff(
694
light checkout root: %s
695
shared repository: %s
696
repository branch: branch
682
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
683
1.9 or 1.9-rich-root or \
684
dirstate or dirstate-tags or \
685
pack-0.92 or rich-root or rich-root-pack)
687
light checkout root: tree/lightcheckout
688
checkout of branch: repo/branch
689
shared repository: repo
699
692
control: Meta directory format 1
700
working tree: Working tree format 3
693
working tree: Working tree format 4
720
713
first revision: %s
721
714
latest revision: %s
726
""" % (tree2.bzrdir.root_transport.base,
727
repo.bzrdir.root_transport.base,
728
format.get_branch_format().get_format_description(),
718
""" % (format.get_branch_format().get_format_description(),
729
719
format.repository_format.get_format_description(),
730
720
datestring_first, datestring_last,
731
# poking at _revision_store isn't all that clean, but neither is
732
# having the ui test dependent on the exact overhead of a given store.
733
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
735
722
self.assertEqual('', err)
737
724
# Show info about shared branch
738
out, err = self.runbzr('info repo/branch --verbose')
725
out, err = self.run_bzr('info repo/branch --verbose')
739
726
self.assertEqualDiff(
741
shared repository: %s
742
repository branch: branch
727
"""Repository branch (format: dirstate or knit)
729
shared repository: repo
730
repository branch: repo/branch
745
733
control: Meta directory format 1
753
741
first revision: %s
754
742
latest revision: %s
759
""" % (repo.bzrdir.root_transport.base,
760
format.get_branch_format().get_format_description(),
746
""" % (format.get_branch_format().get_format_description(),
761
747
format.repository_format.get_format_description(),
762
748
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
750
self.assertEqual('', err)
769
752
# Show info about repository with revisions
770
out, err = self.runbzr('info repo')
753
out, err = self.run_bzr('info -v repo')
771
754
self.assertEqualDiff(
773
shared repository: %s
755
"""Shared repository (format: dirstate or dirstate-tags or knit)
757
shared repository: repo
776
760
control: Meta directory format 1
782
""" % (repo.bzrdir.root_transport.base,
783
format.repository_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,
765
""" % (format.repository_format.get_format_description(),
788
767
self.assertEqual('', err)
794
773
# Create shared repository with working trees
795
774
repo = self.make_repository('repo', shared=True, format=format)
796
775
repo.set_make_working_trees(True)
797
out, err = self.runbzr('info repo')
776
out, err = self.run_bzr('info -v repo')
798
777
self.assertEqualDiff(
800
shared repository: %s
778
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
780
shared repository: repo
803
783
control: Meta directory format 1
806
786
Create working tree for new branches inside the repository.
811
""" % (repo.bzrdir.root_transport.base,
812
format.repository_format.get_format_description(),
790
""" % (format.repository_format.get_format_description(),
814
792
self.assertEqual('', err)
820
798
branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
822
800
# Empty first branch
823
out, err = self.runbzr('info repo/branch1 --verbose')
801
out, err = self.run_bzr('info repo/branch1 --verbose')
824
802
self.assertEqualDiff(
826
shared repository: %s
827
repository checkout: branch1
803
"""Repository tree (format: knit)
805
shared repository: repo
806
repository branch: repo/branch1
830
809
control: Meta directory format 1
852
""" % (repo.bzrdir.root_transport.base,
853
format.get_branch_format().get_format_description(),
830
""" % (format.get_branch_format().get_format_description(),
854
831
format.repository_format.get_format_description(),
856
833
self.assertEqual('', err)
862
839
tree1.commit('commit one')
863
840
rev = repo.get_revision(branch1.revision_history()[0])
864
841
datestring_first = format_date(rev.timestamp, rev.timezone)
865
out, err = self.runbzr('info repo/branch1')
842
out, err = self.run_bzr('info -v repo/branch1')
866
843
self.assertEqualDiff(
868
shared repository: %s
869
repository checkout: branch1
844
"""Repository tree (format: knit)
846
shared repository: repo
847
repository branch: repo/branch1
872
850
control: Meta directory format 1
890
869
first revision: %s
891
870
latest revision: %s
896
""" % (repo.bzrdir.root_transport.base,
897
format.get_branch_format().get_format_description(),
874
""" % (format.get_branch_format().get_format_description(),
898
875
format.repository_format.get_format_description(),
899
876
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
878
self.assertEqual('', err)
906
880
# Out of date second branch
907
out, err = self.runbzr('info repo/branch2 --verbose')
881
out, err = self.run_bzr('info repo/branch2 --verbose')
908
882
self.assertEqualDiff(
910
shared repository: %s
911
repository checkout: branch2
883
"""Repository tree (format: knit)
885
shared repository: repo
886
repository branch: repo/branch2
913
888
Related branches:
889
parent branch: repo/branch1
917
892
control: Meta directory format 1
939
""" % (repo.bzrdir.root_transport.base,
940
branch1.bzrdir.root_transport.base,
941
format.get_branch_format().get_format_description(),
913
""" % (format.get_branch_format().get_format_description(),
942
914
format.repository_format.get_format_description(),
943
# poking at _revision_store isn't all that clean, but neither is
944
# having the ui test dependent on the exact overhead of a given store.
945
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
947
916
self.assertEqual('', err)
949
918
# Update second branch
950
919
tree2 = branch2.bzrdir.open_workingtree()
951
920
tree2.pull(branch1)
952
out, err = self.runbzr('info repo/branch2')
921
out, err = self.run_bzr('info -v repo/branch2')
953
922
self.assertEqualDiff(
955
shared repository: %s
956
repository checkout: branch2
923
"""Repository tree (format: knit)
925
shared repository: repo
926
repository branch: repo/branch2
958
928
Related branches:
929
parent branch: repo/branch1
962
932
control: Meta directory format 1
980
951
first revision: %s
981
952
latest revision: %s
986
""" % (repo.bzrdir.root_transport.base,
987
branch1.bzrdir.root_transport.base,
988
format.get_branch_format().get_format_description(),
956
""" % (format.get_branch_format().get_format_description(),
989
957
format.repository_format.get_format_description(),
990
958
datestring_first, datestring_first,
991
# poking at _revision_store isn't all that clean, but neither is
992
# having the ui test dependent on the exact overhead of a given store.
993
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
995
960
self.assertEqual('', err)
997
962
# Show info about repository with revisions
998
out, err = self.runbzr('info repo')
963
out, err = self.run_bzr('info -v repo')
999
964
self.assertEqualDiff(
1001
shared repository: %s
965
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
967
shared repository: repo
1004
970
control: Meta directory format 1
1007
973
Create working tree for new branches inside the repository.
1012
""" % (repo.bzrdir.root_transport.base,
1013
format.repository_format.get_format_description(),
1014
# poking at _revision_store isn't all that clean, but neither is
1015
# having the ui test dependent on the exact overhead of a given store.
1016
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
977
""" % (format.repository_format.get_format_description(),
1019
980
self.assertEqual('', err)
1025
986
# Create shared repository with working trees
1026
987
repo = self.make_repository('repo', shared=True, format=format)
1027
988
repo.set_make_working_trees(True)
1028
out, err = self.runbzr('info repo')
989
out, err = self.run_bzr('info -v repo')
1029
990
self.assertEqualDiff(
1031
shared repository: %s
991
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
993
shared repository: repo
1034
996
control: Meta directory format 1
1037
999
Create working tree for new branches inside the repository.
1042
""" % (repo.bzrdir.root_transport.base,
1043
format.repository_format.get_format_description(),
1003
""" % (format.repository_format.get_format_description(),
1045
1005
self.assertEqual('', err)
1048
1008
control = repo.bzrdir
1049
1009
branch = control.create_branch()
1050
1010
control.create_workingtree()
1051
out, err = self.runbzr('info repo')
1011
out, err = self.run_bzr('info -v repo')
1052
1012
self.assertEqualDiff(
1054
shared repository: %s
1055
repository checkout: .
1013
"""Repository tree (format: knit)
1015
shared repository: repo
1016
repository branch: repo
1058
1019
control: Meta directory format 1
1073
1034
Branch history:
1079
""" % (repo.bzrdir.root_transport.base,
1080
format.get_branch_format().get_format_description(),
1040
""" % (format.get_branch_format().get_format_description(),
1081
1041
format.repository_format.get_format_description(),
1083
1043
self.assertEqual('', err)
1085
def assertCheckoutStatusOutput(self,
1045
def assertCheckoutStatusOutput(self,
1086
1046
command_string, lco_tree, shared_repo=None,
1087
1047
repo_branch=None,
1088
1048
tree_locked=False,
1089
1049
branch_locked=False, repo_locked=False,
1091
light_checkout=True):
1092
"""Check the output of info in a light checkout tree.
1051
light_checkout=True,
1052
checkout_root=None):
1053
"""Check the output of info in a checkout.
1094
1055
This is not quite a mirror of the info code: rather than using the
1095
1056
tree being examined to predict output, it uses a bunch of flags which
1106
1067
:param tree_locked: If true, expect the tree to be locked.
1107
1068
:param branch_locked: If true, expect the branch to be locked.
1108
1069
:param repo_locked: If true, expect the repository to be locked.
1070
Note that the lco_tree.branch.repository is inspected, and if is not
1071
actually locked then this parameter is overridden. This is because
1072
pack repositories do not have any public API for obtaining an
1073
exclusive repository wide lock.
1109
1074
:param verbose: If true, expect verbose output
1111
out, err = self.runbzr('info %s' % command_string)
1076
def friendly_location(url):
1077
path = urlutils.unescape_for_display(url, 'ascii')
1079
return osutils.relpath(osutils.getcwd(), path)
1080
except errors.PathNotChild:
1084
# We expect this to fail because of locking errors.
1085
# (A write-locked file cannot be read-locked
1086
# in the different process -- either on win32 or on linux).
1087
# This should be removed when the locking errors are fixed.
1088
self.expectFailure('OS locks are exclusive '
1089
'for different processes (Bug #174055)',
1090
self.run_bzr_subprocess,
1091
'info ' + command_string)
1092
out, err = self.run_bzr('info %s' % command_string)
1094
(True, True): 'Lightweight checkout',
1095
(True, False): 'Repository checkout',
1096
(False, True): 'Lightweight checkout',
1097
(False, False): 'Checkout',
1098
}[(shared_repo is not None, light_checkout)]
1099
format = {True: '1.6 or 1.6.1-rich-root'
1100
' or 1.9 or 1.9-rich-root'
1101
' or dirstate or dirstate-tags or pack-0.92'
1102
' or rich-root or rich-root-pack',
1103
False: 'dirstate'}[light_checkout]
1105
repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1112
1106
if repo_locked or branch_locked or tree_locked:
1113
1107
def locked_message(a_bool):
1126
1120
locked_message(repo_locked)))
1128
1122
expected_lock_output = ''
1129
1125
if light_checkout:
1130
tree_data = (" light checkout root: %s" %
1131
lco_tree.bzrdir.root_transport.base)
1133
tree_data = (" checkout root: %s" %
1134
lco_tree.bzrdir.root_transport.base)
1126
tree_data = (" light checkout root: %s\n" %
1127
friendly_location(lco_tree.bzrdir.root_transport.base))
1129
if lco_tree.branch.get_bound_location() is not None:
1130
tree_data += ("%s checkout root: %s\n" % (extra_space,
1131
friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1135
1132
if shared_repo is not None:
1136
1133
branch_data = (
1137
" shared repository: %s\n"
1138
" repository branch: branch\n" %
1139
shared_repo.bzrdir.root_transport.base)
1134
" checkout of branch: %s\n"
1135
" shared repository: %s\n" %
1136
(friendly_location(repo_branch.bzrdir.root_transport.base),
1137
friendly_location(shared_repo.bzrdir.root_transport.base)))
1140
1138
elif repo_branch is not None:
1141
1139
branch_data = (
1142
" checkout of branch: %s\n" %
1143
repo_branch.bzrdir.root_transport.base)
1140
"%s checkout of branch: %s\n" %
1142
friendly_location(repo_branch.bzrdir.root_transport.base)))
1145
branch_data = (" checkout of branch: %s\n" %
1144
branch_data = (" checkout of branch: %s\n" %
1146
1145
lco_tree.branch.bzrdir.root_transport.base)
1190
1190
transport = self.get_transport()
1191
1191
# Create shared repository with a branch
1192
1192
repo = self.make_repository('repo', shared=True,
1193
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1193
format=bzrdir.BzrDirMetaFormat1())
1194
1194
repo.set_make_working_trees(False)
1195
1195
repo.bzrdir.root_transport.mkdir('branch')
1196
1196
repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1197
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1197
format=bzrdir.BzrDirMetaFormat1())
1198
1198
# Do a heavy checkout
1199
1199
transport.mkdir('tree')
1200
1200
transport.mkdir('tree/checkout')
1201
co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1202
format=bzrlib.bzrdir.BzrDirMetaFormat1())
1201
co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1202
format=bzrdir.BzrDirMetaFormat1())
1203
1203
co_branch.bind(repo_branch)
1204
1204
# Do a light checkout of the heavy one
1205
1205
transport.mkdir('tree/lightcheckout')
1206
lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1207
bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1206
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1207
branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1208
1208
lco_dir.create_workingtree()
1209
1209
lco_tree = lco_dir.open_workingtree()
1215
self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1215
self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1216
repo_branch=repo_branch,
1217
verbose=True, light_checkout=True)
1217
1219
lco_tree.branch.repository.lock_write()
1219
self.assertCheckoutStatusOutput('tree/lightcheckout',
1221
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1222
lco_tree, repo_branch=repo_branch,
1223
repo_locked=True, verbose=True, light_checkout=True)
1223
1225
lco_tree.branch.repository.unlock()
1225
1227
lco_tree.branch.lock_write()
1227
self.assertCheckoutStatusOutput('tree/lightcheckout',
1229
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1229
1231
branch_locked=True,
1233
repo_branch=repo_branch,
1232
1236
lco_tree.branch.unlock()
1234
1238
lco_tree.lock_write()
1236
self.assertCheckoutStatusOutput('tree/lightcheckout',
1240
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1241
lco_tree, repo_branch=repo_branch,
1238
1242
tree_locked=True,
1239
1243
branch_locked=True,
1242
1247
lco_tree.unlock()
1244
1249
lco_tree.lock_write()
1245
1250
lco_tree.branch.repository.unlock()
1247
self.assertCheckoutStatusOutput('tree/lightcheckout',
1252
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1253
lco_tree, repo_branch=repo_branch,
1249
1254
tree_locked=True,
1252
1258
lco_tree.branch.repository.lock_write()
1253
1259
lco_tree.unlock()
1255
1261
lco_tree.lock_write()
1256
1262
lco_tree.branch.unlock()
1258
self.assertCheckoutStatusOutput('tree/lightcheckout',
1264
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1265
lco_tree, repo_branch=repo_branch,
1262
1269
lco_tree.branch.lock_write()
1263
1270
lco_tree.unlock()
1266
1273
lco_tree.branch.unlock()
1267
1274
lco_tree.branch.repository.lock_write()
1269
self.assertCheckoutStatusOutput('tree/lightcheckout',
1276
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1277
lco_tree, repo_branch=repo_branch,
1271
1278
tree_locked=True,
1274
1282
lco_tree.branch.repository.unlock()
1275
1283
lco_tree.branch.lock_write()
1278
1286
lco_tree.branch.lock_write()
1279
1287
lco_tree.branch.repository.unlock()
1281
self.assertCheckoutStatusOutput('tree/lightcheckout',
1289
self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1290
lco_tree, repo_branch=repo_branch,
1285
1294
lco_tree.branch.repository.lock_write()
1286
1295
lco_tree.branch.unlock()
1297
if sys.platform == 'win32':
1298
self.knownFailure('Win32 cannot run "bzr info"'
1299
' when the tree is locked.')
1288
1301
def test_info_locking_oslocks(self):
1289
1302
if sys.platform == "win32":
1290
1303
raise TestSkipped("don't use oslocks on win32 in unix manner")
1292
1305
tree = self.make_branch_and_tree('branch',
1293
format=bzrlib.bzrdir.BzrDirFormat6())
1306
format=bzrdir.BzrDirFormat6())
1295
1308
# Test all permutations of locking the working tree, branch and repository
1296
1309
# XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1323
1337
Branch history:
1329
""" % (tree.bzrdir.root_transport.base,
1330
tree.branch.repository._format.get_format_description(),
1343
""" % ('branch', tree.branch.repository._format.get_format_description(),
1332
1345
self.assertEqual('', err)
1334
1347
tree.lock_write()
1335
out, err = self.runbzr('info branch')
1348
out, err = self.run_bzr('info -v branch')
1336
1349
self.assertEqualDiff(
1350
"""Standalone tree (format: weave)
1338
1352
branch root: %s
1356
1370
Branch history:
1362
""" % (tree.bzrdir.root_transport.base,
1363
tree.branch.repository._format.get_format_description(),
1376
""" % ('branch', tree.branch.repository._format.get_format_description(),
1365
1378
self.assertEqual('', err)
1381
def test_info_stacked(self):
1382
# We have a mainline
1383
trunk_tree = self.make_branch_and_tree('mainline',
1385
trunk_tree.commit('mainline')
1386
# and a branch from it which is stacked
1387
new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1388
out, err = self.run_bzr('info newbranch')
1390
"""Standalone tree (format: 1.6)
1392
branch root: newbranch
1395
parent branch: mainline
1396
stacked on: mainline
1398
self.assertEqual("", err)