~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Ian Clatworthy
  • Date: 2007-11-28 00:07:56 UTC
  • mto: (3054.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 3055.
  • Revision ID: ian.clatworthy@internode.on.net-20071128000756-kqm8iqmc9281roii
more cleanups and creation of tutorials directory

Show diffs side-by-side

added added

removed removed

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