~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: 2010-10-08 08:15:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101008081514-dviqzrdfwyzsqbz2
Split NEWS into per-release doc/en/release-notes/bzr-*.txt

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