~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2007-10-29 08:34:38 UTC
  • mto: (2535.4.22 streaming-smart-fetch)
  • mto: This revision was merged to the branch mainline in revision 2981.
  • Revision ID: andrew.bennetts@canonical.com-20071029083438-ke1vsv97dvgrvup5
ImproveĀ someĀ docstrings.

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
 
    info,
27
27
    osutils,
28
 
    tests,
29
 
    upgrade,
 
28
    repository,
30
29
    urlutils,
31
30
    )
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"
 
31
from bzrlib.osutils import format_date
 
32
from bzrlib.tests import TestSkipped
 
33
from bzrlib.tests.blackbox import ExternalBase
 
34
 
 
35
 
 
36
class TestInfo(ExternalBase):
40
37
 
41
38
    def test_info_non_existing(self):
42
 
        self.vfs_transport_factory = memory.MemoryServer
43
 
        location = self.get_url()
 
39
        if sys.platform == "win32":
 
40
            location = "C:/i/do/not/exist/"
 
41
        else:
 
42
            location = "/i/do/not/exist/"
44
43
        out, err = self.run_bzr('info '+location, retcode=3)
45
44
        self.assertEqual(out, '')
46
45
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
62
61
""", out)
63
62
        self.assertEqual('', err)
64
63
 
65
 
        # Standalone branch - verbose mode
66
64
        out, err = self.run_bzr('info standalone -v')
67
65
        self.assertEqualDiff(
68
66
"""Standalone tree (format: weave)
87
85
 
88
86
Branch history:
89
87
         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
88
         0 committers
122
89
 
123
90
Repository:
124
91
         0 revisions
 
92
         0 KiB
125
93
""", out)
126
94
        self.assertEqual('', err)
127
95
        tree1.commit('commit one')
128
96
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
129
 
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
97
        datestring_first = format_date(rev.timestamp, rev.timezone)
130
98
 
131
99
        # Branch standalone with push location
132
100
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
172
140
 
173
141
Branch history:
174
142
         1 revision
 
143
         1 committer
175
144
         0 days old
176
145
   first revision: %s
177
146
  latest revision: %s
178
147
 
179
148
Repository:
180
149
         1 revision
 
150
         %d KiB
181
151
""" % (datestring_first, datestring_first,
 
152
       # poking at _revision_store isn't all that clean, but neither is
 
153
       # having the ui test dependent on the exact overhead of a given store.
 
154
       branch2.repository._revision_store.total_size(
 
155
        branch2.repository.get_transaction())[1] / 1024,
182
156
       ), out)
183
157
        self.assertEqual('', err)
184
158
 
186
160
        # (creates backup as unknown)
187
161
        branch1.bzrdir.sprout('bound')
188
162
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
189
 
        upgrade.upgrade('bound', knit1_format)
190
 
        branch3 = bzrdir.BzrDir.open('bound').open_branch()
 
163
        bzrlib.upgrade.upgrade('bound', knit1_format)
 
164
        branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
191
165
        branch3.bind(branch1)
192
166
        bound_tree = branch3.bzrdir.open_workingtree()
193
167
        out, err = self.run_bzr('info -v bound')
212
186
         0 added
213
187
         0 removed
214
188
         0 renamed
215
 
         0 unknown
216
 
         1 ignored
 
189
         1 unknown
 
190
         0 ignored
217
191
         0 versioned subdirectories
218
192
 
219
193
Branch history:
220
194
         1 revision
 
195
         1 committer
221
196
         0 days old
222
197
   first revision: %s
223
198
  latest revision: %s
224
199
 
225
200
Repository:
226
201
         1 revision
 
202
         %d KiB
227
203
""" % (bound_tree._format.get_format_description(),
228
204
       branch3._format.get_format_description(),
229
205
       branch3.repository._format.get_format_description(),
230
206
       datestring_first, datestring_first,
 
207
       # poking at _revision_store isn't all that clean, but neither is
 
208
       # having the ui test dependent on the exact overhead of a given store.
 
209
       branch3.repository._revision_store.total_size(
 
210
        branch3.repository.get_transaction())[1] / 1024,
231
211
       ), out)
232
212
        self.assertEqual('', err)
233
213
 
234
214
        # Checkout standalone (same as above, but does not have parent set)
235
 
        branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
 
215
        branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
236
216
            format=knit1_format)
237
217
        branch4.bind(branch1)
238
218
        branch4.bzrdir.open_workingtree().update()
261
241
 
262
242
Branch history:
263
243
         1 revision
 
244
         1 committer
264
245
         0 days old
265
246
   first revision: %s
266
247
  latest revision: %s
267
248
 
268
249
Repository:
269
250
         1 revision
 
251
         %d KiB
270
252
""" % (branch4.repository._format.get_format_description(),
271
253
       datestring_first, datestring_first,
 
254
       # poking at _revision_store isn't all that clean, but neither is
 
255
       # having the ui test dependent on the exact overhead of a given store.
 
256
       branch4.repository._revision_store.total_size(
 
257
        branch4.repository.get_transaction())[1] / 1024,
272
258
       ), out)
273
259
        self.assertEqual('', err)
274
260
 
277
263
        branch5 = tree5.branch
278
264
        out, err = self.run_bzr('info -v lightcheckout')
279
265
        self.assertEqualDiff(
280
 
"""Lightweight checkout (format: %s)
 
266
"""Lightweight checkout (format: dirstate or dirstate-tags)
281
267
Location:
282
268
  light checkout root: lightcheckout
283
269
   checkout of branch: standalone
284
270
 
285
271
Format:
286
272
       control: Meta directory format 1
287
 
  working tree: Working tree format 6
 
273
  working tree: Working tree format 4
288
274
        branch: Branch format 4
289
275
    repository: Weave repository format 6
290
276
 
300
286
 
301
287
Branch history:
302
288
         1 revision
 
289
         1 committer
303
290
         0 days old
304
291
   first revision: %s
305
292
  latest revision: %s
306
293
 
307
294
Repository:
308
295
         1 revision
309
 
""" % (self._repo_strings, datestring_first, datestring_first,), out)
 
296
         0 KiB
 
297
""" % (datestring_first, datestring_first,), out)
310
298
        self.assertEqual('', err)
311
299
 
312
300
        # Update initial standalone branch
314
302
        tree1.add('b')
315
303
        tree1.commit('commit two')
316
304
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
317
 
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
 
305
        datestring_last = format_date(rev.timestamp, rev.timezone)
318
306
 
319
307
        # Out of date branched standalone branch will not be detected
320
308
        out, err = self.run_bzr('info -v branch')
345
333
 
346
334
Branch history:
347
335
         1 revision
 
336
         1 committer
348
337
         0 days old
349
338
   first revision: %s
350
339
  latest revision: %s
351
340
 
352
341
Repository:
353
342
         1 revision
 
343
         0 KiB
354
344
""" % (datestring_first, datestring_first,
355
345
       ), out)
356
346
        self.assertEqual('', err)
380
370
         0 added
381
371
         0 removed
382
372
         0 renamed
383
 
         0 unknown
384
 
         1 ignored
 
373
         1 unknown
 
374
         0 ignored
385
375
         0 versioned subdirectories
386
376
 
387
377
Branch history:
388
378
         1 revision
 
379
         1 committer
389
380
         0 days old
390
381
   first revision: %s
391
382
  latest revision: %s
392
383
 
393
384
Repository:
394
385
         1 revision
 
386
         %d KiB
395
387
""" % (branch3.repository._format.get_format_description(),
396
388
       datestring_first, datestring_first,
 
389
       # poking at _revision_store isn't all that clean, but neither is
 
390
       # having the ui test dependent on the exact overhead of a given store.
 
391
       branch3.repository._revision_store.total_size(
 
392
        branch3.repository.get_transaction())[1] / 1024,
397
393
       ), out)
398
394
        self.assertEqual('', err)
399
395
 
425
421
 
426
422
Branch history:
427
423
         1 revision
 
424
         1 committer
428
425
         0 days old
429
426
   first revision: %s
430
427
  latest revision: %s
431
428
 
432
429
Repository:
433
430
         1 revision
 
431
         %d KiB
434
432
""" % (branch4.repository._format.get_format_description(),
435
433
       datestring_first, datestring_first,
 
434
       # poking at _revision_store isn't all that clean, but neither is
 
435
       # having the ui test dependent on the exact overhead of a given store.
 
436
       branch4.repository._revision_store.total_size(
 
437
        branch4.repository.get_transaction())[1] / 1024,
436
438
       ), out)
437
439
        self.assertEqual('', err)
438
440
 
439
441
        # Out of date lightweight checkout
440
442
        out, err = self.run_bzr('info lightcheckout --verbose')
441
443
        self.assertEqualDiff(
442
 
"""Lightweight checkout (format: %s)
 
444
"""Lightweight checkout (format: dirstate or dirstate-tags)
443
445
Location:
444
446
  light checkout root: lightcheckout
445
447
   checkout of branch: standalone
446
448
 
447
449
Format:
448
450
       control: Meta directory format 1
449
 
  working tree: Working tree format 6
 
451
  working tree: Working tree format 4
450
452
        branch: Branch format 4
451
453
    repository: Weave repository format 6
452
454
 
464
466
 
465
467
Branch history:
466
468
         2 revisions
 
469
         1 committer
467
470
         0 days old
468
471
   first revision: %s
469
472
  latest revision: %s
470
473
 
471
474
Repository:
472
475
         2 revisions
473
 
""" % (self._repo_strings, datestring_first, datestring_last,), out)
 
476
         0 KiB
 
477
""" % (datestring_first, datestring_last,), out)
474
478
        self.assertEqual('', err)
475
479
 
476
480
    def test_info_standalone_no_tree(self):
480
484
        repo = branch.repository
481
485
        out, err = self.run_bzr('info branch -v')
482
486
        self.assertEqualDiff(
483
 
"""Standalone branch (format: %s)
 
487
"""Standalone branch (format: dirstate-tags)
484
488
Location:
485
489
  branch root: branch
486
490
 
491
495
 
492
496
Branch history:
493
497
         0 revisions
 
498
         0 committers
494
499
 
495
500
Repository:
496
501
         0 revisions
497
 
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
498
 
       format.get_branch_format().get_format_description(),
 
502
         0 KiB
 
503
""" % (format.get_branch_format().get_format_description(),
499
504
       format.repository_format.get_format_description(),
500
505
       ), out)
501
506
        self.assertEqual('', err)
519
524
 
520
525
Repository:
521
526
         0 revisions
 
527
         0 KiB
522
528
""" % ('repo', format.repository_format.get_format_description(),
523
529
       ), out)
524
530
        self.assertEqual('', err)
541
547
 
542
548
Branch history:
543
549
         0 revisions
 
550
         0 committers
544
551
 
545
552
Repository:
546
553
         0 revisions
 
554
         0 KiB
547
555
""" % (format.get_branch_format().get_format_description(),
548
556
       format.repository_format.get_format_description(),
549
557
       ), out)
552
560
        # Create lightweight checkout
553
561
        transport.mkdir('tree')
554
562
        transport.mkdir('tree/lightcheckout')
555
 
        tree2 = branch1.create_checkout('tree/lightcheckout',
 
563
        tree2 = branch1.create_checkout('tree/lightcheckout', 
556
564
            lightweight=True)
557
565
        branch2 = tree2.branch
558
566
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
568
576
        tree2.add('a')
569
577
        tree2.commit('commit one')
570
578
        rev = repo.get_revision(branch2.revision_history()[0])
571
 
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
579
        datestring_first = format_date(rev.timestamp, rev.timezone)
572
580
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
573
581
        self.assertEqualDiff(
574
 
"""Lightweight checkout (format: %s)
 
582
"""Lightweight checkout (format: dirstate or dirstate-tags)
575
583
Location:
576
584
  light checkout root: tree/lightcheckout
577
585
   checkout of branch: repo/branch
579
587
 
580
588
Format:
581
589
       control: Meta directory format 1
582
 
  working tree: Working tree format 6
 
590
  working tree: Working tree format 4
583
591
        branch: %s
584
592
    repository: %s
585
593
 
595
603
 
596
604
Branch history:
597
605
         1 revision
 
606
         1 committer
598
607
         0 days old
599
608
   first revision: %s
600
609
  latest revision: %s
601
610
 
602
611
Repository:
603
612
         1 revision
604
 
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
 
613
         %d KiB
 
614
""" % (format.get_branch_format().get_format_description(),
605
615
       format.repository_format.get_format_description(),
606
616
       datestring_first, datestring_first,
 
617
       # poking at _revision_store isn't all that clean, but neither is
 
618
       # having the ui test dependent on the exact overhead of a given store.
 
619
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
607
620
       ), out)
608
621
        self.assertEqual('', err)
609
622
 
610
623
        # Out of date checkout
611
624
        out, err = self.run_bzr('info -v tree/checkout')
612
625
        self.assertEqualDiff(
613
 
"""Checkout (format: unnamed)
 
626
"""Checkout (format: dirstate)
614
627
Location:
615
628
       checkout root: tree/checkout
616
629
  checkout of branch: repo/branch
617
630
 
618
631
Format:
619
632
       control: Meta directory format 1
620
 
  working tree: Working tree format 6
 
633
  working tree: Working tree format 4
621
634
        branch: %s
622
635
    repository: %s
623
636
 
635
648
 
636
649
Branch history:
637
650
         0 revisions
 
651
         0 committers
638
652
 
639
653
Repository:
640
654
         0 revisions
 
655
         0 KiB
641
656
""" % (format.get_branch_format().get_format_description(),
642
657
       format.repository_format.get_format_description(),
643
658
       ), out)
649
664
        tree3.add('b')
650
665
        out, err = self.run_bzr('info tree/checkout --verbose')
651
666
        self.assertEqualDiff(
652
 
"""Checkout (format: unnamed)
 
667
"""Checkout (format: dirstate)
653
668
Location:
654
669
       checkout root: tree/checkout
655
670
  checkout of branch: repo/branch
656
671
 
657
672
Format:
658
673
       control: Meta directory format 1
659
 
  working tree: Working tree format 6
 
674
  working tree: Working tree format 4
660
675
        branch: %s
661
676
    repository: %s
662
677
 
672
687
 
673
688
Branch history:
674
689
         1 revision
 
690
         1 committer
675
691
         0 days old
676
692
   first revision: %s
677
693
  latest revision: %s
678
694
 
679
695
Repository:
680
696
         1 revision
 
697
         %d KiB
681
698
""" % (format.get_branch_format().get_format_description(),
682
699
       format.repository_format.get_format_description(),
683
700
       datestring_first, datestring_first,
 
701
       # poking at _revision_store isn't all that clean, but neither is
 
702
       # having the ui test dependent on the exact overhead of a given store.
 
703
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
684
704
       ), out)
685
705
        self.assertEqual('', err)
686
706
        tree3.commit('commit two')
687
707
 
688
708
        # Out of date lightweight checkout
689
709
        rev = repo.get_revision(branch1.revision_history()[-1])
690
 
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
 
710
        datestring_last = format_date(rev.timestamp, rev.timezone)
691
711
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
692
712
        self.assertEqualDiff(
693
 
"""Lightweight checkout (format: %s)
 
713
"""Lightweight checkout (format: dirstate or dirstate-tags)
694
714
Location:
695
715
  light checkout root: tree/lightcheckout
696
716
   checkout of branch: repo/branch
698
718
 
699
719
Format:
700
720
       control: Meta directory format 1
701
 
  working tree: Working tree format 6
 
721
  working tree: Working tree format 4
702
722
        branch: %s
703
723
    repository: %s
704
724
 
716
736
 
717
737
Branch history:
718
738
         2 revisions
 
739
         1 committer
719
740
         0 days old
720
741
   first revision: %s
721
742
  latest revision: %s
722
743
 
723
744
Repository:
724
745
         2 revisions
725
 
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
 
746
         %d KiB
 
747
""" % (format.get_branch_format().get_format_description(),
726
748
       format.repository_format.get_format_description(),
727
749
       datestring_first, datestring_last,
 
750
       # poking at _revision_store isn't all that clean, but neither is
 
751
       # having the ui test dependent on the exact overhead of a given store.
 
752
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
728
753
       ), out)
729
754
        self.assertEqual('', err)
730
755
 
743
768
 
744
769
Branch history:
745
770
         2 revisions
 
771
         1 committer
746
772
         0 days old
747
773
   first revision: %s
748
774
  latest revision: %s
749
775
 
750
776
Repository:
751
777
         2 revisions
 
778
         %d KiB
752
779
""" % (format.get_branch_format().get_format_description(),
753
780
       format.repository_format.get_format_description(),
754
781
       datestring_first, datestring_last,
 
782
       # poking at _revision_store isn't all that clean, but neither is
 
783
       # having the ui test dependent on the exact overhead of a given store.
 
784
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
755
785
       ), out)
756
786
        self.assertEqual('', err)
757
787
 
768
798
 
769
799
Repository:
770
800
         2 revisions
 
801
         %d KiB
771
802
""" % (format.repository_format.get_format_description(),
 
803
       # poking at _revision_store isn't all that clean, but neither is
 
804
       # having the ui test dependent on the exact overhead of a given store.
 
805
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
772
806
       ), out)
773
807
        self.assertEqual('', err)
774
808
 
793
827
 
794
828
Repository:
795
829
         0 revisions
 
830
         0 KiB
796
831
""" % (format.repository_format.get_format_description(),
797
832
       ), out)
798
833
        self.assertEqual('', err)
829
864
 
830
865
Branch history:
831
866
         0 revisions
 
867
         0 committers
832
868
 
833
869
Repository:
834
870
         0 revisions
 
871
         0 KiB
835
872
""" % (format.get_branch_format().get_format_description(),
836
873
       format.repository_format.get_format_description(),
837
874
       ), out)
843
880
        tree1.add('a')
844
881
        tree1.commit('commit one')
845
882
        rev = repo.get_revision(branch1.revision_history()[0])
846
 
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
883
        datestring_first = format_date(rev.timestamp, rev.timezone)
847
884
        out, err = self.run_bzr('info -v repo/branch1')
848
885
        self.assertEqualDiff(
849
886
"""Repository tree (format: knit)
869
906
 
870
907
Branch history:
871
908
         1 revision
 
909
         1 committer
872
910
         0 days old
873
911
   first revision: %s
874
912
  latest revision: %s
875
913
 
876
914
Repository:
877
915
         1 revision
 
916
         %d KiB
878
917
""" % (format.get_branch_format().get_format_description(),
879
918
       format.repository_format.get_format_description(),
880
919
       datestring_first, datestring_first,
 
920
       # poking at _revision_store isn't all that clean, but neither is
 
921
       # having the ui test dependent on the exact overhead of a given store.
 
922
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
881
923
       ), out)
882
924
        self.assertEqual('', err)
883
925
 
910
952
 
911
953
Branch history:
912
954
         0 revisions
 
955
         0 committers
913
956
 
914
957
Repository:
915
958
         1 revision
 
959
         %d KiB
916
960
""" % (format.get_branch_format().get_format_description(),
917
961
       format.repository_format.get_format_description(),
 
962
       # poking at _revision_store isn't all that clean, but neither is
 
963
       # having the ui test dependent on the exact overhead of a given store.
 
964
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
918
965
       ), out)
919
966
        self.assertEqual('', err)
920
967
 
949
996
 
950
997
Branch history:
951
998
         1 revision
 
999
         1 committer
952
1000
         0 days old
953
1001
   first revision: %s
954
1002
  latest revision: %s
955
1003
 
956
1004
Repository:
957
1005
         1 revision
 
1006
         %d KiB
958
1007
""" % (format.get_branch_format().get_format_description(),
959
1008
       format.repository_format.get_format_description(),
960
1009
       datestring_first, datestring_first,
 
1010
       # poking at _revision_store isn't all that clean, but neither is
 
1011
       # having the ui test dependent on the exact overhead of a given store.
 
1012
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
961
1013
       ), out)
962
1014
        self.assertEqual('', err)
963
1015
 
976
1028
 
977
1029
Repository:
978
1030
         1 revision
 
1031
         %d KiB
979
1032
""" % (format.repository_format.get_format_description(),
 
1033
       # poking at _revision_store isn't all that clean, but neither is
 
1034
       # having the ui test dependent on the exact overhead of a given store.
 
1035
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
980
1036
       ),
981
1037
       out)
982
1038
        self.assertEqual('', err)
983
 
 
 
1039
    
984
1040
    def test_info_shared_repository_with_tree_in_root(self):
985
1041
        format = bzrdir.format_registry.make_bzrdir('knit')
986
1042
        transport = self.get_transport()
1002
1058
 
1003
1059
Repository:
1004
1060
         0 revisions
 
1061
         0 KiB
1005
1062
""" % (format.repository_format.get_format_description(),
1006
1063
       ), out)
1007
1064
        self.assertEqual('', err)
1035
1092
 
1036
1093
Branch history:
1037
1094
         0 revisions
 
1095
         0 committers
1038
1096
 
1039
1097
Repository:
1040
1098
         0 revisions
 
1099
         0 KiB
1041
1100
""" % (format.get_branch_format().get_format_description(),
1042
1101
       format.repository_format.get_format_description(),
1043
1102
       ), out)
1044
1103
        self.assertEqual('', err)
1045
1104
 
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
 
    def assertCheckoutStatusOutput(self,
 
1105
    def assertCheckoutStatusOutput(self, 
1073
1106
        command_string, lco_tree, shared_repo=None,
1074
1107
        repo_branch=None,
1075
1108
        tree_locked=False,
1084
1117
        allow us, the test writers, to document what *should* be present in
1085
1118
        the output. Removing this separation would remove the value of the
1086
1119
        tests.
1087
 
 
 
1120
        
1088
1121
        :param path: the path to the light checkout.
1089
1122
        :param lco_tree: the tree object for the light checkout.
1090
1123
        :param shared_repo: A shared repository is in use, expect that in
1094
1127
        :param tree_locked: If true, expect the tree to be locked.
1095
1128
        :param branch_locked: If true, expect the branch to be locked.
1096
1129
        :param repo_locked: If true, expect the repository to be locked.
1097
 
            Note that the lco_tree.branch.repository is inspected, and if is not
1098
 
            actually locked then this parameter is overridden. This is because
1099
 
            pack repositories do not have any public API for obtaining an
1100
 
            exclusive repository wide lock.
1101
 
        :param verbose: verbosity level: 2 or higher to show committers
 
1130
        :param verbose: If true, expect verbose output
1102
1131
        """
1103
1132
        def friendly_location(url):
1104
1133
            path = urlutils.unescape_for_display(url, 'ascii')
1107
1136
            except errors.PathNotChild:
1108
1137
                return path
1109
1138
 
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).
 
1139
        if tree_locked and sys.platform == 'win32':
 
1140
            # We expect this to fail because of locking errors. (A write-locked
 
1141
            # file cannot be read-locked in the same process).
1114
1142
            # 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)
 
1143
            self.run_bzr_error([], 'info ' + command_string)
 
1144
            return
1119
1145
        out, err = self.run_bzr('info %s' % command_string)
1120
1146
        description = {
1121
1147
            (True, True): 'Lightweight checkout',
1123
1149
            (False, True): 'Lightweight checkout',
1124
1150
            (False, False): 'Checkout',
1125
1151
            }[(shared_repo is not None, light_checkout)]
1126
 
        format = {True: self._repo_strings,
1127
 
                  False: 'unnamed'}[light_checkout]
1128
 
        if repo_locked:
1129
 
            repo_locked = lco_tree.branch.repository.get_physical_lock_status()
 
1152
        format = {True: 'dirstate or dirstate-tags',
 
1153
                  False: 'dirstate'}[light_checkout]
1130
1154
        if repo_locked or branch_locked or tree_locked:
1131
1155
            def locked_message(a_bool):
1132
1156
                if a_bool:
1167
1191
        else:
1168
1192
            branch_data = ("   checkout of branch: %s\n" %
1169
1193
                lco_tree.branch.bzrdir.root_transport.base)
1170
 
 
1171
 
        if verbose >= 2:
 
1194
        
 
1195
        if verbose:
1172
1196
            verbose_info = '         0 committers\n'
1173
1197
        else:
1174
1198
            verbose_info = ''
1175
 
 
 
1199
            
1176
1200
        self.assertEqualDiff(
1177
1201
"""%s (format: %s)
1178
1202
Location:
1198
1222
%s
1199
1223
Repository:
1200
1224
         0 revisions
 
1225
         0 KiB
1201
1226
""" %  (description,
1202
1227
        format,
1203
1228
        tree_data,
1214
1239
        transport = self.get_transport()
1215
1240
        # Create shared repository with a branch
1216
1241
        repo = self.make_repository('repo', shared=True,
1217
 
                                    format=bzrdir.BzrDirMetaFormat1())
 
1242
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
1218
1243
        repo.set_make_working_trees(False)
1219
1244
        repo.bzrdir.root_transport.mkdir('branch')
1220
1245
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1221
 
                                    format=bzrdir.BzrDirMetaFormat1())
 
1246
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
1222
1247
        # Do a heavy checkout
1223
1248
        transport.mkdir('tree')
1224
1249
        transport.mkdir('tree/checkout')
1225
 
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1226
 
            format=bzrdir.BzrDirMetaFormat1())
 
1250
        co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
 
1251
            format=bzrlib.bzrdir.BzrDirMetaFormat1())
1227
1252
        co_branch.bind(repo_branch)
1228
1253
        # Do a light checkout of the heavy one
1229
1254
        transport.mkdir('tree/lightcheckout')
1230
 
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1231
 
        branch.BranchReferenceFormat().initialize(lco_dir,
1232
 
            target_branch=co_branch)
 
1255
        lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
 
1256
        bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1233
1257
        lco_dir.create_workingtree()
1234
1258
        lco_tree = lco_dir.open_workingtree()
1235
1259
 
1325
1349
 
1326
1350
    def test_info_locking_oslocks(self):
1327
1351
        if sys.platform == "win32":
1328
 
            self.skip("don't use oslocks on win32 in unix manner")
1329
 
        # This test tests old (all-in-one, OS lock using) behaviour which
1330
 
        # simply cannot work on windows (and is indeed why we changed our
1331
 
        # design. As such, don't try to remove the thisFailsStrictLockCheck
1332
 
        # call here.
1333
 
        self.thisFailsStrictLockCheck()
 
1352
            raise TestSkipped("don't use oslocks on win32 in unix manner")
1334
1353
 
1335
1354
        tree = self.make_branch_and_tree('branch',
1336
 
                                         format=bzrdir.BzrDirFormat6())
 
1355
                                         format=bzrlib.bzrdir.BzrDirFormat6())
1337
1356
 
1338
1357
        # Test all permutations of locking the working tree, branch and repository
1339
1358
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1366
1385
 
1367
1386
Branch history:
1368
1387
         0 revisions
 
1388
         0 committers
1369
1389
 
1370
1390
Repository:
1371
1391
         0 revisions
 
1392
         0 KiB
1372
1393
""" % ('branch', tree.branch.repository._format.get_format_description(),
1373
1394
       ), out)
1374
1395
        self.assertEqual('', err)
1398
1419
 
1399
1420
Branch history:
1400
1421
         0 revisions
 
1422
         0 committers
1401
1423
 
1402
1424
Repository:
1403
1425
         0 revisions
 
1426
         0 KiB
1404
1427
""" % ('branch', tree.branch.repository._format.get_format_description(),
1405
1428
       ), out)
1406
1429
        self.assertEqual('', err)
1407
1430
        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)