~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2010-04-08 04:34:03 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5139.
  • Revision ID: robertc@robertcollins.net-20100408043403-56z0d07vdqrx7f3t
Update bugfix for 528114 to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# 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
16
16
 
17
17
 
18
18
"""Tests for the info command of bzr."""
19
19
 
20
 
import os
21
20
import sys
22
21
 
23
 
import bzrlib
24
22
from bzrlib import (
 
23
    branch,
25
24
    bzrdir,
26
25
    errors,
27
26
    info,
28
27
    osutils,
29
 
    repository,
 
28
    tests,
 
29
    upgrade,
30
30
    urlutils,
31
31
    )
32
 
from bzrlib.osutils import format_date
33
 
from bzrlib.tests import TestSkipped
34
 
from bzrlib.tests.blackbox import ExternalBase
35
 
 
36
 
 
37
 
class TestInfo(ExternalBase):
 
32
from bzrlib.transport import memory
 
33
 
 
34
 
 
35
class TestInfo(tests.TestCaseWithTransport):
 
36
 
 
37
    def setUp(self):
 
38
        super(TestInfo, self).setUp()
 
39
        self._repo_strings = "2a"
38
40
 
39
41
    def test_info_non_existing(self):
40
 
        if sys.platform == "win32":
41
 
            location = "C:/i/do/not/exist/"
42
 
        else:
43
 
            location = "/i/do/not/exist/"
 
42
        self.vfs_transport_factory = memory.MemoryServer
 
43
        location = self.get_url()
44
44
        out, err = self.run_bzr('info '+location, retcode=3)
45
45
        self.assertEqual(out, '')
46
46
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
62
62
""", out)
63
63
        self.assertEqual('', err)
64
64
 
 
65
        # Standalone branch - verbose mode
65
66
        out, err = self.run_bzr('info standalone -v')
66
67
        self.assertEqualDiff(
67
68
"""Standalone tree (format: weave)
86
87
 
87
88
Branch history:
88
89
         0 revisions
 
90
 
 
91
Repository:
 
92
         0 revisions
 
93
""", out)
 
94
        self.assertEqual('', err)
 
95
 
 
96
        # Standalone branch - really verbose mode
 
97
        out, err = self.run_bzr('info standalone -vv')
 
98
        self.assertEqualDiff(
 
99
"""Standalone tree (format: weave)
 
100
Location:
 
101
  branch root: standalone
 
102
 
 
103
Format:
 
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
 
108
 
 
109
In the working tree:
 
110
         0 unchanged
 
111
         0 modified
 
112
         1 added
 
113
         0 removed
 
114
         0 renamed
 
115
         0 unknown
 
116
         0 ignored
 
117
         0 versioned subdirectories
 
118
 
 
119
Branch history:
 
120
         0 revisions
89
121
         0 committers
90
122
 
91
123
Repository:
92
124
         0 revisions
93
 
         0 KiB
94
125
""", out)
95
126
        self.assertEqual('', err)
96
127
        tree1.commit('commit one')
97
128
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
98
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
129
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
99
130
 
100
131
        # Branch standalone with push location
101
132
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
141
172
 
142
173
Branch history:
143
174
         1 revision
144
 
         1 committer
145
175
         0 days old
146
176
   first revision: %s
147
177
  latest revision: %s
148
178
 
149
179
Repository:
150
180
         1 revision
151
 
         %d KiB
152
181
""" % (datestring_first, datestring_first,
153
 
       # poking at _revision_store isn't all that clean, but neither is
154
 
       # having the ui test dependent on the exact overhead of a given store.
155
 
       branch2.repository._revision_store.total_size(
156
 
        branch2.repository.get_transaction())[1] / 1024,
157
182
       ), out)
158
183
        self.assertEqual('', err)
159
184
 
161
186
        # (creates backup as unknown)
162
187
        branch1.bzrdir.sprout('bound')
163
188
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
164
 
        bzrlib.upgrade.upgrade('bound', knit1_format)
165
 
        branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
 
189
        upgrade.upgrade('bound', knit1_format)
 
190
        branch3 = bzrdir.BzrDir.open('bound').open_branch()
166
191
        branch3.bind(branch1)
167
192
        bound_tree = branch3.bzrdir.open_workingtree()
168
193
        out, err = self.run_bzr('info -v bound')
187
212
         0 added
188
213
         0 removed
189
214
         0 renamed
190
 
         1 unknown
191
 
         0 ignored
 
215
         0 unknown
 
216
         1 ignored
192
217
         0 versioned subdirectories
193
218
 
194
219
Branch history:
195
220
         1 revision
196
 
         1 committer
197
221
         0 days old
198
222
   first revision: %s
199
223
  latest revision: %s
200
224
 
201
225
Repository:
202
226
         1 revision
203
 
         %d KiB
204
227
""" % (bound_tree._format.get_format_description(),
205
228
       branch3._format.get_format_description(),
206
229
       branch3.repository._format.get_format_description(),
207
230
       datestring_first, datestring_first,
208
 
       # poking at _revision_store isn't all that clean, but neither is
209
 
       # having the ui test dependent on the exact overhead of a given store.
210
 
       branch3.repository._revision_store.total_size(
211
 
        branch3.repository.get_transaction())[1] / 1024,
212
231
       ), out)
213
232
        self.assertEqual('', err)
214
233
 
215
234
        # Checkout standalone (same as above, but does not have parent set)
216
 
        branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
 
235
        branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
217
236
            format=knit1_format)
218
237
        branch4.bind(branch1)
219
238
        branch4.bzrdir.open_workingtree().update()
242
261
 
243
262
Branch history:
244
263
         1 revision
245
 
         1 committer
246
264
         0 days old
247
265
   first revision: %s
248
266
  latest revision: %s
249
267
 
250
268
Repository:
251
269
         1 revision
252
 
         %d KiB
253
270
""" % (branch4.repository._format.get_format_description(),
254
271
       datestring_first, datestring_first,
255
 
       # poking at _revision_store isn't all that clean, but neither is
256
 
       # having the ui test dependent on the exact overhead of a given store.
257
 
       branch4.repository._revision_store.total_size(
258
 
        branch4.repository.get_transaction())[1] / 1024,
259
272
       ), out)
260
273
        self.assertEqual('', err)
261
274
 
264
277
        branch5 = tree5.branch
265
278
        out, err = self.run_bzr('info -v lightcheckout')
266
279
        self.assertEqualDiff(
267
 
"""Lightweight checkout (format: dirstate or dirstate-tags or \
268
 
pack-0.92 or rich-root or rich-root-pack)
 
280
"""Lightweight checkout (format: %s)
269
281
Location:
270
282
  light checkout root: lightcheckout
271
283
   checkout of branch: standalone
272
284
 
273
285
Format:
274
286
       control: Meta directory format 1
275
 
  working tree: Working tree format 4
 
287
  working tree: Working tree format 6
276
288
        branch: Branch format 4
277
289
    repository: Weave repository format 6
278
290
 
288
300
 
289
301
Branch history:
290
302
         1 revision
291
 
         1 committer
292
303
         0 days old
293
304
   first revision: %s
294
305
  latest revision: %s
295
306
 
296
307
Repository:
297
308
         1 revision
298
 
         0 KiB
299
 
""" % (datestring_first, datestring_first,), out)
 
309
""" % (self._repo_strings, datestring_first, datestring_first,), out)
300
310
        self.assertEqual('', err)
301
311
 
302
312
        # Update initial standalone branch
304
314
        tree1.add('b')
305
315
        tree1.commit('commit two')
306
316
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
307
 
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
317
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
308
318
 
309
319
        # Out of date branched standalone branch will not be detected
310
320
        out, err = self.run_bzr('info -v branch')
335
345
 
336
346
Branch history:
337
347
         1 revision
338
 
         1 committer
339
348
         0 days old
340
349
   first revision: %s
341
350
  latest revision: %s
342
351
 
343
352
Repository:
344
353
         1 revision
345
 
         0 KiB
346
354
""" % (datestring_first, datestring_first,
347
355
       ), out)
348
356
        self.assertEqual('', err)
372
380
         0 added
373
381
         0 removed
374
382
         0 renamed
375
 
         1 unknown
376
 
         0 ignored
 
383
         0 unknown
 
384
         1 ignored
377
385
         0 versioned subdirectories
378
386
 
379
387
Branch history:
380
388
         1 revision
381
 
         1 committer
382
389
         0 days old
383
390
   first revision: %s
384
391
  latest revision: %s
385
392
 
386
393
Repository:
387
394
         1 revision
388
 
         %d KiB
389
395
""" % (branch3.repository._format.get_format_description(),
390
396
       datestring_first, datestring_first,
391
 
       # poking at _revision_store isn't all that clean, but neither is
392
 
       # having the ui test dependent on the exact overhead of a given store.
393
 
       branch3.repository._revision_store.total_size(
394
 
        branch3.repository.get_transaction())[1] / 1024,
395
397
       ), out)
396
398
        self.assertEqual('', err)
397
399
 
423
425
 
424
426
Branch history:
425
427
         1 revision
426
 
         1 committer
427
428
         0 days old
428
429
   first revision: %s
429
430
  latest revision: %s
430
431
 
431
432
Repository:
432
433
         1 revision
433
 
         %d KiB
434
434
""" % (branch4.repository._format.get_format_description(),
435
435
       datestring_first, datestring_first,
436
 
       # poking at _revision_store isn't all that clean, but neither is
437
 
       # having the ui test dependent on the exact overhead of a given store.
438
 
       branch4.repository._revision_store.total_size(
439
 
        branch4.repository.get_transaction())[1] / 1024,
440
436
       ), out)
441
437
        self.assertEqual('', err)
442
438
 
443
439
        # Out of date lightweight checkout
444
440
        out, err = self.run_bzr('info lightcheckout --verbose')
445
441
        self.assertEqualDiff(
446
 
"""Lightweight checkout (format: dirstate or dirstate-tags or \
447
 
pack-0.92 or rich-root or rich-root-pack)
 
442
"""Lightweight checkout (format: %s)
448
443
Location:
449
444
  light checkout root: lightcheckout
450
445
   checkout of branch: standalone
451
446
 
452
447
Format:
453
448
       control: Meta directory format 1
454
 
  working tree: Working tree format 4
 
449
  working tree: Working tree format 6
455
450
        branch: Branch format 4
456
451
    repository: Weave repository format 6
457
452
 
469
464
 
470
465
Branch history:
471
466
         2 revisions
472
 
         1 committer
473
467
         0 days old
474
468
   first revision: %s
475
469
  latest revision: %s
476
470
 
477
471
Repository:
478
472
         2 revisions
479
 
         0 KiB
480
 
""" % (datestring_first, datestring_last,), out)
 
473
""" % (self._repo_strings, datestring_first, datestring_last,), out)
481
474
        self.assertEqual('', err)
482
475
 
483
476
    def test_info_standalone_no_tree(self):
498
491
 
499
492
Branch history:
500
493
         0 revisions
501
 
         0 committers
502
494
 
503
495
Repository:
504
496
         0 revisions
505
 
         0 KiB
506
497
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
507
498
       format.get_branch_format().get_format_description(),
508
499
       format.repository_format.get_format_description(),
528
519
 
529
520
Repository:
530
521
         0 revisions
531
 
         0 KiB
532
522
""" % ('repo', format.repository_format.get_format_description(),
533
523
       ), out)
534
524
        self.assertEqual('', err)
551
541
 
552
542
Branch history:
553
543
         0 revisions
554
 
         0 committers
555
544
 
556
545
Repository:
557
546
         0 revisions
558
 
         0 KiB
559
547
""" % (format.get_branch_format().get_format_description(),
560
548
       format.repository_format.get_format_description(),
561
549
       ), out)
564
552
        # Create lightweight checkout
565
553
        transport.mkdir('tree')
566
554
        transport.mkdir('tree/lightcheckout')
567
 
        tree2 = branch1.create_checkout('tree/lightcheckout', 
 
555
        tree2 = branch1.create_checkout('tree/lightcheckout',
568
556
            lightweight=True)
569
557
        branch2 = tree2.branch
570
558
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
580
568
        tree2.add('a')
581
569
        tree2.commit('commit one')
582
570
        rev = repo.get_revision(branch2.revision_history()[0])
583
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
571
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
584
572
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
585
573
        self.assertEqualDiff(
586
 
"""Lightweight checkout (format: dirstate or dirstate-tags or \
587
 
pack-0.92 or rich-root or rich-root-pack)
 
574
"""Lightweight checkout (format: %s)
588
575
Location:
589
576
  light checkout root: tree/lightcheckout
590
577
   checkout of branch: repo/branch
592
579
 
593
580
Format:
594
581
       control: Meta directory format 1
595
 
  working tree: Working tree format 4
 
582
  working tree: Working tree format 6
596
583
        branch: %s
597
584
    repository: %s
598
585
 
608
595
 
609
596
Branch history:
610
597
         1 revision
611
 
         1 committer
612
598
         0 days old
613
599
   first revision: %s
614
600
  latest revision: %s
615
601
 
616
602
Repository:
617
603
         1 revision
618
 
         %d KiB
619
 
""" % (format.get_branch_format().get_format_description(),
 
604
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
620
605
       format.repository_format.get_format_description(),
621
606
       datestring_first, datestring_first,
622
 
       # poking at _revision_store isn't all that clean, but neither is
623
 
       # having the ui test dependent on the exact overhead of a given store.
624
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
625
607
       ), out)
626
608
        self.assertEqual('', err)
627
609
 
628
610
        # Out of date checkout
629
611
        out, err = self.run_bzr('info -v tree/checkout')
630
612
        self.assertEqualDiff(
631
 
"""Checkout (format: dirstate)
 
613
"""Checkout (format: unnamed)
632
614
Location:
633
615
       checkout root: tree/checkout
634
616
  checkout of branch: repo/branch
635
617
 
636
618
Format:
637
619
       control: Meta directory format 1
638
 
  working tree: Working tree format 4
 
620
  working tree: Working tree format 6
639
621
        branch: %s
640
622
    repository: %s
641
623
 
653
635
 
654
636
Branch history:
655
637
         0 revisions
656
 
         0 committers
657
638
 
658
639
Repository:
659
640
         0 revisions
660
 
         0 KiB
661
641
""" % (format.get_branch_format().get_format_description(),
662
642
       format.repository_format.get_format_description(),
663
643
       ), out)
669
649
        tree3.add('b')
670
650
        out, err = self.run_bzr('info tree/checkout --verbose')
671
651
        self.assertEqualDiff(
672
 
"""Checkout (format: dirstate)
 
652
"""Checkout (format: unnamed)
673
653
Location:
674
654
       checkout root: tree/checkout
675
655
  checkout of branch: repo/branch
676
656
 
677
657
Format:
678
658
       control: Meta directory format 1
679
 
  working tree: Working tree format 4
 
659
  working tree: Working tree format 6
680
660
        branch: %s
681
661
    repository: %s
682
662
 
692
672
 
693
673
Branch history:
694
674
         1 revision
695
 
         1 committer
696
675
         0 days old
697
676
   first revision: %s
698
677
  latest revision: %s
699
678
 
700
679
Repository:
701
680
         1 revision
702
 
         %d KiB
703
681
""" % (format.get_branch_format().get_format_description(),
704
682
       format.repository_format.get_format_description(),
705
683
       datestring_first, datestring_first,
706
 
       # poking at _revision_store isn't all that clean, but neither is
707
 
       # having the ui test dependent on the exact overhead of a given store.
708
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
709
684
       ), out)
710
685
        self.assertEqual('', err)
711
686
        tree3.commit('commit two')
712
687
 
713
688
        # Out of date lightweight checkout
714
689
        rev = repo.get_revision(branch1.revision_history()[-1])
715
 
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
690
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
716
691
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
717
692
        self.assertEqualDiff(
718
 
"""Lightweight checkout (format: dirstate or dirstate-tags or \
719
 
pack-0.92 or rich-root or rich-root-pack)
 
693
"""Lightweight checkout (format: %s)
720
694
Location:
721
695
  light checkout root: tree/lightcheckout
722
696
   checkout of branch: repo/branch
724
698
 
725
699
Format:
726
700
       control: Meta directory format 1
727
 
  working tree: Working tree format 4
 
701
  working tree: Working tree format 6
728
702
        branch: %s
729
703
    repository: %s
730
704
 
742
716
 
743
717
Branch history:
744
718
         2 revisions
745
 
         1 committer
746
719
         0 days old
747
720
   first revision: %s
748
721
  latest revision: %s
749
722
 
750
723
Repository:
751
724
         2 revisions
752
 
         %d KiB
753
 
""" % (format.get_branch_format().get_format_description(),
 
725
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
754
726
       format.repository_format.get_format_description(),
755
727
       datestring_first, datestring_last,
756
 
       # poking at _revision_store isn't all that clean, but neither is
757
 
       # having the ui test dependent on the exact overhead of a given store.
758
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
759
728
       ), out)
760
729
        self.assertEqual('', err)
761
730
 
774
743
 
775
744
Branch history:
776
745
         2 revisions
777
 
         1 committer
778
746
         0 days old
779
747
   first revision: %s
780
748
  latest revision: %s
781
749
 
782
750
Repository:
783
751
         2 revisions
784
 
         %d KiB
785
752
""" % (format.get_branch_format().get_format_description(),
786
753
       format.repository_format.get_format_description(),
787
754
       datestring_first, datestring_last,
788
 
       # poking at _revision_store isn't all that clean, but neither is
789
 
       # having the ui test dependent on the exact overhead of a given store.
790
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
791
755
       ), out)
792
756
        self.assertEqual('', err)
793
757
 
804
768
 
805
769
Repository:
806
770
         2 revisions
807
 
         %d KiB
808
771
""" % (format.repository_format.get_format_description(),
809
 
       # poking at _revision_store isn't all that clean, but neither is
810
 
       # having the ui test dependent on the exact overhead of a given store.
811
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
812
772
       ), out)
813
773
        self.assertEqual('', err)
814
774
 
833
793
 
834
794
Repository:
835
795
         0 revisions
836
 
         0 KiB
837
796
""" % (format.repository_format.get_format_description(),
838
797
       ), out)
839
798
        self.assertEqual('', err)
870
829
 
871
830
Branch history:
872
831
         0 revisions
873
 
         0 committers
874
832
 
875
833
Repository:
876
834
         0 revisions
877
 
         0 KiB
878
835
""" % (format.get_branch_format().get_format_description(),
879
836
       format.repository_format.get_format_description(),
880
837
       ), out)
886
843
        tree1.add('a')
887
844
        tree1.commit('commit one')
888
845
        rev = repo.get_revision(branch1.revision_history()[0])
889
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
846
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
890
847
        out, err = self.run_bzr('info -v repo/branch1')
891
848
        self.assertEqualDiff(
892
849
"""Repository tree (format: knit)
912
869
 
913
870
Branch history:
914
871
         1 revision
915
 
         1 committer
916
872
         0 days old
917
873
   first revision: %s
918
874
  latest revision: %s
919
875
 
920
876
Repository:
921
877
         1 revision
922
 
         %d KiB
923
878
""" % (format.get_branch_format().get_format_description(),
924
879
       format.repository_format.get_format_description(),
925
880
       datestring_first, datestring_first,
926
 
       # poking at _revision_store isn't all that clean, but neither is
927
 
       # having the ui test dependent on the exact overhead of a given store.
928
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
929
881
       ), out)
930
882
        self.assertEqual('', err)
931
883
 
958
910
 
959
911
Branch history:
960
912
         0 revisions
961
 
         0 committers
962
913
 
963
914
Repository:
964
915
         1 revision
965
 
         %d KiB
966
916
""" % (format.get_branch_format().get_format_description(),
967
917
       format.repository_format.get_format_description(),
968
 
       # poking at _revision_store isn't all that clean, but neither is
969
 
       # having the ui test dependent on the exact overhead of a given store.
970
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
971
918
       ), out)
972
919
        self.assertEqual('', err)
973
920
 
1002
949
 
1003
950
Branch history:
1004
951
         1 revision
1005
 
         1 committer
1006
952
         0 days old
1007
953
   first revision: %s
1008
954
  latest revision: %s
1009
955
 
1010
956
Repository:
1011
957
         1 revision
1012
 
         %d KiB
1013
958
""" % (format.get_branch_format().get_format_description(),
1014
959
       format.repository_format.get_format_description(),
1015
960
       datestring_first, datestring_first,
1016
 
       # poking at _revision_store isn't all that clean, but neither is
1017
 
       # having the ui test dependent on the exact overhead of a given store.
1018
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1019
961
       ), out)
1020
962
        self.assertEqual('', err)
1021
963
 
1034
976
 
1035
977
Repository:
1036
978
         1 revision
1037
 
         %d KiB
1038
979
""" % (format.repository_format.get_format_description(),
1039
 
       # poking at _revision_store isn't all that clean, but neither is
1040
 
       # having the ui test dependent on the exact overhead of a given store.
1041
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1042
980
       ),
1043
981
       out)
1044
982
        self.assertEqual('', err)
1045
 
    
 
983
 
1046
984
    def test_info_shared_repository_with_tree_in_root(self):
1047
985
        format = bzrdir.format_registry.make_bzrdir('knit')
1048
986
        transport = self.get_transport()
1064
1002
 
1065
1003
Repository:
1066
1004
         0 revisions
1067
 
         0 KiB
1068
1005
""" % (format.repository_format.get_format_description(),
1069
1006
       ), out)
1070
1007
        self.assertEqual('', err)
1098
1035
 
1099
1036
Branch history:
1100
1037
         0 revisions
1101
 
         0 committers
1102
1038
 
1103
1039
Repository:
1104
1040
         0 revisions
1105
 
         0 KiB
1106
1041
""" % (format.get_branch_format().get_format_description(),
1107
1042
       format.repository_format.get_format_description(),
1108
1043
       ), out)
1109
1044
        self.assertEqual('', err)
1110
1045
 
 
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)
 
1056
Location:
 
1057
  shared repository: repo
 
1058
 
 
1059
Format:
 
1060
       control: Meta directory format 1
 
1061
    repository: %s
 
1062
 
 
1063
Create working tree for new branches inside the repository.
 
1064
 
 
1065
Repository:
 
1066
         0 revisions
 
1067
more info
 
1068
""" % (format.repository_format.get_format_description(),
 
1069
       ), out)
 
1070
        self.assertEqual('', err)
 
1071
 
1111
1072
    def assertCheckoutStatusOutput(self,
1112
1073
        command_string, lco_tree, shared_repo=None,
1113
1074
        repo_branch=None,
1123
1084
        allow us, the test writers, to document what *should* be present in
1124
1085
        the output. Removing this separation would remove the value of the
1125
1086
        tests.
1126
 
        
 
1087
 
1127
1088
        :param path: the path to the light checkout.
1128
1089
        :param lco_tree: the tree object for the light checkout.
1129
1090
        :param shared_repo: A shared repository is in use, expect that in
1137
1098
            actually locked then this parameter is overridden. This is because
1138
1099
            pack repositories do not have any public API for obtaining an
1139
1100
            exclusive repository wide lock.
1140
 
        :param verbose: If true, expect verbose output
 
1101
        :param verbose: verbosity level: 2 or higher to show committers
1141
1102
        """
1142
1103
        def friendly_location(url):
1143
1104
            path = urlutils.unescape_for_display(url, 'ascii')
1162
1123
            (False, True): 'Lightweight checkout',
1163
1124
            (False, False): 'Checkout',
1164
1125
            }[(shared_repo is not None, light_checkout)]
1165
 
        format = {True: 'dirstate or dirstate-tags or pack-0.92'
1166
 
                        ' or rich-root or rich-root-pack',
1167
 
                  False: 'dirstate'}[light_checkout]
 
1126
        format = {True: self._repo_strings,
 
1127
                  False: 'unnamed'}[light_checkout]
1168
1128
        if repo_locked:
1169
1129
            repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1170
1130
        if repo_locked or branch_locked or tree_locked:
1207
1167
        else:
1208
1168
            branch_data = ("   checkout of branch: %s\n" %
1209
1169
                lco_tree.branch.bzrdir.root_transport.base)
1210
 
        
1211
 
        if verbose:
 
1170
 
 
1171
        if verbose >= 2:
1212
1172
            verbose_info = '         0 committers\n'
1213
1173
        else:
1214
1174
            verbose_info = ''
1215
 
            
 
1175
 
1216
1176
        self.assertEqualDiff(
1217
1177
"""%s (format: %s)
1218
1178
Location:
1238
1198
%s
1239
1199
Repository:
1240
1200
         0 revisions
1241
 
         0 KiB
1242
1201
""" %  (description,
1243
1202
        format,
1244
1203
        tree_data,
1255
1214
        transport = self.get_transport()
1256
1215
        # Create shared repository with a branch
1257
1216
        repo = self.make_repository('repo', shared=True,
1258
 
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1217
                                    format=bzrdir.BzrDirMetaFormat1())
1259
1218
        repo.set_make_working_trees(False)
1260
1219
        repo.bzrdir.root_transport.mkdir('branch')
1261
1220
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1262
 
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1221
                                    format=bzrdir.BzrDirMetaFormat1())
1263
1222
        # Do a heavy checkout
1264
1223
        transport.mkdir('tree')
1265
1224
        transport.mkdir('tree/checkout')
1266
 
        co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1267
 
            format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1225
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
 
1226
            format=bzrdir.BzrDirMetaFormat1())
1268
1227
        co_branch.bind(repo_branch)
1269
1228
        # Do a light checkout of the heavy one
1270
1229
        transport.mkdir('tree/lightcheckout')
1271
 
        lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1272
 
        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)
1273
1233
        lco_dir.create_workingtree()
1274
1234
        lco_tree = lco_dir.open_workingtree()
1275
1235
 
1366
1326
    def test_info_locking_oslocks(self):
1367
1327
        if sys.platform == "win32":
1368
1328
            raise TestSkipped("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
 
1332
        # call here.
 
1333
        self.thisFailsStrictLockCheck()
1369
1334
 
1370
1335
        tree = self.make_branch_and_tree('branch',
1371
 
                                         format=bzrlib.bzrdir.BzrDirFormat6())
 
1336
                                         format=bzrdir.BzrDirFormat6())
1372
1337
 
1373
1338
        # Test all permutations of locking the working tree, branch and repository
1374
1339
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1401
1366
 
1402
1367
Branch history:
1403
1368
         0 revisions
1404
 
         0 committers
1405
1369
 
1406
1370
Repository:
1407
1371
         0 revisions
1408
 
         0 KiB
1409
1372
""" % ('branch', tree.branch.repository._format.get_format_description(),
1410
1373
       ), out)
1411
1374
        self.assertEqual('', err)
1435
1398
 
1436
1399
Branch history:
1437
1400
         0 revisions
1438
 
         0 committers
1439
1401
 
1440
1402
Repository:
1441
1403
         0 revisions
1442
 
         0 KiB
1443
1404
""" % ('branch', tree.branch.repository._format.get_format_description(),
1444
1405
       ), out)
1445
1406
        self.assertEqual('', err)
1446
1407
        tree.unlock()
 
1408
 
 
1409
    def test_info_stacked(self):
 
1410
        # We have a mainline
 
1411
        trunk_tree = self.make_branch_and_tree('mainline',
 
1412
            format='1.6')
 
1413
        trunk_tree.commit('mainline')
 
1414
        # and a branch from it which is stacked
 
1415
        new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
 
1416
        out, err = self.run_bzr('info newbranch')
 
1417
        self.assertEqual(
 
1418
"""Standalone tree (format: 1.6)
 
1419
Location:
 
1420
  branch root: newbranch
 
1421
 
 
1422
Related branches:
 
1423
  parent branch: mainline
 
1424
     stacked on: mainline
 
1425
""", out)
 
1426
        self.assertEqual("", err)