~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_info.py

  • Committer: Aaron Bentley
  • Date: 2006-06-21 14:28:21 UTC
  • mfrom: (1802 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1803.
  • Revision ID: abentley@panoramicfeedback.com-20060621142821-6c1170e2d9029f76
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
"""Tests for the info command of bzr."""
20
20
 
 
21
import sys
21
22
 
22
23
import bzrlib
23
 
 
24
 
 
25
24
from bzrlib.osutils import format_date
26
25
from bzrlib.tests import TestSkipped
27
26
from bzrlib.tests.blackbox import ExternalBase
29
28
 
30
29
class TestInfo(ExternalBase):
31
30
 
 
31
    def test_info_non_existing(self):
 
32
        if sys.platform == "win32":
 
33
            location = "C:/i/do/not/exist/"
 
34
        else:
 
35
            location = "/i/do/not/exist/"
 
36
        out, err = self.runbzr('info '+location, retcode=3)
 
37
        self.assertEqual(out, '')
 
38
        self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
 
39
 
32
40
    def test_info_standalone(self):
33
41
        transport = self.get_transport()
34
42
 
43
51
        out, err = self.runbzr('info standalone')
44
52
        self.assertEqualDiff(
45
53
"""Location:
46
 
         branch root: %s
 
54
  branch root: %s
47
55
 
48
56
Format:
49
57
       control: All-in-one format 6
79
87
        out, err = self.runbzr('info branch --verbose')
80
88
        self.assertEqualDiff(
81
89
"""Location:
82
 
         branch root: %s
83
 
       parent branch: %s
84
 
      push to branch: %s
 
90
  branch root: %s
 
91
 
 
92
Related branches:
 
93
      parent branch: %s
 
94
  publish to branch: %s
85
95
 
86
96
Format:
87
97
       control: All-in-one format 6
108
118
 
109
119
Revision store:
110
120
         1 revision
111
 
         0 KiB
112
 
""" % (branch2.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
113
 
       branch1.bzrdir.root_transport.base,
114
 
       datestring_first, datestring_first), out)
 
121
         %d KiB
 
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,
 
130
       ), out)
115
131
        self.assertEqual('', err)
116
132
 
117
133
        # Branch and bind to standalone, needs upgrade to metadir
118
134
        # (creates backup as unknown)
119
 
        # XXX: I can't get this to work through API
120
 
        self.runbzr('branch standalone bound')
121
 
        #branch3 = branch1.bzrdir.sprout('bound').open_branch()
122
 
        self.runbzr('upgrade --format=metadir bound')
123
 
        #bzrlib.upgrade.upgrade('bound', 'metadir')
 
135
        branch1.bzrdir.sprout('bound')
 
136
        bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
124
137
        branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
125
138
        branch3.bind(branch1)
 
139
        bound_tree = branch3.bzrdir.open_workingtree()
126
140
        out, err = self.runbzr('info bound')
127
141
        self.assertEqualDiff(
128
142
"""Location:
129
 
         branch root: %s
130
 
     bound to branch: %s
131
 
       parent branch: %s
 
143
       checkout root: %s
 
144
  checkout of branch: %s
 
145
 
 
146
Related branches:
 
147
  parent branch: %s
132
148
 
133
149
Format:
134
150
       control: Meta directory format 1
135
 
  working tree: Working tree format 3
 
151
  working tree: %s
136
152
        branch: Branch format 5
137
153
    repository: %s
138
154
 
155
171
Revision store:
156
172
         1 revision
157
173
         %d KiB
158
 
""" % (branch3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
159
 
       branch1.bzrdir.root_transport.base,
 
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(),      
160
178
       branch3.repository._format.get_format_description(),
161
179
       datestring_first, datestring_first,
162
180
       # poking at _revision_store isn't all that clean, but neither is
176
194
        out, err = self.runbzr('info checkout --verbose')
177
195
        self.assertEqualDiff(
178
196
"""Location:
179
 
         branch root: %s
180
 
     bound to branch: %s
 
197
       checkout root: %s
 
198
  checkout of branch: %s
181
199
 
182
200
Format:
183
201
       control: Meta directory format 1
205
223
Revision store:
206
224
         1 revision
207
225
         %d KiB
208
 
""" % (branch4.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
 
226
""" % (branch4.bzrdir.root_transport.base,
 
227
       branch1.bzrdir.root_transport.base,
209
228
       branch4.repository._format.get_format_description(),
210
229
       datestring_first, datestring_first,
211
230
       # poking at _revision_store isn't all that clean, but neither is
228
247
        out, err = self.runbzr('info lightcheckout')
229
248
        self.assertEqualDiff(
230
249
"""Location:
231
 
       checkout root: %s
 
250
 light checkout root: %s
232
251
  checkout of branch: %s
233
252
 
234
253
Format:
256
275
Revision store:
257
276
         1 revision
258
277
         0 KiB
259
 
""" % (tree5.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
260
 
       datestring_first, datestring_first), out)
 
278
""" % (tree5.bzrdir.root_transport.base,
 
279
       branch1.bzrdir.root_transport.base,
 
280
       datestring_first, datestring_first,
 
281
       ), out)
261
282
        self.assertEqual('', err)
262
283
 
263
284
        # Update initial standalone branch
271
292
        out, err = self.runbzr('info branch')
272
293
        self.assertEqualDiff(
273
294
"""Location:
274
 
         branch root: %s
275
 
       parent branch: %s
276
 
      push to branch: %s
 
295
  branch root: %s
 
296
 
 
297
Related branches:
 
298
      parent branch: %s
 
299
  publish to branch: %s
277
300
 
278
301
Format:
279
302
       control: All-in-one format 6
300
323
Revision store:
301
324
         1 revision
302
325
         0 KiB
303
 
""" % (branch2.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
304
 
       branch1.bzrdir.root_transport.base,
305
 
       datestring_first, datestring_first), out)
 
326
""" % (branch2.bzrdir.root_transport.base,
 
327
       branch1.bzrdir.root_transport.base,
 
328
       branch1.bzrdir.root_transport.base,
 
329
       datestring_first, datestring_first,
 
330
       ), out)
306
331
        self.assertEqual('', err)
307
332
 
308
333
        # Out of date bound branch
309
334
        out, err = self.runbzr('info bound')
310
335
        self.assertEqualDiff(
311
336
"""Location:
312
 
         branch root: %s
313
 
     bound to branch: %s
314
 
       parent branch: %s
 
337
       checkout root: %s
 
338
  checkout of branch: %s
 
339
 
 
340
Related branches:
 
341
  parent branch: %s
315
342
 
316
343
Format:
317
344
       control: Meta directory format 1
340
367
Revision store:
341
368
         1 revision
342
369
         %d KiB
343
 
""" % (branch3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
 
370
""" % (branch3.bzrdir.root_transport.base,
 
371
       branch1.bzrdir.root_transport.base,
344
372
       branch1.bzrdir.root_transport.base,
345
373
       branch3.repository._format.get_format_description(),
346
374
       datestring_first, datestring_first,
355
383
        out, err = self.runbzr('info checkout')
356
384
        self.assertEqualDiff(
357
385
"""Location:
358
 
         branch root: %s
359
 
     bound to branch: %s
 
386
       checkout root: %s
 
387
  checkout of branch: %s
360
388
 
361
389
Format:
362
390
       control: Meta directory format 1
385
413
Revision store:
386
414
         1 revision
387
415
         %d KiB
388
 
""" % (branch4.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
 
416
""" % (branch4.bzrdir.root_transport.base,
 
417
       branch1.bzrdir.root_transport.base,
389
418
       branch4.repository._format.get_format_description(),
390
419
       datestring_first, datestring_first,
391
420
       # poking at _revision_store isn't all that clean, but neither is
399
428
        out, err = self.runbzr('info lightcheckout --verbose')
400
429
        self.assertEqualDiff(
401
430
"""Location:
402
 
       checkout root: %s
 
431
 light checkout root: %s
403
432
  checkout of branch: %s
404
433
 
405
434
Format:
430
459
Revision store:
431
460
         2 revisions
432
461
         0 KiB
433
 
""" % (tree5.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
434
 
       datestring_first, datestring_last), out)
 
462
""" % (tree5.bzrdir.root_transport.base,
 
463
       branch1.bzrdir.root_transport.base,
 
464
       datestring_first, datestring_last,
 
465
       ), out)
 
466
        self.assertEqual('', err)
 
467
 
 
468
    def test_info_standalone_no_tree(self):
 
469
        # create standalone branch without a working tree
 
470
        branch = self.make_branch('branch')
 
471
        repo = branch.repository
 
472
        out, err = self.runbzr('info branch')
 
473
        self.assertEqualDiff(
 
474
"""Location:
 
475
  branch root: %s
 
476
 
 
477
Format:
 
478
       control: Meta directory format 1
 
479
        branch: Branch format 5
 
480
    repository: %s
 
481
 
 
482
Branch history:
 
483
         0 revisions
 
484
 
 
485
Revision store:
 
486
         0 revisions
 
487
         0 KiB
 
488
""" % (branch.bzrdir.root_transport.base,
 
489
       repo._format.get_format_description(),
 
490
       ), out)
435
491
        self.assertEqual('', err)
436
492
 
437
493
    def test_info_shared_repository(self):
445
501
        out, err = self.runbzr('info repo')
446
502
        self.assertEqualDiff(
447
503
"""Location:
448
 
   shared repository: %s
 
504
  shared repository: %s
449
505
 
450
506
Format:
451
507
       control: Meta directory format 1
454
510
Revision store:
455
511
         0 revisions
456
512
         0 KiB
457
 
""" % (repo.bzrdir.root_transport.base, repo._format.get_format_description()),
458
 
            out)
 
513
""" % (repo.bzrdir.root_transport.base,
 
514
       repo._format.get_format_description(),
 
515
       ), out)
459
516
        self.assertEqual('', err)
460
517
 
461
518
        # Create branch inside shared repository
464
521
        out, err = self.runbzr('info repo/branch')
465
522
        self.assertEqualDiff(
466
523
"""Location:
467
 
         branch root: %s
468
 
   shared repository: %s
 
524
  shared repository: %s
 
525
  repository branch: branch
469
526
 
470
527
Format:
471
528
       control: Meta directory format 1
478
535
Revision store:
479
536
         0 revisions
480
537
         0 KiB
481
 
""" % (branch1.bzrdir.root_transport.base,
482
 
       repo.bzrdir.root_transport.base,
 
538
""" % (repo.bzrdir.root_transport.base,
483
539
       repo._format.get_format_description(),
484
540
       ), out)
485
541
        self.assertEqual('', err)
492
548
        dir2.create_workingtree()
493
549
        tree2 = dir2.open_workingtree()
494
550
        branch2 = tree2.branch
495
 
        out, err = self.runbzr('info tree/lightcheckout')
496
 
        self.assertEqualDiff(
497
 
"""Location:
498
 
       checkout root: %s
499
 
  checkout of branch: %s
500
 
   shared repository: %s
501
 
 
502
 
Format:
503
 
       control: Meta directory format 1
504
 
  working tree: Working tree format 3
505
 
        branch: Branch format 5
506
 
    repository: %s
507
 
 
508
 
In the working tree:
509
 
         0 unchanged
510
 
         0 modified
511
 
         0 added
512
 
         0 removed
513
 
         0 renamed
514
 
         0 unknown
515
 
         0 ignored
516
 
         0 versioned subdirectories
517
 
 
518
 
Branch history:
519
 
         0 revisions
520
 
 
521
 
Revision store:
522
 
         0 revisions
523
 
         0 KiB
524
 
""" % (tree2.bzrdir.root_transport.base,
525
 
       branch1.bzrdir.root_transport.base,
526
 
       repo.bzrdir.root_transport.base,
527
 
       repo._format.get_format_description(),
528
 
       ), out)
529
 
        self.assertEqual('', err)
 
551
        self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
530
552
 
531
553
        # Create normal checkout
532
554
        branch3 = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout')
533
555
        branch3.bind(branch1)
534
556
        tree3 = branch3.bzrdir.open_workingtree()
535
557
        tree3.update()
536
 
        out, err = self.runbzr('info tree/checkout --verbose')
537
 
        self.assertEqualDiff(
538
 
"""Location:
539
 
         branch root: %s
540
 
     bound to branch: %s
541
 
 
542
 
Format:
543
 
       control: Meta directory format 1
544
 
  working tree: Working tree format 3
545
 
        branch: Branch format 5
546
 
    repository: %s
547
 
 
548
 
In the working tree:
549
 
         0 unchanged
550
 
         0 modified
551
 
         0 added
552
 
         0 removed
553
 
         0 renamed
554
 
         0 unknown
555
 
         0 ignored
556
 
         0 versioned subdirectories
557
 
 
558
 
Branch history:
559
 
         0 revisions
560
 
         0 committers
561
 
 
562
 
Revision store:
563
 
         0 revisions
564
 
         0 KiB
565
 
""" % (branch3.bzrdir.root_transport.base,
566
 
       branch1.bzrdir.root_transport.base,
567
 
       repo._format.get_format_description(),
568
 
       ), out)
569
 
        self.assertEqual('', err)
570
 
 
 
558
        self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
 
559
            verbose=True,
 
560
            light_checkout=False, repo_branch=branch1)
571
561
        # Update lightweight checkout
572
562
        self.build_tree(['tree/lightcheckout/a'])
573
563
        tree2.add('a')
577
567
        out, err = self.runbzr('info tree/lightcheckout --verbose')
578
568
        self.assertEqualDiff(
579
569
"""Location:
580
 
       checkout root: %s
581
 
  checkout of branch: %s
 
570
 light checkout root: %s
582
571
   shared repository: %s
 
572
   repository branch: branch
583
573
 
584
574
Format:
585
575
       control: Meta directory format 1
608
598
         1 revision
609
599
         %d KiB
610
600
""" % (tree2.bzrdir.root_transport.base,
611
 
       branch1.bzrdir.root_transport.base,
612
601
       repo.bzrdir.root_transport.base,
613
602
       repo._format.get_format_description(),
614
603
       datestring_first, datestring_first,
622
611
        out, err = self.runbzr('info tree/checkout')
623
612
        self.assertEqualDiff(
624
613
"""Location:
625
 
         branch root: %s
626
 
     bound to branch: %s
 
614
       checkout root: %s
 
615
  checkout of branch: %s
627
616
 
628
617
Format:
629
618
       control: Meta directory format 1
662
651
        out, err = self.runbzr('info tree/checkout --verbose')
663
652
        self.assertEqualDiff(
664
653
"""Location:
665
 
         branch root: %s
666
 
     bound to branch: %s
 
654
       checkout root: %s
 
655
  checkout of branch: %s
667
656
 
668
657
Format:
669
658
       control: Meta directory format 1
707
696
        out, err = self.runbzr('info tree/lightcheckout --verbose')
708
697
        self.assertEqualDiff(
709
698
"""Location:
710
 
       checkout root: %s
711
 
  checkout of branch: %s
 
699
 light checkout root: %s
712
700
   shared repository: %s
 
701
   repository branch: branch
713
702
 
714
703
Format:
715
704
       control: Meta directory format 1
740
729
         2 revisions
741
730
         %d KiB
742
731
""" % (tree2.bzrdir.root_transport.base,
743
 
       branch1.bzrdir.root_transport.base,
744
732
       repo.bzrdir.root_transport.base,
745
733
       repo._format.get_format_description(),
746
734
       datestring_first, datestring_last,
754
742
        out, err = self.runbzr('info repo/branch --verbose')
755
743
        self.assertEqualDiff(
756
744
"""Location:
757
 
         branch root: %s
758
 
   shared repository: %s
 
745
  shared repository: %s
 
746
  repository branch: branch
759
747
 
760
748
Format:
761
749
       control: Meta directory format 1
772
760
Revision store:
773
761
         2 revisions
774
762
         %d KiB
775
 
""" % (branch1.bzrdir.root_transport.base,
776
 
       repo.bzrdir.root_transport.base,
 
763
""" % (repo.bzrdir.root_transport.base,
777
764
       repo._format.get_format_description(),
778
765
       datestring_first, datestring_last,
779
766
       # poking at _revision_store isn't all that clean, but neither is
786
773
        out, err = self.runbzr('info repo')
787
774
        self.assertEqualDiff(
788
775
"""Location:
789
 
   shared repository: %s
 
776
  shared repository: %s
790
777
 
791
778
Format:
792
779
       control: Meta directory format 1
800
787
       # poking at _revision_store isn't all that clean, but neither is
801
788
       # having the ui test dependent on the exact overhead of a given store.
802
789
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
803
 
       ),
804
 
       out)
 
790
       ), out)
805
791
        self.assertEqual('', err)
806
792
 
807
793
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
817
803
        out, err = self.runbzr('info repo')
818
804
        self.assertEqualDiff(
819
805
"""Location:
820
 
   shared repository: %s
 
806
  shared repository: %s
821
807
 
822
808
Format:
823
809
       control: Meta directory format 1
842
828
        out, err = self.runbzr('info repo/branch1 --verbose')
843
829
        self.assertEqualDiff(
844
830
"""Location:
845
 
         branch root: %s
846
 
   shared repository: %s
 
831
    shared repository: %s
 
832
  repository checkout: branch1
847
833
 
848
834
Format:
849
835
       control: Meta directory format 1
868
854
Revision store:
869
855
         0 revisions
870
856
         0 KiB
871
 
""" % (branch1.bzrdir.root_transport.base,
872
 
       repo.bzrdir.root_transport.base,
 
857
""" % (repo.bzrdir.root_transport.base,
873
858
       repo._format.get_format_description(),
874
859
       ), out)
875
860
        self.assertEqual('', err)
884
869
        out, err = self.runbzr('info repo/branch1')
885
870
        self.assertEqualDiff(
886
871
"""Location:
887
 
         branch root: %s
888
 
   shared repository: %s
 
872
    shared repository: %s
 
873
  repository checkout: branch1
889
874
 
890
875
Format:
891
876
       control: Meta directory format 1
912
897
Revision store:
913
898
         1 revision
914
899
         %d KiB
915
 
""" % (branch1.bzrdir.root_transport.base, repo.bzrdir.root_transport.base,
 
900
""" % (repo.bzrdir.root_transport.base,
916
901
       repo._format.get_format_description(),
917
902
       datestring_first, datestring_first,
918
903
       # poking at _revision_store isn't all that clean, but neither is
925
910
        out, err = self.runbzr('info repo/branch2 --verbose')
926
911
        self.assertEqualDiff(
927
912
"""Location:
928
 
         branch root: %s
929
 
   shared repository: %s
930
 
       parent branch: %s
 
913
    shared repository: %s
 
914
  repository checkout: branch2
 
915
 
 
916
Related branches:
 
917
  parent branch: %s
931
918
 
932
919
Format:
933
920
       control: Meta directory format 1
952
939
Revision store:
953
940
         1 revision
954
941
         %d KiB
955
 
""" % (branch2.bzrdir.root_transport.base, repo.bzrdir.root_transport.base,
 
942
""" % (repo.bzrdir.root_transport.base,
956
943
       branch1.bzrdir.root_transport.base,
957
944
       repo._format.get_format_description(),
958
945
       # poking at _revision_store isn't all that clean, but neither is
967
954
        out, err = self.runbzr('info repo/branch2')
968
955
        self.assertEqualDiff(
969
956
"""Location:
970
 
         branch root: %s
971
 
   shared repository: %s
972
 
       parent branch: %s
 
957
    shared repository: %s
 
958
  repository checkout: branch2
 
959
 
 
960
Related branches:
 
961
  parent branch: %s
973
962
 
974
963
Format:
975
964
       control: Meta directory format 1
996
985
Revision store:
997
986
         1 revision
998
987
         %d KiB
999
 
""" % (branch2.bzrdir.root_transport.base,
1000
 
       repo.bzrdir.root_transport.base,
 
988
""" % (repo.bzrdir.root_transport.base,
1001
989
       branch1.bzrdir.root_transport.base,
1002
990
       repo._format.get_format_description(),
1003
991
       datestring_first, datestring_first,
1011
999
        out, err = self.runbzr('info repo')
1012
1000
        self.assertEqualDiff(
1013
1001
"""Location:
1014
 
   shared repository: %s
 
1002
  shared repository: %s
1015
1003
 
1016
1004
Format:
1017
1005
       control: Meta directory format 1
1032
1020
        self.assertEqual('', err)
1033
1021
 
1034
1022
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
 
1023
    
 
1024
    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())
 
1027
        transport = self.get_transport()
 
1028
 
 
1029
        # Create shared repository with working trees
 
1030
        repo = self.make_repository('repo', shared=True)
 
1031
        repo.set_make_working_trees(True)
 
1032
        out, err = self.runbzr('info repo')
 
1033
        self.assertEqualDiff(
 
1034
"""Location:
 
1035
  shared repository: %s
 
1036
 
 
1037
Format:
 
1038
       control: Meta directory format 1
 
1039
    repository: %s
 
1040
 
 
1041
Create working tree for new branches inside the repository.
 
1042
 
 
1043
Revision store:
 
1044
         0 revisions
 
1045
         0 KiB
 
1046
""" % (repo.bzrdir.root_transport.base,
 
1047
       repo._format.get_format_description(),
 
1048
       ), out)
 
1049
        self.assertEqual('', err)
 
1050
 
 
1051
        # Create branch in root of repository
 
1052
        control = repo.bzrdir
 
1053
        branch = control.create_branch()
 
1054
        control.create_workingtree()
 
1055
        out, err = self.runbzr('info repo')
 
1056
        self.assertEqualDiff(
 
1057
"""Location:
 
1058
    shared repository: %s
 
1059
  repository checkout: .
 
1060
 
 
1061
Format:
 
1062
       control: Meta directory format 1
 
1063
  working tree: Working tree format 3
 
1064
        branch: Branch format 5
 
1065
    repository: %s
 
1066
 
 
1067
In the working tree:
 
1068
         0 unchanged
 
1069
         0 modified
 
1070
         0 added
 
1071
         0 removed
 
1072
         0 renamed
 
1073
         0 unknown
 
1074
         0 ignored
 
1075
         0 versioned subdirectories
 
1076
 
 
1077
Branch history:
 
1078
         0 revisions
 
1079
 
 
1080
Revision store:
 
1081
         0 revisions
 
1082
         0 KiB
 
1083
""" % (repo.bzrdir.root_transport.base,
 
1084
       repo._format.get_format_description(),
 
1085
       ), out)
 
1086
        self.assertEqual('', err)
 
1087
 
 
1088
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
 
1089
 
 
1090
    def assertCheckoutStatusOutput(self, 
 
1091
        command_string, lco_tree, shared_repo=None,
 
1092
        repo_branch=None,
 
1093
        tree_locked=False,
 
1094
        branch_locked=False, repo_locked=False,
 
1095
        verbose=False,
 
1096
        light_checkout=True):
 
1097
        """Check the output of info in a light checkout tree.
 
1098
 
 
1099
        This is not quite a mirror of the info code: rather than using the
 
1100
        tree being examined to predict output, it uses a bunch of flags which
 
1101
        allow us, the test writers, to document what *should* be present in
 
1102
        the output. Removing this separation would remove the value of the
 
1103
        tests.
 
1104
        
 
1105
        :param path: the path to the light checkout.
 
1106
        :param lco_tree: the tree object for the light checkout.
 
1107
        :param shared_repo: A shared repository is in use, expect that in
 
1108
            the output.
 
1109
        :param repo_branch: A branch in a shared repository for non light
 
1110
            checkouts.
 
1111
        :param tree_locked: If true, expect the tree to be locked.
 
1112
        :param branch_locked: If true, expect the branch to be locked.
 
1113
        :param repo_locked: If true, expect the repository to be locked.
 
1114
        :param verbose: If true, expect verbose output
 
1115
        """
 
1116
        out, err = self.runbzr('info %s' % command_string)
 
1117
        if repo_locked or branch_locked or tree_locked:
 
1118
            def locked_message(a_bool):
 
1119
                if a_bool:
 
1120
                    return 'locked'
 
1121
                else:
 
1122
                    return 'unlocked'
 
1123
            expected_lock_output = (
 
1124
                "\n"
 
1125
                "Lock status:\n"
 
1126
                "  working tree: %s\n"
 
1127
                "        branch: %s\n"
 
1128
                "    repository: %s\n" % (
 
1129
                    locked_message(tree_locked),
 
1130
                    locked_message(branch_locked),
 
1131
                    locked_message(repo_locked)))
 
1132
        else:
 
1133
            expected_lock_output = ''
 
1134
        if light_checkout:
 
1135
            tree_data = (" light checkout root: %s" %
 
1136
                lco_tree.bzrdir.root_transport.base)
 
1137
        else:
 
1138
            tree_data = ("       checkout root: %s" %
 
1139
                lco_tree.bzrdir.root_transport.base)
 
1140
        if shared_repo is not None:
 
1141
            branch_data = (
 
1142
                "   shared repository: %s\n"
 
1143
                "   repository branch: branch\n" %
 
1144
                shared_repo.bzrdir.root_transport.base)
 
1145
        elif repo_branch is not None:
 
1146
            branch_data = (
 
1147
                "  checkout of branch: %s\n" % 
 
1148
                repo_branch.bzrdir.root_transport.base)
 
1149
        else:
 
1150
            branch_data = ("  checkout of branch: %s\n" % 
 
1151
                lco_tree.branch.bzrdir.root_transport.base)
 
1152
        
 
1153
        if verbose:
 
1154
            verbose_info = '         0 committers\n'
 
1155
        else:
 
1156
            verbose_info = ''
 
1157
            
 
1158
        self.assertEqualDiff(
 
1159
"""Location:
 
1160
%s
 
1161
%s
 
1162
Format:
 
1163
       control: Meta directory format 1
 
1164
  working tree: %s
 
1165
        branch: Branch format 5
 
1166
    repository: %s
 
1167
%s
 
1168
In the working tree:
 
1169
         0 unchanged
 
1170
         0 modified
 
1171
         0 added
 
1172
         0 removed
 
1173
         0 renamed
 
1174
         0 unknown
 
1175
         0 ignored
 
1176
         0 versioned subdirectories
 
1177
 
 
1178
Branch history:
 
1179
         0 revisions
 
1180
%s
 
1181
Revision store:
 
1182
         0 revisions
 
1183
         0 KiB
 
1184
""" %  (tree_data,
 
1185
        branch_data,
 
1186
        lco_tree._format.get_format_description(),
 
1187
        lco_tree.branch.repository._format.get_format_description(),
 
1188
        expected_lock_output,
 
1189
        verbose_info,
 
1190
        ), out)
 
1191
        self.assertEqual('', err)
 
1192
 
 
1193
    def test_info_locking(self):
 
1194
        transport = self.get_transport()
 
1195
        # Create shared repository with a branch
 
1196
        repo = self.make_repository('repo', shared=True,
 
1197
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1198
        repo.set_make_working_trees(False)
 
1199
        repo.bzrdir.root_transport.mkdir('branch')
 
1200
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
 
1201
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1202
        # Do a heavy checkout
 
1203
        transport.mkdir('tree')
 
1204
        transport.mkdir('tree/checkout')
 
1205
        co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
 
1206
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1207
        co_branch.bind(repo_branch)
 
1208
        # Do a light checkout of the heavy one
 
1209
        transport.mkdir('tree/lightcheckout')
 
1210
        lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
 
1211
        bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
 
1212
        lco_dir.create_workingtree()
 
1213
        lco_tree = lco_dir.open_workingtree()
 
1214
 
 
1215
        # Test all permutations of locking the working tree, branch and repository
 
1216
        # W B R
 
1217
 
 
1218
        # U U U
 
1219
        self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
 
1220
        # U U L
 
1221
        lco_tree.branch.repository.lock_write()
 
1222
        try:
 
1223
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1224
            lco_tree,
 
1225
            repo_locked=True)
 
1226
        finally:
 
1227
            lco_tree.branch.repository.unlock()
 
1228
        # U L L
 
1229
        lco_tree.branch.lock_write()
 
1230
        try:
 
1231
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1232
            lco_tree,
 
1233
            branch_locked=True,
 
1234
            repo_locked=True)
 
1235
        finally:
 
1236
            lco_tree.branch.unlock()
 
1237
        # L L L
 
1238
        lco_tree.lock_write()
 
1239
        try:
 
1240
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1241
            lco_tree,
 
1242
            tree_locked=True,
 
1243
            branch_locked=True,
 
1244
            repo_locked=True)
 
1245
        finally:
 
1246
            lco_tree.unlock()
 
1247
        # L L U
 
1248
        lco_tree.lock_write()
 
1249
        lco_tree.branch.repository.unlock()
 
1250
        try:
 
1251
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1252
            lco_tree,
 
1253
            tree_locked=True,
 
1254
            branch_locked=True)
 
1255
        finally:
 
1256
            lco_tree.branch.repository.lock_write()
 
1257
            lco_tree.unlock()
 
1258
        # L U U
 
1259
        lco_tree.lock_write()
 
1260
        lco_tree.branch.unlock()
 
1261
        try:
 
1262
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1263
            lco_tree,
 
1264
            tree_locked=True)
 
1265
        finally:
 
1266
            lco_tree.branch.lock_write()
 
1267
            lco_tree.unlock()
 
1268
        # L U L
 
1269
        lco_tree.lock_write()
 
1270
        lco_tree.branch.unlock()
 
1271
        lco_tree.branch.repository.lock_write()
 
1272
        try:
 
1273
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1274
            lco_tree,
 
1275
            tree_locked=True,
 
1276
            repo_locked=True)
 
1277
        finally:
 
1278
            lco_tree.branch.repository.unlock()
 
1279
            lco_tree.branch.lock_write()
 
1280
            lco_tree.unlock()
 
1281
        # U L U
 
1282
        lco_tree.branch.lock_write()
 
1283
        lco_tree.branch.repository.unlock()
 
1284
        try:
 
1285
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1286
            lco_tree,
 
1287
            branch_locked=True)
 
1288
        finally:
 
1289
            lco_tree.branch.repository.lock_write()
 
1290
            lco_tree.branch.unlock()
 
1291
 
 
1292
    def test_info_locking_oslocks(self):
 
1293
        if sys.platform == "win32":
 
1294
            raise TestSkipped("don't use oslocks on win32 in unix manner")
 
1295
 
 
1296
        tree = self.make_branch_and_tree('branch',
 
1297
                                         format=bzrlib.bzrdir.BzrDirFormat6())
 
1298
 
 
1299
        # Test all permutations of locking the working tree, branch and repository
 
1300
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
 
1301
        # implemented by raising NotImplementedError and get_physical_lock_status()
 
1302
        # always returns false. This makes bzr info hide the lock status.  (Olaf)
 
1303
        # W B R
 
1304
 
 
1305
        # U U U
 
1306
        out, err = self.runbzr('info branch')
 
1307
        self.assertEqualDiff(
 
1308
"""Location:
 
1309
  branch root: %s
 
1310
 
 
1311
Format:
 
1312
       control: All-in-one format 6
 
1313
  working tree: Working tree format 2
 
1314
        branch: Branch format 4
 
1315
    repository: %s
 
1316
 
 
1317
In the working tree:
 
1318
         0 unchanged
 
1319
         0 modified
 
1320
         0 added
 
1321
         0 removed
 
1322
         0 renamed
 
1323
         0 unknown
 
1324
         0 ignored
 
1325
         0 versioned subdirectories
 
1326
 
 
1327
Branch history:
 
1328
         0 revisions
 
1329
 
 
1330
Revision store:
 
1331
         0 revisions
 
1332
         0 KiB
 
1333
""" % (tree.bzrdir.root_transport.base,
 
1334
       tree.branch.repository._format.get_format_description(),
 
1335
       ), out)
 
1336
        self.assertEqual('', err)
 
1337
        # L L L
 
1338
        tree.lock_write()
 
1339
        out, err = self.runbzr('info branch')
 
1340
        self.assertEqualDiff(
 
1341
"""Location:
 
1342
  branch root: %s
 
1343
 
 
1344
Format:
 
1345
       control: All-in-one format 6
 
1346
  working tree: Working tree format 2
 
1347
        branch: Branch format 4
 
1348
    repository: %s
 
1349
 
 
1350
In the working tree:
 
1351
         0 unchanged
 
1352
         0 modified
 
1353
         0 added
 
1354
         0 removed
 
1355
         0 renamed
 
1356
         0 unknown
 
1357
         0 ignored
 
1358
         0 versioned subdirectories
 
1359
 
 
1360
Branch history:
 
1361
         0 revisions
 
1362
 
 
1363
Revision store:
 
1364
         0 revisions
 
1365
         0 KiB
 
1366
""" % (tree.bzrdir.root_transport.base,
 
1367
       tree.branch.repository._format.get_format_description(),
 
1368
       ), out)
 
1369
        self.assertEqual('', err)
 
1370
        tree.unlock()