~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Tests for the info command of bzr."""
19
19
 
 
20
import os
20
21
import sys
21
22
 
22
23
import bzrlib
23
24
from bzrlib import (
24
25
    bzrdir,
 
26
    errors,
 
27
    info,
 
28
    osutils,
25
29
    repository,
 
30
    urlutils,
26
31
    )
27
32
from bzrlib.osutils import format_date
28
33
from bzrlib.tests import TestSkipped
36
41
            location = "C:/i/do/not/exist/"
37
42
        else:
38
43
            location = "/i/do/not/exist/"
39
 
        out, err = self.runbzr('info '+location, retcode=3)
 
44
        out, err = self.run_bzr('info '+location, retcode=3)
40
45
        self.assertEqual(out, '')
41
 
        self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
 
46
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
42
47
 
43
48
    def test_info_standalone(self):
44
49
        transport = self.get_transport()
48
53
        self.build_tree(['standalone/a'])
49
54
        tree1.add('a')
50
55
        branch1 = tree1.branch
51
 
        out, err = self.runbzr('info standalone')
52
 
        self.assertEqualDiff(
53
 
"""Location:
54
 
  branch root: %s
 
56
 
 
57
        out, err = self.run_bzr('info standalone')
 
58
        self.assertEqualDiff(
 
59
"""Standalone tree (format: weave)
 
60
Location:
 
61
  branch root: standalone
 
62
""", out)
 
63
        self.assertEqual('', err)
 
64
 
 
65
        out, err = self.run_bzr('info standalone -v')
 
66
        self.assertEqualDiff(
 
67
"""Standalone tree (format: weave)
 
68
Location:
 
69
  branch root: standalone
55
70
 
56
71
Format:
57
72
       control: All-in-one format 6
71
86
 
72
87
Branch history:
73
88
         0 revisions
 
89
         0 committers
74
90
 
75
91
Repository:
76
92
         0 revisions
77
93
         0 KiB
78
 
""" % branch1.bzrdir.root_transport.base, out)
 
94
""", out)
79
95
        self.assertEqual('', err)
80
96
        tree1.commit('commit one')
81
97
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
84
100
        # Branch standalone with push location
85
101
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
86
102
        branch2.set_push_location(branch1.bzrdir.root_transport.base)
87
 
        out, err = self.runbzr('info branch --verbose')
88
 
        self.assertEqualDiff(
89
 
"""Location:
90
 
  branch root: %s
91
 
 
92
 
Related branches:
93
 
      parent branch: %s
94
 
  publish to branch: %s
 
103
 
 
104
        out, err = self.run_bzr('info branch')
 
105
        self.assertEqualDiff(
 
106
"""Standalone tree (format: weave)
 
107
Location:
 
108
  branch root: branch
 
109
 
 
110
Related branches:
 
111
    push branch: standalone
 
112
  parent branch: standalone
 
113
""", out)
 
114
        self.assertEqual('', err)
 
115
 
 
116
        out, err = self.run_bzr('info branch --verbose')
 
117
        self.assertEqualDiff(
 
118
"""Standalone tree (format: weave)
 
119
Location:
 
120
  branch root: branch
 
121
 
 
122
Related branches:
 
123
    push branch: standalone
 
124
  parent branch: standalone
95
125
 
96
126
Format:
97
127
       control: All-in-one format 6
119
149
Repository:
120
150
         1 revision
121
151
         %d KiB
122
 
""" % (branch2.bzrdir.root_transport.base,
123
 
       branch1.bzrdir.root_transport.base,
124
 
       branch1.bzrdir.root_transport.base,
125
 
       datestring_first, datestring_first,
 
152
""" % (datestring_first, datestring_first,
126
153
       # poking at _revision_store isn't all that clean, but neither is
127
154
       # having the ui test dependent on the exact overhead of a given store.
128
155
       branch2.repository._revision_store.total_size(
138
165
        branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
139
166
        branch3.bind(branch1)
140
167
        bound_tree = branch3.bzrdir.open_workingtree()
141
 
        out, err = self.runbzr('info bound')
 
168
        out, err = self.run_bzr('info -v bound')
142
169
        self.assertEqualDiff(
143
 
"""Location:
144
 
       checkout root: %s
145
 
  checkout of branch: %s
 
170
"""Checkout (format: knit)
 
171
Location:
 
172
       checkout root: bound
 
173
  checkout of branch: standalone
146
174
 
147
175
Related branches:
148
 
  parent branch: %s
 
176
  parent branch: standalone
149
177
 
150
178
Format:
151
179
       control: Meta directory format 1
165
193
 
166
194
Branch history:
167
195
         1 revision
 
196
         1 committer
168
197
         0 days old
169
198
   first revision: %s
170
199
  latest revision: %s
172
201
Repository:
173
202
         1 revision
174
203
         %d KiB
175
 
""" % (branch3.bzrdir.root_transport.base,
176
 
       branch1.bzrdir.root_transport.base,
177
 
       branch1.bzrdir.root_transport.base,
178
 
       bound_tree._format.get_format_description(),      
 
204
""" % (bound_tree._format.get_format_description(),
179
205
       branch3._format.get_format_description(),
180
206
       branch3.repository._format.get_format_description(),
181
207
       datestring_first, datestring_first,
191
217
            format=knit1_format)
192
218
        branch4.bind(branch1)
193
219
        branch4.bzrdir.open_workingtree().update()
194
 
        out, err = self.runbzr('info checkout --verbose')
 
220
        out, err = self.run_bzr('info checkout --verbose')
195
221
        self.assertEqualDiff(
196
 
"""Location:
197
 
       checkout root: %s
198
 
  checkout of branch: %s
 
222
"""Checkout (format: knit)
 
223
Location:
 
224
       checkout root: checkout
 
225
  checkout of branch: standalone
199
226
 
200
227
Format:
201
228
       control: Meta directory format 1
223
250
Repository:
224
251
         1 revision
225
252
         %d KiB
226
 
""" % (branch4.bzrdir.root_transport.base,
227
 
       branch1.bzrdir.root_transport.base,
228
 
       branch4.repository._format.get_format_description(),
 
253
""" % (branch4.repository._format.get_format_description(),
229
254
       datestring_first, datestring_first,
230
255
       # poking at _revision_store isn't all that clean, but neither is
231
256
       # having the ui test dependent on the exact overhead of a given store.
237
262
        # Lightweight checkout (same as above, different branch and repository)
238
263
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
239
264
        branch5 = tree5.branch
240
 
        out, err = self.runbzr('info lightcheckout')
 
265
        out, err = self.run_bzr('info -v lightcheckout')
241
266
        self.assertEqualDiff(
242
 
"""Location:
243
 
 light checkout root: %s
244
 
  checkout of branch: %s
 
267
"""Lightweight checkout (format: dirstate or dirstate-tags or \
 
268
pack-0.92 or rich-root or rich-root-pack)
 
269
Location:
 
270
  light checkout root: lightcheckout
 
271
   checkout of branch: standalone
245
272
 
246
273
Format:
247
274
       control: Meta directory format 1
261
288
 
262
289
Branch history:
263
290
         1 revision
 
291
         1 committer
264
292
         0 days old
265
293
   first revision: %s
266
294
  latest revision: %s
268
296
Repository:
269
297
         1 revision
270
298
         0 KiB
271
 
""" % (tree5.bzrdir.root_transport.base,
272
 
       branch1.bzrdir.root_transport.base,
273
 
       datestring_first, datestring_first,
274
 
       ), out)
 
299
""" % (datestring_first, datestring_first,), out)
275
300
        self.assertEqual('', err)
276
301
 
277
302
        # Update initial standalone branch
282
307
        datestring_last = format_date(rev.timestamp, rev.timezone)
283
308
 
284
309
        # Out of date branched standalone branch will not be detected
285
 
        out, err = self.runbzr('info branch')
 
310
        out, err = self.run_bzr('info -v branch')
286
311
        self.assertEqualDiff(
287
 
"""Location:
288
 
  branch root: %s
 
312
"""Standalone tree (format: weave)
 
313
Location:
 
314
  branch root: branch
289
315
 
290
316
Related branches:
291
 
      parent branch: %s
292
 
  publish to branch: %s
 
317
    push branch: standalone
 
318
  parent branch: standalone
293
319
 
294
320
Format:
295
321
       control: All-in-one format 6
309
335
 
310
336
Branch history:
311
337
         1 revision
 
338
         1 committer
312
339
         0 days old
313
340
   first revision: %s
314
341
  latest revision: %s
316
343
Repository:
317
344
         1 revision
318
345
         0 KiB
319
 
""" % (branch2.bzrdir.root_transport.base,
320
 
       branch1.bzrdir.root_transport.base,
321
 
       branch1.bzrdir.root_transport.base,
322
 
       datestring_first, datestring_first,
 
346
""" % (datestring_first, datestring_first,
323
347
       ), out)
324
348
        self.assertEqual('', err)
325
349
 
326
350
        # Out of date bound branch
327
 
        out, err = self.runbzr('info bound')
 
351
        out, err = self.run_bzr('info -v bound')
328
352
        self.assertEqualDiff(
329
 
"""Location:
330
 
       checkout root: %s
331
 
  checkout of branch: %s
 
353
"""Checkout (format: knit)
 
354
Location:
 
355
       checkout root: bound
 
356
  checkout of branch: standalone
332
357
 
333
358
Related branches:
334
 
  parent branch: %s
 
359
  parent branch: standalone
335
360
 
336
361
Format:
337
362
       control: Meta directory format 1
353
378
 
354
379
Branch history:
355
380
         1 revision
 
381
         1 committer
356
382
         0 days old
357
383
   first revision: %s
358
384
  latest revision: %s
360
386
Repository:
361
387
         1 revision
362
388
         %d KiB
363
 
""" % (branch3.bzrdir.root_transport.base,
364
 
       branch1.bzrdir.root_transport.base,
365
 
       branch1.bzrdir.root_transport.base,
366
 
       branch3.repository._format.get_format_description(),
 
389
""" % (branch3.repository._format.get_format_description(),
367
390
       datestring_first, datestring_first,
368
391
       # poking at _revision_store isn't all that clean, but neither is
369
392
       # having the ui test dependent on the exact overhead of a given store.
373
396
        self.assertEqual('', err)
374
397
 
375
398
        # Out of date checkout
376
 
        out, err = self.runbzr('info checkout')
 
399
        out, err = self.run_bzr('info -v checkout')
377
400
        self.assertEqualDiff(
378
 
"""Location:
379
 
       checkout root: %s
380
 
  checkout of branch: %s
 
401
"""Checkout (format: knit)
 
402
Location:
 
403
       checkout root: checkout
 
404
  checkout of branch: standalone
381
405
 
382
406
Format:
383
407
       control: Meta directory format 1
399
423
 
400
424
Branch history:
401
425
         1 revision
 
426
         1 committer
402
427
         0 days old
403
428
   first revision: %s
404
429
  latest revision: %s
406
431
Repository:
407
432
         1 revision
408
433
         %d KiB
409
 
""" % (branch4.bzrdir.root_transport.base,
410
 
       branch1.bzrdir.root_transport.base,
411
 
       branch4.repository._format.get_format_description(),
 
434
""" % (branch4.repository._format.get_format_description(),
412
435
       datestring_first, datestring_first,
413
436
       # poking at _revision_store isn't all that clean, but neither is
414
437
       # having the ui test dependent on the exact overhead of a given store.
418
441
        self.assertEqual('', err)
419
442
 
420
443
        # Out of date lightweight checkout
421
 
        out, err = self.runbzr('info lightcheckout --verbose')
 
444
        out, err = self.run_bzr('info lightcheckout --verbose')
422
445
        self.assertEqualDiff(
423
 
"""Location:
424
 
 light checkout root: %s
425
 
  checkout of branch: %s
 
446
"""Lightweight checkout (format: dirstate or dirstate-tags or \
 
447
pack-0.92 or rich-root or rich-root-pack)
 
448
Location:
 
449
  light checkout root: lightcheckout
 
450
   checkout of branch: standalone
426
451
 
427
452
Format:
428
453
       control: Meta directory format 1
452
477
Repository:
453
478
         2 revisions
454
479
         0 KiB
455
 
""" % (tree5.bzrdir.root_transport.base,
456
 
       branch1.bzrdir.root_transport.base,
457
 
       datestring_first, datestring_last,
458
 
       ), out)
 
480
""" % (datestring_first, datestring_last,), out)
459
481
        self.assertEqual('', err)
460
482
 
461
483
    def test_info_standalone_no_tree(self):
463
485
        format = bzrdir.format_registry.make_bzrdir('default')
464
486
        branch = self.make_branch('branch')
465
487
        repo = branch.repository
466
 
        out, err = self.runbzr('info branch')
 
488
        out, err = self.run_bzr('info branch -v')
467
489
        self.assertEqualDiff(
468
 
"""Location:
469
 
  branch root: %s
 
490
"""Standalone branch (format: %s)
 
491
Location:
 
492
  branch root: branch
470
493
 
471
494
Format:
472
495
       control: Meta directory format 1
475
498
 
476
499
Branch history:
477
500
         0 revisions
 
501
         0 committers
478
502
 
479
503
Repository:
480
504
         0 revisions
481
505
         0 KiB
482
 
""" % (branch.bzrdir.root_transport.base,
 
506
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
483
507
       format.get_branch_format().get_format_description(),
484
508
       format.repository_format.get_format_description(),
485
509
       ), out)
492
516
        # Create shared repository
493
517
        repo = self.make_repository('repo', shared=True, format=format)
494
518
        repo.set_make_working_trees(False)
495
 
        out, err = self.runbzr('info repo')
 
519
        out, err = self.run_bzr('info -v repo')
496
520
        self.assertEqualDiff(
497
 
"""Location:
 
521
"""Shared repository (format: dirstate or dirstate-tags or knit)
 
522
Location:
498
523
  shared repository: %s
499
524
 
500
525
Format:
504
529
Repository:
505
530
         0 revisions
506
531
         0 KiB
507
 
""" % (repo.bzrdir.root_transport.base,
508
 
       format.repository_format.get_format_description(),
 
532
""" % ('repo', format.repository_format.get_format_description(),
509
533
       ), out)
510
534
        self.assertEqual('', err)
511
535
 
513
537
        repo.bzrdir.root_transport.mkdir('branch')
514
538
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
515
539
            format=format)
516
 
        out, err = self.runbzr('info repo/branch')
 
540
        out, err = self.run_bzr('info -v repo/branch')
517
541
        self.assertEqualDiff(
518
 
"""Location:
519
 
  shared repository: %s
520
 
  repository branch: branch
 
542
"""Repository branch (format: dirstate or knit)
 
543
Location:
 
544
  shared repository: repo
 
545
  repository branch: repo/branch
521
546
 
522
547
Format:
523
548
       control: Meta directory format 1
526
551
 
527
552
Branch history:
528
553
         0 revisions
 
554
         0 committers
529
555
 
530
556
Repository:
531
557
         0 revisions
532
558
         0 KiB
533
 
""" % (repo.bzrdir.root_transport.base,
534
 
       format.get_branch_format().get_format_description(),
 
559
""" % (format.get_branch_format().get_format_description(),
535
560
       format.repository_format.get_format_description(),
536
561
       ), out)
537
562
        self.assertEqual('', err)
542
567
        tree2 = branch1.create_checkout('tree/lightcheckout', 
543
568
            lightweight=True)
544
569
        branch2 = tree2.branch
545
 
        self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, 
546
 
                   shared_repo=repo)
 
570
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
 
571
                   shared_repo=repo, repo_branch=branch1, verbose=True)
547
572
 
548
573
        # Create normal checkout
549
574
        tree3 = branch1.create_checkout('tree/checkout')
556
581
        tree2.commit('commit one')
557
582
        rev = repo.get_revision(branch2.revision_history()[0])
558
583
        datestring_first = format_date(rev.timestamp, rev.timezone)
559
 
        out, err = self.runbzr('info tree/lightcheckout --verbose')
 
584
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
560
585
        self.assertEqualDiff(
561
 
"""Location:
562
 
 light checkout root: %s
563
 
   shared repository: %s
564
 
   repository branch: branch
 
586
"""Lightweight checkout (format: dirstate or dirstate-tags or \
 
587
pack-0.92 or rich-root or rich-root-pack)
 
588
Location:
 
589
  light checkout root: tree/lightcheckout
 
590
   checkout of branch: repo/branch
 
591
    shared repository: repo
565
592
 
566
593
Format:
567
594
       control: Meta directory format 1
589
616
Repository:
590
617
         1 revision
591
618
         %d KiB
592
 
""" % (tree2.bzrdir.root_transport.base,
593
 
       repo.bzrdir.root_transport.base,
594
 
       format.get_branch_format().get_format_description(),
 
619
""" % (format.get_branch_format().get_format_description(),
595
620
       format.repository_format.get_format_description(),
596
621
       datestring_first, datestring_first,
597
622
       # poking at _revision_store isn't all that clean, but neither is
601
626
        self.assertEqual('', err)
602
627
 
603
628
        # Out of date checkout
604
 
        out, err = self.runbzr('info tree/checkout')
 
629
        out, err = self.run_bzr('info -v tree/checkout')
605
630
        self.assertEqualDiff(
606
 
"""Location:
607
 
       checkout root: %s
608
 
  checkout of branch: %s
 
631
"""Checkout (format: dirstate)
 
632
Location:
 
633
       checkout root: tree/checkout
 
634
  checkout of branch: repo/branch
609
635
 
610
636
Format:
611
637
       control: Meta directory format 1
627
653
 
628
654
Branch history:
629
655
         0 revisions
 
656
         0 committers
630
657
 
631
658
Repository:
632
659
         0 revisions
633
660
         0 KiB
634
 
""" % (tree3.bzrdir.root_transport.base,
635
 
       branch1.bzrdir.root_transport.base,
636
 
       format.get_branch_format().get_format_description(),
 
661
""" % (format.get_branch_format().get_format_description(),
637
662
       format.repository_format.get_format_description(),
638
663
       ), out)
639
664
        self.assertEqual('', err)
642
667
        tree3.update()
643
668
        self.build_tree(['tree/checkout/b'])
644
669
        tree3.add('b')
645
 
        out, err = self.runbzr('info tree/checkout --verbose')
 
670
        out, err = self.run_bzr('info tree/checkout --verbose')
646
671
        self.assertEqualDiff(
647
 
"""Location:
648
 
       checkout root: %s
649
 
  checkout of branch: %s
 
672
"""Checkout (format: dirstate)
 
673
Location:
 
674
       checkout root: tree/checkout
 
675
  checkout of branch: repo/branch
650
676
 
651
677
Format:
652
678
       control: Meta directory format 1
674
700
Repository:
675
701
         1 revision
676
702
         %d KiB
677
 
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
678
 
       format.get_branch_format().get_format_description(),
 
703
""" % (format.get_branch_format().get_format_description(),
679
704
       format.repository_format.get_format_description(),
680
705
       datestring_first, datestring_first,
681
706
       # poking at _revision_store isn't all that clean, but neither is
688
713
        # Out of date lightweight checkout
689
714
        rev = repo.get_revision(branch1.revision_history()[-1])
690
715
        datestring_last = format_date(rev.timestamp, rev.timezone)
691
 
        out, err = self.runbzr('info tree/lightcheckout --verbose')
 
716
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
692
717
        self.assertEqualDiff(
693
 
"""Location:
694
 
 light checkout root: %s
695
 
   shared repository: %s
696
 
   repository branch: branch
 
718
"""Lightweight checkout (format: dirstate or dirstate-tags or \
 
719
pack-0.92 or rich-root or rich-root-pack)
 
720
Location:
 
721
  light checkout root: tree/lightcheckout
 
722
   checkout of branch: repo/branch
 
723
    shared repository: repo
697
724
 
698
725
Format:
699
726
       control: Meta directory format 1
723
750
Repository:
724
751
         2 revisions
725
752
         %d KiB
726
 
""" % (tree2.bzrdir.root_transport.base,
727
 
       repo.bzrdir.root_transport.base,
728
 
       format.get_branch_format().get_format_description(),
 
753
""" % (format.get_branch_format().get_format_description(),
729
754
       format.repository_format.get_format_description(),
730
755
       datestring_first, datestring_last,
731
756
       # poking at _revision_store isn't all that clean, but neither is
735
760
        self.assertEqual('', err)
736
761
 
737
762
        # Show info about shared branch
738
 
        out, err = self.runbzr('info repo/branch --verbose')
 
763
        out, err = self.run_bzr('info repo/branch --verbose')
739
764
        self.assertEqualDiff(
740
 
"""Location:
741
 
  shared repository: %s
742
 
  repository branch: branch
 
765
"""Repository branch (format: dirstate or knit)
 
766
Location:
 
767
  shared repository: repo
 
768
  repository branch: repo/branch
743
769
 
744
770
Format:
745
771
       control: Meta directory format 1
756
782
Repository:
757
783
         2 revisions
758
784
         %d KiB
759
 
""" % (repo.bzrdir.root_transport.base,
760
 
       format.get_branch_format().get_format_description(),
 
785
""" % (format.get_branch_format().get_format_description(),
761
786
       format.repository_format.get_format_description(),
762
787
       datestring_first, datestring_last,
763
788
       # poking at _revision_store isn't all that clean, but neither is
767
792
        self.assertEqual('', err)
768
793
 
769
794
        # Show info about repository with revisions
770
 
        out, err = self.runbzr('info repo')
 
795
        out, err = self.run_bzr('info -v repo')
771
796
        self.assertEqualDiff(
772
 
"""Location:
773
 
  shared repository: %s
 
797
"""Shared repository (format: dirstate or dirstate-tags or knit)
 
798
Location:
 
799
  shared repository: repo
774
800
 
775
801
Format:
776
802
       control: Meta directory format 1
779
805
Repository:
780
806
         2 revisions
781
807
         %d KiB
782
 
""" % (repo.bzrdir.root_transport.base,
783
 
       format.repository_format.get_format_description(),
 
808
""" % (format.repository_format.get_format_description(),
784
809
       # poking at _revision_store isn't all that clean, but neither is
785
810
       # having the ui test dependent on the exact overhead of a given store.
786
811
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
794
819
        # Create shared repository with working trees
795
820
        repo = self.make_repository('repo', shared=True, format=format)
796
821
        repo.set_make_working_trees(True)
797
 
        out, err = self.runbzr('info repo')
 
822
        out, err = self.run_bzr('info -v repo')
798
823
        self.assertEqualDiff(
799
 
"""Location:
800
 
  shared repository: %s
 
824
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
825
Location:
 
826
  shared repository: repo
801
827
 
802
828
Format:
803
829
       control: Meta directory format 1
808
834
Repository:
809
835
         0 revisions
810
836
         0 KiB
811
 
""" % (repo.bzrdir.root_transport.base,
812
 
       format.repository_format.get_format_description(),
 
837
""" % (format.repository_format.get_format_description(),
813
838
       ), out)
814
839
        self.assertEqual('', err)
815
840
 
820
845
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
821
846
 
822
847
        # Empty first branch
823
 
        out, err = self.runbzr('info repo/branch1 --verbose')
 
848
        out, err = self.run_bzr('info repo/branch1 --verbose')
824
849
        self.assertEqualDiff(
825
 
"""Location:
826
 
    shared repository: %s
827
 
  repository checkout: branch1
 
850
"""Repository tree (format: knit)
 
851
Location:
 
852
  shared repository: repo
 
853
  repository branch: repo/branch1
828
854
 
829
855
Format:
830
856
       control: Meta directory format 1
849
875
Repository:
850
876
         0 revisions
851
877
         0 KiB
852
 
""" % (repo.bzrdir.root_transport.base,
853
 
       format.get_branch_format().get_format_description(),
 
878
""" % (format.get_branch_format().get_format_description(),
854
879
       format.repository_format.get_format_description(),
855
880
       ), out)
856
881
        self.assertEqual('', err)
862
887
        tree1.commit('commit one')
863
888
        rev = repo.get_revision(branch1.revision_history()[0])
864
889
        datestring_first = format_date(rev.timestamp, rev.timezone)
865
 
        out, err = self.runbzr('info repo/branch1')
 
890
        out, err = self.run_bzr('info -v repo/branch1')
866
891
        self.assertEqualDiff(
867
 
"""Location:
868
 
    shared repository: %s
869
 
  repository checkout: branch1
 
892
"""Repository tree (format: knit)
 
893
Location:
 
894
  shared repository: repo
 
895
  repository branch: repo/branch1
870
896
 
871
897
Format:
872
898
       control: Meta directory format 1
886
912
 
887
913
Branch history:
888
914
         1 revision
 
915
         1 committer
889
916
         0 days old
890
917
   first revision: %s
891
918
  latest revision: %s
893
920
Repository:
894
921
         1 revision
895
922
         %d KiB
896
 
""" % (repo.bzrdir.root_transport.base,
897
 
       format.get_branch_format().get_format_description(),
 
923
""" % (format.get_branch_format().get_format_description(),
898
924
       format.repository_format.get_format_description(),
899
925
       datestring_first, datestring_first,
900
926
       # poking at _revision_store isn't all that clean, but neither is
904
930
        self.assertEqual('', err)
905
931
 
906
932
        # Out of date second branch
907
 
        out, err = self.runbzr('info repo/branch2 --verbose')
 
933
        out, err = self.run_bzr('info repo/branch2 --verbose')
908
934
        self.assertEqualDiff(
909
 
"""Location:
910
 
    shared repository: %s
911
 
  repository checkout: branch2
 
935
"""Repository tree (format: knit)
 
936
Location:
 
937
  shared repository: repo
 
938
  repository branch: repo/branch2
912
939
 
913
940
Related branches:
914
 
  parent branch: %s
 
941
  parent branch: repo/branch1
915
942
 
916
943
Format:
917
944
       control: Meta directory format 1
936
963
Repository:
937
964
         1 revision
938
965
         %d KiB
939
 
""" % (repo.bzrdir.root_transport.base,
940
 
       branch1.bzrdir.root_transport.base,
941
 
       format.get_branch_format().get_format_description(),
 
966
""" % (format.get_branch_format().get_format_description(),
942
967
       format.repository_format.get_format_description(),
943
968
       # poking at _revision_store isn't all that clean, but neither is
944
969
       # having the ui test dependent on the exact overhead of a given store.
949
974
        # Update second branch
950
975
        tree2 = branch2.bzrdir.open_workingtree()
951
976
        tree2.pull(branch1)
952
 
        out, err = self.runbzr('info repo/branch2')
 
977
        out, err = self.run_bzr('info -v repo/branch2')
953
978
        self.assertEqualDiff(
954
 
"""Location:
955
 
    shared repository: %s
956
 
  repository checkout: branch2
 
979
"""Repository tree (format: knit)
 
980
Location:
 
981
  shared repository: repo
 
982
  repository branch: repo/branch2
957
983
 
958
984
Related branches:
959
 
  parent branch: %s
 
985
  parent branch: repo/branch1
960
986
 
961
987
Format:
962
988
       control: Meta directory format 1
976
1002
 
977
1003
Branch history:
978
1004
         1 revision
 
1005
         1 committer
979
1006
         0 days old
980
1007
   first revision: %s
981
1008
  latest revision: %s
983
1010
Repository:
984
1011
         1 revision
985
1012
         %d KiB
986
 
""" % (repo.bzrdir.root_transport.base,
987
 
       branch1.bzrdir.root_transport.base,
988
 
       format.get_branch_format().get_format_description(),
 
1013
""" % (format.get_branch_format().get_format_description(),
989
1014
       format.repository_format.get_format_description(),
990
1015
       datestring_first, datestring_first,
991
1016
       # poking at _revision_store isn't all that clean, but neither is
995
1020
        self.assertEqual('', err)
996
1021
 
997
1022
        # Show info about repository with revisions
998
 
        out, err = self.runbzr('info repo')
 
1023
        out, err = self.run_bzr('info -v repo')
999
1024
        self.assertEqualDiff(
1000
 
"""Location:
1001
 
  shared repository: %s
 
1025
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
1026
Location:
 
1027
  shared repository: repo
1002
1028
 
1003
1029
Format:
1004
1030
       control: Meta directory format 1
1009
1035
Repository:
1010
1036
         1 revision
1011
1037
         %d KiB
1012
 
""" % (repo.bzrdir.root_transport.base,
1013
 
       format.repository_format.get_format_description(),
 
1038
""" % (format.repository_format.get_format_description(),
1014
1039
       # poking at _revision_store isn't all that clean, but neither is
1015
1040
       # having the ui test dependent on the exact overhead of a given store.
1016
1041
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1025
1050
        # Create shared repository with working trees
1026
1051
        repo = self.make_repository('repo', shared=True, format=format)
1027
1052
        repo.set_make_working_trees(True)
1028
 
        out, err = self.runbzr('info repo')
 
1053
        out, err = self.run_bzr('info -v repo')
1029
1054
        self.assertEqualDiff(
1030
 
"""Location:
1031
 
  shared repository: %s
 
1055
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
1056
Location:
 
1057
  shared repository: repo
1032
1058
 
1033
1059
Format:
1034
1060
       control: Meta directory format 1
1039
1065
Repository:
1040
1066
         0 revisions
1041
1067
         0 KiB
1042
 
""" % (repo.bzrdir.root_transport.base,
1043
 
       format.repository_format.get_format_description(),
 
1068
""" % (format.repository_format.get_format_description(),
1044
1069
       ), out)
1045
1070
        self.assertEqual('', err)
1046
1071
 
1048
1073
        control = repo.bzrdir
1049
1074
        branch = control.create_branch()
1050
1075
        control.create_workingtree()
1051
 
        out, err = self.runbzr('info repo')
 
1076
        out, err = self.run_bzr('info -v repo')
1052
1077
        self.assertEqualDiff(
1053
 
"""Location:
1054
 
    shared repository: %s
1055
 
  repository checkout: .
 
1078
"""Repository tree (format: knit)
 
1079
Location:
 
1080
  shared repository: repo
 
1081
  repository branch: repo
1056
1082
 
1057
1083
Format:
1058
1084
       control: Meta directory format 1
1072
1098
 
1073
1099
Branch history:
1074
1100
         0 revisions
 
1101
         0 committers
1075
1102
 
1076
1103
Repository:
1077
1104
         0 revisions
1078
1105
         0 KiB
1079
 
""" % (repo.bzrdir.root_transport.base,
1080
 
       format.get_branch_format().get_format_description(),
 
1106
""" % (format.get_branch_format().get_format_description(),
1081
1107
       format.repository_format.get_format_description(),
1082
1108
       ), out)
1083
1109
        self.assertEqual('', err)
1084
1110
 
1085
 
    def assertCheckoutStatusOutput(self, 
 
1111
    def assertCheckoutStatusOutput(self,
1086
1112
        command_string, lco_tree, shared_repo=None,
1087
1113
        repo_branch=None,
1088
1114
        tree_locked=False,
1089
1115
        branch_locked=False, repo_locked=False,
1090
1116
        verbose=False,
1091
 
        light_checkout=True):
1092
 
        """Check the output of info in a light checkout tree.
 
1117
        light_checkout=True,
 
1118
        checkout_root=None):
 
1119
        """Check the output of info in a checkout.
1093
1120
 
1094
1121
        This is not quite a mirror of the info code: rather than using the
1095
1122
        tree being examined to predict output, it uses a bunch of flags which
1106
1133
        :param tree_locked: If true, expect the tree to be locked.
1107
1134
        :param branch_locked: If true, expect the branch to be locked.
1108
1135
        :param repo_locked: If true, expect the repository to be locked.
 
1136
            Note that the lco_tree.branch.repository is inspected, and if is not
 
1137
            actually locked then this parameter is overridden. This is because
 
1138
            pack repositories do not have any public API for obtaining an
 
1139
            exclusive repository wide lock.
1109
1140
        :param verbose: If true, expect verbose output
1110
1141
        """
1111
 
        if tree_locked and sys.platform == 'win32':
1112
 
            # We expect this to fail because of locking errors. (A write-locked
1113
 
            # file cannot be read-locked in the same process).
 
1142
        def friendly_location(url):
 
1143
            path = urlutils.unescape_for_display(url, 'ascii')
 
1144
            try:
 
1145
                return osutils.relpath(osutils.getcwd(), path)
 
1146
            except errors.PathNotChild:
 
1147
                return path
 
1148
 
 
1149
        if tree_locked:
 
1150
            # We expect this to fail because of locking errors.
 
1151
            # (A write-locked file cannot be read-locked
 
1152
            # in the different process -- either on win32 or on linux).
1114
1153
            # This should be removed when the locking errors are fixed.
1115
 
            args = command_string.split(' ')
1116
 
            self.run_bzr_error([], 'info', *args)
1117
 
            return
1118
 
        out, err = self.runbzr('info %s' % command_string)
 
1154
            self.expectFailure('OS locks are exclusive '
 
1155
                'for different processes (Bug #174055)',
 
1156
                self.run_bzr_subprocess,
 
1157
                'info ' + command_string)
 
1158
        out, err = self.run_bzr('info %s' % command_string)
 
1159
        description = {
 
1160
            (True, True): 'Lightweight checkout',
 
1161
            (True, False): 'Repository checkout',
 
1162
            (False, True): 'Lightweight checkout',
 
1163
            (False, False): 'Checkout',
 
1164
            }[(shared_repo is not None, light_checkout)]
 
1165
        format = {True: 'dirstate or dirstate-tags or pack-0.92'
 
1166
                        ' or rich-root or rich-root-pack',
 
1167
                  False: 'dirstate'}[light_checkout]
 
1168
        if repo_locked:
 
1169
            repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1119
1170
        if repo_locked or branch_locked or tree_locked:
1120
1171
            def locked_message(a_bool):
1121
1172
                if a_bool:
1133
1184
                    locked_message(repo_locked)))
1134
1185
        else:
1135
1186
            expected_lock_output = ''
 
1187
        tree_data = ''
 
1188
        extra_space = ''
1136
1189
        if light_checkout:
1137
 
            tree_data = (" light checkout root: %s" %
1138
 
                lco_tree.bzrdir.root_transport.base)
1139
 
        else:
1140
 
            tree_data = ("       checkout root: %s" %
1141
 
                lco_tree.bzrdir.root_transport.base)
 
1190
            tree_data = ("  light checkout root: %s\n" %
 
1191
                friendly_location(lco_tree.bzrdir.root_transport.base))
 
1192
            extra_space = ' '
 
1193
        if lco_tree.branch.get_bound_location() is not None:
 
1194
            tree_data += ("%s       checkout root: %s\n" % (extra_space,
 
1195
                friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1142
1196
        if shared_repo is not None:
1143
1197
            branch_data = (
1144
 
                "   shared repository: %s\n"
1145
 
                "   repository branch: branch\n" %
1146
 
                shared_repo.bzrdir.root_transport.base)
 
1198
                "   checkout of branch: %s\n"
 
1199
                "    shared repository: %s\n" %
 
1200
                (friendly_location(repo_branch.bzrdir.root_transport.base),
 
1201
                 friendly_location(shared_repo.bzrdir.root_transport.base)))
1147
1202
        elif repo_branch is not None:
1148
1203
            branch_data = (
1149
 
                "  checkout of branch: %s\n" % 
1150
 
                repo_branch.bzrdir.root_transport.base)
 
1204
                "%s  checkout of branch: %s\n" %
 
1205
                (extra_space,
 
1206
                 friendly_location(repo_branch.bzrdir.root_transport.base)))
1151
1207
        else:
1152
 
            branch_data = ("  checkout of branch: %s\n" % 
 
1208
            branch_data = ("   checkout of branch: %s\n" %
1153
1209
                lco_tree.branch.bzrdir.root_transport.base)
1154
1210
        
1155
1211
        if verbose:
1158
1214
            verbose_info = ''
1159
1215
            
1160
1216
        self.assertEqualDiff(
1161
 
"""Location:
1162
 
%s
1163
 
%s
 
1217
"""%s (format: %s)
 
1218
Location:
 
1219
%s%s
1164
1220
Format:
1165
1221
       control: Meta directory format 1
1166
1222
  working tree: %s
1183
1239
Repository:
1184
1240
         0 revisions
1185
1241
         0 KiB
1186
 
""" %  (tree_data,
 
1242
""" %  (description,
 
1243
        format,
 
1244
        tree_data,
1187
1245
        branch_data,
1188
1246
        lco_tree._format.get_format_description(),
1189
1247
        lco_tree.branch._format.get_format_description(),
1219
1277
        # W B R
1220
1278
 
1221
1279
        # U U U
1222
 
        self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
 
1280
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
 
1281
                                        repo_branch=repo_branch,
 
1282
                                        verbose=True, light_checkout=True)
1223
1283
        # U U L
1224
1284
        lco_tree.branch.repository.lock_write()
1225
1285
        try:
1226
 
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1227
 
            lco_tree,
1228
 
            repo_locked=True)
 
1286
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1287
            lco_tree, repo_branch=repo_branch,
 
1288
            repo_locked=True, verbose=True, light_checkout=True)
1229
1289
        finally:
1230
1290
            lco_tree.branch.repository.unlock()
1231
1291
        # U L L
1232
1292
        lco_tree.branch.lock_write()
1233
1293
        try:
1234
 
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1294
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1235
1295
            lco_tree,
1236
1296
            branch_locked=True,
1237
 
            repo_locked=True)
 
1297
            repo_locked=True,
 
1298
            repo_branch=repo_branch,
 
1299
            verbose=True)
1238
1300
        finally:
1239
1301
            lco_tree.branch.unlock()
1240
1302
        # L L L
1241
1303
        lco_tree.lock_write()
1242
1304
        try:
1243
 
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1244
 
            lco_tree,
 
1305
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1306
            lco_tree, repo_branch=repo_branch,
1245
1307
            tree_locked=True,
1246
1308
            branch_locked=True,
1247
 
            repo_locked=True)
 
1309
            repo_locked=True,
 
1310
            verbose=True)
1248
1311
        finally:
1249
1312
            lco_tree.unlock()
1250
1313
        # L L U
1251
1314
        lco_tree.lock_write()
1252
1315
        lco_tree.branch.repository.unlock()
1253
1316
        try:
1254
 
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1255
 
            lco_tree,
 
1317
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1318
            lco_tree, repo_branch=repo_branch,
1256
1319
            tree_locked=True,
1257
 
            branch_locked=True)
 
1320
            branch_locked=True,
 
1321
            verbose=True)
1258
1322
        finally:
1259
1323
            lco_tree.branch.repository.lock_write()
1260
1324
            lco_tree.unlock()
1262
1326
        lco_tree.lock_write()
1263
1327
        lco_tree.branch.unlock()
1264
1328
        try:
1265
 
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1266
 
            lco_tree,
1267
 
            tree_locked=True)
 
1329
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1330
            lco_tree, repo_branch=repo_branch,
 
1331
            tree_locked=True,
 
1332
            verbose=True)
1268
1333
        finally:
1269
1334
            lco_tree.branch.lock_write()
1270
1335
            lco_tree.unlock()
1273
1338
        lco_tree.branch.unlock()
1274
1339
        lco_tree.branch.repository.lock_write()
1275
1340
        try:
1276
 
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1277
 
            lco_tree,
 
1341
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1342
            lco_tree, repo_branch=repo_branch,
1278
1343
            tree_locked=True,
1279
 
            repo_locked=True)
 
1344
            repo_locked=True,
 
1345
            verbose=True)
1280
1346
        finally:
1281
1347
            lco_tree.branch.repository.unlock()
1282
1348
            lco_tree.branch.lock_write()
1285
1351
        lco_tree.branch.lock_write()
1286
1352
        lco_tree.branch.repository.unlock()
1287
1353
        try:
1288
 
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1289
 
            lco_tree,
1290
 
            branch_locked=True)
 
1354
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1355
            lco_tree, repo_branch=repo_branch,
 
1356
            branch_locked=True,
 
1357
            verbose=True)
1291
1358
        finally:
1292
1359
            lco_tree.branch.repository.lock_write()
1293
1360
            lco_tree.branch.unlock()
1310
1377
        # W B R
1311
1378
 
1312
1379
        # U U U
1313
 
        out, err = self.runbzr('info branch')
 
1380
        out, err = self.run_bzr('info -v branch')
1314
1381
        self.assertEqualDiff(
1315
 
"""Location:
 
1382
"""Standalone tree (format: weave)
 
1383
Location:
1316
1384
  branch root: %s
1317
1385
 
1318
1386
Format:
1333
1401
 
1334
1402
Branch history:
1335
1403
         0 revisions
 
1404
         0 committers
1336
1405
 
1337
1406
Repository:
1338
1407
         0 revisions
1339
1408
         0 KiB
1340
 
""" % (tree.bzrdir.root_transport.base,
1341
 
       tree.branch.repository._format.get_format_description(),
 
1409
""" % ('branch', tree.branch.repository._format.get_format_description(),
1342
1410
       ), out)
1343
1411
        self.assertEqual('', err)
1344
1412
        # L L L
1345
1413
        tree.lock_write()
1346
 
        out, err = self.runbzr('info branch')
 
1414
        out, err = self.run_bzr('info -v branch')
1347
1415
        self.assertEqualDiff(
1348
 
"""Location:
 
1416
"""Standalone tree (format: weave)
 
1417
Location:
1349
1418
  branch root: %s
1350
1419
 
1351
1420
Format:
1366
1435
 
1367
1436
Branch history:
1368
1437
         0 revisions
 
1438
         0 committers
1369
1439
 
1370
1440
Repository:
1371
1441
         0 revisions
1372
1442
         0 KiB
1373
 
""" % (tree.bzrdir.root_transport.base,
1374
 
       tree.branch.repository._format.get_format_description(),
 
1443
""" % ('branch', tree.branch.repository._format.get_format_description(),
1375
1444
       ), out)
1376
1445
        self.assertEqual('', err)
1377
1446
        tree.unlock()