~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2007-05-04 18:59:36 UTC
  • mto: This revision was merged to the branch mainline in revision 2643.
  • Revision ID: john@arbash-meinel.com-20070504185936-1mjdoqmtz74xe5mg
A C implementation of _fields_to_entry_0_parents drops the time from 400ms to 330ms for a 21k-entry tree

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