~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-03-14 20:47:17 UTC
  • mto: (2353.4.2 locking)
  • mto: This revision was merged to the branch mainline in revision 2360.
  • Revision ID: john@arbash-meinel.com-20070314204717-htynwogv97fqr22a
Cleanup errors, and change ReadOnlyLockError to pass around more details.

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
 
    osutils,
27
25
    repository,
28
 
    urlutils,
29
26
    )
30
27
from bzrlib.osutils import format_date
31
28
from bzrlib.tests import TestSkipped
39
36
            location = "C:/i/do/not/exist/"
40
37
        else:
41
38
            location = "/i/do/not/exist/"
42
 
        out, err = self.run_bzr('info '+location, retcode=3)
 
39
        out, err = self.runbzr('info '+location, retcode=3)
43
40
        self.assertEqual(out, '')
44
41
        self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
45
42
 
51
48
        self.build_tree(['standalone/a'])
52
49
        tree1.add('a')
53
50
        branch1 = tree1.branch
54
 
 
55
 
        out, err = self.run_bzr('info standalone')
56
 
        self.assertEqualDiff(
57
 
"""Standalone tree (format: weave)
58
 
Location:
59
 
  branch root: standalone
60
 
""", out)
61
 
        self.assertEqual('', err)
62
 
 
63
 
        out, err = self.run_bzr('info standalone -v')
64
 
        self.assertEqualDiff(
65
 
"""Standalone tree (format: weave)
66
 
Location:
67
 
  branch root: standalone
 
51
        out, err = self.runbzr('info standalone')
 
52
        self.assertEqualDiff(
 
53
"""Location:
 
54
  branch root: %s
68
55
 
69
56
Format:
70
57
       control: All-in-one format 6
84
71
 
85
72
Branch history:
86
73
         0 revisions
87
 
         0 committers
88
74
 
89
 
Repository:
 
75
Revision store:
90
76
         0 revisions
91
77
         0 KiB
92
 
""", out)
 
78
""" % branch1.bzrdir.root_transport.base, out)
93
79
        self.assertEqual('', err)
94
80
        tree1.commit('commit one')
95
81
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
98
84
        # Branch standalone with push location
99
85
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
100
86
        branch2.set_push_location(branch1.bzrdir.root_transport.base)
101
 
 
102
 
        out, err = self.run_bzr('info branch')
103
 
        self.assertEqualDiff(
104
 
"""Standalone tree (format: weave)
105
 
Location:
106
 
  branch root: branch
107
 
 
108
 
Related branches:
109
 
    push branch: standalone
110
 
  parent branch: standalone
111
 
""", out)
112
 
        self.assertEqual('', err)
113
 
 
114
 
        out, err = self.run_bzr('info branch --verbose')
115
 
        self.assertEqualDiff(
116
 
"""Standalone tree (format: weave)
117
 
Location:
118
 
  branch root: branch
119
 
 
120
 
Related branches:
121
 
    push branch: standalone
122
 
  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
123
95
 
124
96
Format:
125
97
       control: All-in-one format 6
144
116
   first revision: %s
145
117
  latest revision: %s
146
118
 
147
 
Repository:
 
119
Revision store:
148
120
         1 revision
149
121
         %d KiB
150
 
""" % (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,
151
126
       # poking at _revision_store isn't all that clean, but neither is
152
127
       # having the ui test dependent on the exact overhead of a given store.
153
128
       branch2.repository._revision_store.total_size(
163
138
        branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
164
139
        branch3.bind(branch1)
165
140
        bound_tree = branch3.bzrdir.open_workingtree()
166
 
        out, err = self.run_bzr('info -v bound')
 
141
        out, err = self.runbzr('info bound')
167
142
        self.assertEqualDiff(
168
 
"""Checkout (format: knit)
169
 
Location:
170
 
       checkout root: bound
171
 
  checkout of branch: standalone
 
143
"""Location:
 
144
       checkout root: %s
 
145
  checkout of branch: %s
172
146
 
173
147
Related branches:
174
 
  parent branch: standalone
 
148
  parent branch: %s
175
149
 
176
150
Format:
177
151
       control: Meta directory format 1
191
165
 
192
166
Branch history:
193
167
         1 revision
194
 
         1 committer
195
168
         0 days old
196
169
   first revision: %s
197
170
  latest revision: %s
198
171
 
199
 
Repository:
 
172
Revision store:
200
173
         1 revision
201
174
         %d KiB
202
 
""" % (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(),      
203
179
       branch3._format.get_format_description(),
204
180
       branch3.repository._format.get_format_description(),
205
181
       datestring_first, datestring_first,
215
191
            format=knit1_format)
216
192
        branch4.bind(branch1)
217
193
        branch4.bzrdir.open_workingtree().update()
218
 
        out, err = self.run_bzr('info checkout --verbose')
 
194
        out, err = self.runbzr('info checkout --verbose')
219
195
        self.assertEqualDiff(
220
 
"""Checkout (format: knit)
221
 
Location:
222
 
       checkout root: checkout
223
 
  checkout of branch: standalone
 
196
"""Location:
 
197
       checkout root: %s
 
198
  checkout of branch: %s
224
199
 
225
200
Format:
226
201
       control: Meta directory format 1
245
220
   first revision: %s
246
221
  latest revision: %s
247
222
 
248
 
Repository:
 
223
Revision store:
249
224
         1 revision
250
225
         %d KiB
251
 
""" % (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(),
252
229
       datestring_first, datestring_first,
253
230
       # poking at _revision_store isn't all that clean, but neither is
254
231
       # having the ui test dependent on the exact overhead of a given store.
260
237
        # Lightweight checkout (same as above, different branch and repository)
261
238
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
262
239
        branch5 = tree5.branch
263
 
        out, err = self.run_bzr('info -v lightcheckout')
 
240
        out, err = self.runbzr('info lightcheckout')
264
241
        self.assertEqualDiff(
265
 
"""Lightweight checkout (format: dirstate or dirstate-tags)
266
 
Location:
267
 
  light checkout root: lightcheckout
268
 
   checkout of branch: standalone
 
242
"""Location:
 
243
 light checkout root: %s
 
244
  checkout of branch: %s
269
245
 
270
246
Format:
271
247
       control: Meta directory format 1
285
261
 
286
262
Branch history:
287
263
         1 revision
288
 
         1 committer
289
264
         0 days old
290
265
   first revision: %s
291
266
  latest revision: %s
292
267
 
293
 
Repository:
 
268
Revision store:
294
269
         1 revision
295
270
         0 KiB
296
 
""" % (datestring_first, datestring_first,), out)
 
271
""" % (tree5.bzrdir.root_transport.base,
 
272
       branch1.bzrdir.root_transport.base,
 
273
       datestring_first, datestring_first,
 
274
       ), out)
297
275
        self.assertEqual('', err)
298
276
 
299
277
        # Update initial standalone branch
304
282
        datestring_last = format_date(rev.timestamp, rev.timezone)
305
283
 
306
284
        # Out of date branched standalone branch will not be detected
307
 
        out, err = self.run_bzr('info -v branch')
 
285
        out, err = self.runbzr('info branch')
308
286
        self.assertEqualDiff(
309
 
"""Standalone tree (format: weave)
310
 
Location:
311
 
  branch root: branch
 
287
"""Location:
 
288
  branch root: %s
312
289
 
313
290
Related branches:
314
 
    push branch: standalone
315
 
  parent branch: standalone
 
291
      parent branch: %s
 
292
  publish to branch: %s
316
293
 
317
294
Format:
318
295
       control: All-in-one format 6
332
309
 
333
310
Branch history:
334
311
         1 revision
335
 
         1 committer
336
312
         0 days old
337
313
   first revision: %s
338
314
  latest revision: %s
339
315
 
340
 
Repository:
 
316
Revision store:
341
317
         1 revision
342
318
         0 KiB
343
 
""" % (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,
344
323
       ), out)
345
324
        self.assertEqual('', err)
346
325
 
347
326
        # Out of date bound branch
348
 
        out, err = self.run_bzr('info -v bound')
 
327
        out, err = self.runbzr('info bound')
349
328
        self.assertEqualDiff(
350
 
"""Checkout (format: knit)
351
 
Location:
352
 
       checkout root: bound
353
 
  checkout of branch: standalone
 
329
"""Location:
 
330
       checkout root: %s
 
331
  checkout of branch: %s
354
332
 
355
333
Related branches:
356
 
  parent branch: standalone
 
334
  parent branch: %s
357
335
 
358
336
Format:
359
337
       control: Meta directory format 1
375
353
 
376
354
Branch history:
377
355
         1 revision
378
 
         1 committer
379
356
         0 days old
380
357
   first revision: %s
381
358
  latest revision: %s
382
359
 
383
 
Repository:
 
360
Revision store:
384
361
         1 revision
385
362
         %d KiB
386
 
""" % (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(),
387
367
       datestring_first, datestring_first,
388
368
       # poking at _revision_store isn't all that clean, but neither is
389
369
       # having the ui test dependent on the exact overhead of a given store.
393
373
        self.assertEqual('', err)
394
374
 
395
375
        # Out of date checkout
396
 
        out, err = self.run_bzr('info -v checkout')
 
376
        out, err = self.runbzr('info checkout')
397
377
        self.assertEqualDiff(
398
 
"""Checkout (format: knit)
399
 
Location:
400
 
       checkout root: checkout
401
 
  checkout of branch: standalone
 
378
"""Location:
 
379
       checkout root: %s
 
380
  checkout of branch: %s
402
381
 
403
382
Format:
404
383
       control: Meta directory format 1
420
399
 
421
400
Branch history:
422
401
         1 revision
423
 
         1 committer
424
402
         0 days old
425
403
   first revision: %s
426
404
  latest revision: %s
427
405
 
428
 
Repository:
 
406
Revision store:
429
407
         1 revision
430
408
         %d KiB
431
 
""" % (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(),
432
412
       datestring_first, datestring_first,
433
413
       # poking at _revision_store isn't all that clean, but neither is
434
414
       # having the ui test dependent on the exact overhead of a given store.
438
418
        self.assertEqual('', err)
439
419
 
440
420
        # Out of date lightweight checkout
441
 
        out, err = self.run_bzr('info lightcheckout --verbose')
 
421
        out, err = self.runbzr('info lightcheckout --verbose')
442
422
        self.assertEqualDiff(
443
 
"""Lightweight checkout (format: dirstate or dirstate-tags)
444
 
Location:
445
 
  light checkout root: lightcheckout
446
 
   checkout of branch: standalone
 
423
"""Location:
 
424
 light checkout root: %s
 
425
  checkout of branch: %s
447
426
 
448
427
Format:
449
428
       control: Meta directory format 1
470
449
   first revision: %s
471
450
  latest revision: %s
472
451
 
473
 
Repository:
 
452
Revision store:
474
453
         2 revisions
475
454
         0 KiB
476
 
""" % (datestring_first, datestring_last,), out)
 
455
""" % (tree5.bzrdir.root_transport.base,
 
456
       branch1.bzrdir.root_transport.base,
 
457
       datestring_first, datestring_last,
 
458
       ), out)
477
459
        self.assertEqual('', err)
478
460
 
479
461
    def test_info_standalone_no_tree(self):
481
463
        format = bzrdir.format_registry.make_bzrdir('default')
482
464
        branch = self.make_branch('branch')
483
465
        repo = branch.repository
484
 
        out, err = self.run_bzr('info branch -v')
 
466
        out, err = self.runbzr('info branch')
485
467
        self.assertEqualDiff(
486
 
"""Standalone branch (format: dirstate or knit)
487
 
Location:
488
 
  branch root: branch
 
468
"""Location:
 
469
  branch root: %s
489
470
 
490
471
Format:
491
472
       control: Meta directory format 1
494
475
 
495
476
Branch history:
496
477
         0 revisions
497
 
         0 committers
498
478
 
499
 
Repository:
 
479
Revision store:
500
480
         0 revisions
501
481
         0 KiB
502
 
""" % (format.get_branch_format().get_format_description(),
 
482
""" % (branch.bzrdir.root_transport.base,
 
483
       format.get_branch_format().get_format_description(),
503
484
       format.repository_format.get_format_description(),
504
485
       ), out)
505
486
        self.assertEqual('', err)
511
492
        # Create shared repository
512
493
        repo = self.make_repository('repo', shared=True, format=format)
513
494
        repo.set_make_working_trees(False)
514
 
        out, err = self.run_bzr('info -v repo')
 
495
        out, err = self.runbzr('info repo')
515
496
        self.assertEqualDiff(
516
 
"""Shared repository (format: dirstate or dirstate-tags or knit)
517
 
Location:
 
497
"""Location:
518
498
  shared repository: %s
519
499
 
520
500
Format:
521
501
       control: Meta directory format 1
522
502
    repository: %s
523
503
 
524
 
Repository:
 
504
Revision store:
525
505
         0 revisions
526
506
         0 KiB
527
 
""" % ('repo', format.repository_format.get_format_description(),
 
507
""" % (repo.bzrdir.root_transport.base,
 
508
       format.repository_format.get_format_description(),
528
509
       ), out)
529
510
        self.assertEqual('', err)
530
511
 
532
513
        repo.bzrdir.root_transport.mkdir('branch')
533
514
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
534
515
            format=format)
535
 
        out, err = self.run_bzr('info -v repo/branch')
 
516
        out, err = self.runbzr('info repo/branch')
536
517
        self.assertEqualDiff(
537
 
"""Repository branch (format: dirstate or knit)
538
 
Location:
539
 
  shared repository: repo
540
 
  repository branch: repo/branch
 
518
"""Location:
 
519
  shared repository: %s
 
520
  repository branch: branch
541
521
 
542
522
Format:
543
523
       control: Meta directory format 1
546
526
 
547
527
Branch history:
548
528
         0 revisions
549
 
         0 committers
550
529
 
551
 
Repository:
 
530
Revision store:
552
531
         0 revisions
553
532
         0 KiB
554
 
""" % (format.get_branch_format().get_format_description(),
 
533
""" % (repo.bzrdir.root_transport.base,
 
534
       format.get_branch_format().get_format_description(),
555
535
       format.repository_format.get_format_description(),
556
536
       ), out)
557
537
        self.assertEqual('', err)
562
542
        tree2 = branch1.create_checkout('tree/lightcheckout', 
563
543
            lightweight=True)
564
544
        branch2 = tree2.branch
565
 
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
566
 
                   shared_repo=repo, repo_branch=branch1, verbose=True)
 
545
        self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, 
 
546
                   shared_repo=repo)
567
547
 
568
548
        # Create normal checkout
569
549
        tree3 = branch1.create_checkout('tree/checkout')
576
556
        tree2.commit('commit one')
577
557
        rev = repo.get_revision(branch2.revision_history()[0])
578
558
        datestring_first = format_date(rev.timestamp, rev.timezone)
579
 
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
 
559
        out, err = self.runbzr('info tree/lightcheckout --verbose')
580
560
        self.assertEqualDiff(
581
 
"""Lightweight checkout (format: dirstate or dirstate-tags)
582
 
Location:
583
 
  light checkout root: tree/lightcheckout
584
 
   checkout of branch: repo/branch
585
 
    shared repository: repo
 
561
"""Location:
 
562
 light checkout root: %s
 
563
   shared repository: %s
 
564
   repository branch: branch
586
565
 
587
566
Format:
588
567
       control: Meta directory format 1
607
586
   first revision: %s
608
587
  latest revision: %s
609
588
 
610
 
Repository:
 
589
Revision store:
611
590
         1 revision
612
591
         %d KiB
613
 
""" % (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(),
614
595
       format.repository_format.get_format_description(),
615
596
       datestring_first, datestring_first,
616
597
       # poking at _revision_store isn't all that clean, but neither is
620
601
        self.assertEqual('', err)
621
602
 
622
603
        # Out of date checkout
623
 
        out, err = self.run_bzr('info -v tree/checkout')
 
604
        out, err = self.runbzr('info tree/checkout')
624
605
        self.assertEqualDiff(
625
 
"""Checkout (format: dirstate)
626
 
Location:
627
 
       checkout root: tree/checkout
628
 
  checkout of branch: repo/branch
 
606
"""Location:
 
607
       checkout root: %s
 
608
  checkout of branch: %s
629
609
 
630
610
Format:
631
611
       control: Meta directory format 1
647
627
 
648
628
Branch history:
649
629
         0 revisions
650
 
         0 committers
651
630
 
652
 
Repository:
 
631
Revision store:
653
632
         0 revisions
654
633
         0 KiB
655
 
""" % (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(),
656
637
       format.repository_format.get_format_description(),
657
638
       ), out)
658
639
        self.assertEqual('', err)
661
642
        tree3.update()
662
643
        self.build_tree(['tree/checkout/b'])
663
644
        tree3.add('b')
664
 
        out, err = self.run_bzr('info tree/checkout --verbose')
 
645
        out, err = self.runbzr('info tree/checkout --verbose')
665
646
        self.assertEqualDiff(
666
 
"""Checkout (format: dirstate)
667
 
Location:
668
 
       checkout root: tree/checkout
669
 
  checkout of branch: repo/branch
 
647
"""Location:
 
648
       checkout root: %s
 
649
  checkout of branch: %s
670
650
 
671
651
Format:
672
652
       control: Meta directory format 1
691
671
   first revision: %s
692
672
  latest revision: %s
693
673
 
694
 
Repository:
 
674
Revision store:
695
675
         1 revision
696
676
         %d KiB
697
 
""" % (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(),
698
679
       format.repository_format.get_format_description(),
699
680
       datestring_first, datestring_first,
700
681
       # poking at _revision_store isn't all that clean, but neither is
707
688
        # Out of date lightweight checkout
708
689
        rev = repo.get_revision(branch1.revision_history()[-1])
709
690
        datestring_last = format_date(rev.timestamp, rev.timezone)
710
 
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
 
691
        out, err = self.runbzr('info tree/lightcheckout --verbose')
711
692
        self.assertEqualDiff(
712
 
"""Lightweight checkout (format: dirstate or dirstate-tags)
713
 
Location:
714
 
  light checkout root: tree/lightcheckout
715
 
   checkout of branch: repo/branch
716
 
    shared repository: repo
 
693
"""Location:
 
694
 light checkout root: %s
 
695
   shared repository: %s
 
696
   repository branch: branch
717
697
 
718
698
Format:
719
699
       control: Meta directory format 1
740
720
   first revision: %s
741
721
  latest revision: %s
742
722
 
743
 
Repository:
 
723
Revision store:
744
724
         2 revisions
745
725
         %d KiB
746
 
""" % (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(),
747
729
       format.repository_format.get_format_description(),
748
730
       datestring_first, datestring_last,
749
731
       # poking at _revision_store isn't all that clean, but neither is
753
735
        self.assertEqual('', err)
754
736
 
755
737
        # Show info about shared branch
756
 
        out, err = self.run_bzr('info repo/branch --verbose')
 
738
        out, err = self.runbzr('info repo/branch --verbose')
757
739
        self.assertEqualDiff(
758
 
"""Repository branch (format: dirstate or knit)
759
 
Location:
760
 
  shared repository: repo
761
 
  repository branch: repo/branch
 
740
"""Location:
 
741
  shared repository: %s
 
742
  repository branch: branch
762
743
 
763
744
Format:
764
745
       control: Meta directory format 1
772
753
   first revision: %s
773
754
  latest revision: %s
774
755
 
775
 
Repository:
 
756
Revision store:
776
757
         2 revisions
777
758
         %d KiB
778
 
""" % (format.get_branch_format().get_format_description(),
 
759
""" % (repo.bzrdir.root_transport.base,
 
760
       format.get_branch_format().get_format_description(),
779
761
       format.repository_format.get_format_description(),
780
762
       datestring_first, datestring_last,
781
763
       # poking at _revision_store isn't all that clean, but neither is
785
767
        self.assertEqual('', err)
786
768
 
787
769
        # Show info about repository with revisions
788
 
        out, err = self.run_bzr('info -v repo')
 
770
        out, err = self.runbzr('info repo')
789
771
        self.assertEqualDiff(
790
 
"""Shared repository (format: dirstate or dirstate-tags or knit)
791
 
Location:
792
 
  shared repository: repo
 
772
"""Location:
 
773
  shared repository: %s
793
774
 
794
775
Format:
795
776
       control: Meta directory format 1
796
777
    repository: %s
797
778
 
798
 
Repository:
 
779
Revision store:
799
780
         2 revisions
800
781
         %d KiB
801
 
""" % (format.repository_format.get_format_description(),
 
782
""" % (repo.bzrdir.root_transport.base,
 
783
       format.repository_format.get_format_description(),
802
784
       # poking at _revision_store isn't all that clean, but neither is
803
785
       # having the ui test dependent on the exact overhead of a given store.
804
786
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
812
794
        # Create shared repository with working trees
813
795
        repo = self.make_repository('repo', shared=True, format=format)
814
796
        repo.set_make_working_trees(True)
815
 
        out, err = self.run_bzr('info -v repo')
 
797
        out, err = self.runbzr('info repo')
816
798
        self.assertEqualDiff(
817
 
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
818
 
Location:
819
 
  shared repository: repo
 
799
"""Location:
 
800
  shared repository: %s
820
801
 
821
802
Format:
822
803
       control: Meta directory format 1
824
805
 
825
806
Create working tree for new branches inside the repository.
826
807
 
827
 
Repository:
 
808
Revision store:
828
809
         0 revisions
829
810
         0 KiB
830
 
""" % (format.repository_format.get_format_description(),
 
811
""" % (repo.bzrdir.root_transport.base,
 
812
       format.repository_format.get_format_description(),
831
813
       ), out)
832
814
        self.assertEqual('', err)
833
815
 
838
820
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
839
821
 
840
822
        # Empty first branch
841
 
        out, err = self.run_bzr('info repo/branch1 --verbose')
 
823
        out, err = self.runbzr('info repo/branch1 --verbose')
842
824
        self.assertEqualDiff(
843
 
"""Repository tree (format: knit)
844
 
Location:
845
 
  shared repository: repo
846
 
  repository branch: repo/branch1
 
825
"""Location:
 
826
    shared repository: %s
 
827
  repository checkout: branch1
847
828
 
848
829
Format:
849
830
       control: Meta directory format 1
865
846
         0 revisions
866
847
         0 committers
867
848
 
868
 
Repository:
 
849
Revision store:
869
850
         0 revisions
870
851
         0 KiB
871
 
""" % (format.get_branch_format().get_format_description(),
 
852
""" % (repo.bzrdir.root_transport.base,
 
853
       format.get_branch_format().get_format_description(),
872
854
       format.repository_format.get_format_description(),
873
855
       ), out)
874
856
        self.assertEqual('', err)
880
862
        tree1.commit('commit one')
881
863
        rev = repo.get_revision(branch1.revision_history()[0])
882
864
        datestring_first = format_date(rev.timestamp, rev.timezone)
883
 
        out, err = self.run_bzr('info -v repo/branch1')
 
865
        out, err = self.runbzr('info repo/branch1')
884
866
        self.assertEqualDiff(
885
 
"""Repository tree (format: knit)
886
 
Location:
887
 
  shared repository: repo
888
 
  repository branch: repo/branch1
 
867
"""Location:
 
868
    shared repository: %s
 
869
  repository checkout: branch1
889
870
 
890
871
Format:
891
872
       control: Meta directory format 1
905
886
 
906
887
Branch history:
907
888
         1 revision
908
 
         1 committer
909
889
         0 days old
910
890
   first revision: %s
911
891
  latest revision: %s
912
892
 
913
 
Repository:
 
893
Revision store:
914
894
         1 revision
915
895
         %d KiB
916
 
""" % (format.get_branch_format().get_format_description(),
 
896
""" % (repo.bzrdir.root_transport.base,
 
897
       format.get_branch_format().get_format_description(),
917
898
       format.repository_format.get_format_description(),
918
899
       datestring_first, datestring_first,
919
900
       # poking at _revision_store isn't all that clean, but neither is
923
904
        self.assertEqual('', err)
924
905
 
925
906
        # Out of date second branch
926
 
        out, err = self.run_bzr('info repo/branch2 --verbose')
 
907
        out, err = self.runbzr('info repo/branch2 --verbose')
927
908
        self.assertEqualDiff(
928
 
"""Repository tree (format: knit)
929
 
Location:
930
 
  shared repository: repo
931
 
  repository branch: repo/branch2
 
909
"""Location:
 
910
    shared repository: %s
 
911
  repository checkout: branch2
932
912
 
933
913
Related branches:
934
 
  parent branch: repo/branch1
 
914
  parent branch: %s
935
915
 
936
916
Format:
937
917
       control: Meta directory format 1
953
933
         0 revisions
954
934
         0 committers
955
935
 
956
 
Repository:
 
936
Revision store:
957
937
         1 revision
958
938
         %d KiB
959
 
""" % (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(),
960
942
       format.repository_format.get_format_description(),
961
943
       # poking at _revision_store isn't all that clean, but neither is
962
944
       # having the ui test dependent on the exact overhead of a given store.
967
949
        # Update second branch
968
950
        tree2 = branch2.bzrdir.open_workingtree()
969
951
        tree2.pull(branch1)
970
 
        out, err = self.run_bzr('info -v repo/branch2')
 
952
        out, err = self.runbzr('info repo/branch2')
971
953
        self.assertEqualDiff(
972
 
"""Repository tree (format: knit)
973
 
Location:
974
 
  shared repository: repo
975
 
  repository branch: repo/branch2
 
954
"""Location:
 
955
    shared repository: %s
 
956
  repository checkout: branch2
976
957
 
977
958
Related branches:
978
 
  parent branch: repo/branch1
 
959
  parent branch: %s
979
960
 
980
961
Format:
981
962
       control: Meta directory format 1
995
976
 
996
977
Branch history:
997
978
         1 revision
998
 
         1 committer
999
979
         0 days old
1000
980
   first revision: %s
1001
981
  latest revision: %s
1002
982
 
1003
 
Repository:
 
983
Revision store:
1004
984
         1 revision
1005
985
         %d KiB
1006
 
""" % (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(),
1007
989
       format.repository_format.get_format_description(),
1008
990
       datestring_first, datestring_first,
1009
991
       # poking at _revision_store isn't all that clean, but neither is
1013
995
        self.assertEqual('', err)
1014
996
 
1015
997
        # Show info about repository with revisions
1016
 
        out, err = self.run_bzr('info -v repo')
 
998
        out, err = self.runbzr('info repo')
1017
999
        self.assertEqualDiff(
1018
 
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1019
 
Location:
1020
 
  shared repository: repo
 
1000
"""Location:
 
1001
  shared repository: %s
1021
1002
 
1022
1003
Format:
1023
1004
       control: Meta directory format 1
1025
1006
 
1026
1007
Create working tree for new branches inside the repository.
1027
1008
 
1028
 
Repository:
 
1009
Revision store:
1029
1010
         1 revision
1030
1011
         %d KiB
1031
 
""" % (format.repository_format.get_format_description(),
 
1012
""" % (repo.bzrdir.root_transport.base,
 
1013
       format.repository_format.get_format_description(),
1032
1014
       # poking at _revision_store isn't all that clean, but neither is
1033
1015
       # having the ui test dependent on the exact overhead of a given store.
1034
1016
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1043
1025
        # Create shared repository with working trees
1044
1026
        repo = self.make_repository('repo', shared=True, format=format)
1045
1027
        repo.set_make_working_trees(True)
1046
 
        out, err = self.run_bzr('info -v repo')
 
1028
        out, err = self.runbzr('info repo')
1047
1029
        self.assertEqualDiff(
1048
 
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1049
 
Location:
1050
 
  shared repository: repo
 
1030
"""Location:
 
1031
  shared repository: %s
1051
1032
 
1052
1033
Format:
1053
1034
       control: Meta directory format 1
1055
1036
 
1056
1037
Create working tree for new branches inside the repository.
1057
1038
 
1058
 
Repository:
 
1039
Revision store:
1059
1040
         0 revisions
1060
1041
         0 KiB
1061
 
""" % (format.repository_format.get_format_description(),
 
1042
""" % (repo.bzrdir.root_transport.base,
 
1043
       format.repository_format.get_format_description(),
1062
1044
       ), out)
1063
1045
        self.assertEqual('', err)
1064
1046
 
1066
1048
        control = repo.bzrdir
1067
1049
        branch = control.create_branch()
1068
1050
        control.create_workingtree()
1069
 
        out, err = self.run_bzr('info -v repo')
 
1051
        out, err = self.runbzr('info repo')
1070
1052
        self.assertEqualDiff(
1071
 
"""Repository tree (format: knit)
1072
 
Location:
1073
 
  shared repository: repo
1074
 
  repository branch: repo
 
1053
"""Location:
 
1054
    shared repository: %s
 
1055
  repository checkout: .
1075
1056
 
1076
1057
Format:
1077
1058
       control: Meta directory format 1
1091
1072
 
1092
1073
Branch history:
1093
1074
         0 revisions
1094
 
         0 committers
1095
1075
 
1096
 
Repository:
 
1076
Revision store:
1097
1077
         0 revisions
1098
1078
         0 KiB
1099
 
""" % (format.get_branch_format().get_format_description(),
 
1079
""" % (repo.bzrdir.root_transport.base,
 
1080
       format.get_branch_format().get_format_description(),
1100
1081
       format.repository_format.get_format_description(),
1101
1082
       ), out)
1102
1083
        self.assertEqual('', err)
1107
1088
        tree_locked=False,
1108
1089
        branch_locked=False, repo_locked=False,
1109
1090
        verbose=False,
1110
 
        light_checkout=True,
1111
 
        checkout_root=None):
1112
 
        """Check the output of info in a checkout.
 
1091
        light_checkout=True):
 
1092
        """Check the output of info in a light checkout tree.
1113
1093
 
1114
1094
        This is not quite a mirror of the info code: rather than using the
1115
1095
        tree being examined to predict output, it uses a bunch of flags which
1128
1108
        :param repo_locked: If true, expect the repository to be locked.
1129
1109
        :param verbose: If true, expect verbose output
1130
1110
        """
1131
 
        def friendly_location(url):
1132
 
            path = urlutils.unescape_for_display(url, 'ascii')
1133
 
            try:
1134
 
                return osutils.relpath(os.getcwd(), path)
1135
 
            except errors.PathNotChild:
1136
 
                return path
1137
 
 
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).
1141
 
            # This should be removed when the locking errors are fixed.
1142
 
            args = command_string.split(' ')
1143
 
            self.run_bzr_error([], 'info', *args)
1144
 
            return
1145
 
        out, err = self.run_bzr('info %s' % command_string)
1146
 
        description = {
1147
 
            (True, True): 'Lightweight checkout',
1148
 
            (True, False): 'Repository checkout',
1149
 
            (False, True): 'Lightweight checkout',
1150
 
            (False, False): 'Checkout',
1151
 
            }[(shared_repo is not None, light_checkout)]
1152
 
        format = {True: 'dirstate or dirstate-tags',
1153
 
                  False: 'dirstate'}[light_checkout]
 
1111
        out, err = self.runbzr('info %s' % command_string)
1154
1112
        if repo_locked or branch_locked or tree_locked:
1155
1113
            def locked_message(a_bool):
1156
1114
                if a_bool:
1168
1126
                    locked_message(repo_locked)))
1169
1127
        else:
1170
1128
            expected_lock_output = ''
1171
 
        tree_data = ''
1172
 
        extra_space = ''
1173
1129
        if light_checkout:
1174
 
            tree_data = ("  light checkout root: %s\n" %
1175
 
                friendly_location(lco_tree.bzrdir.root_transport.base))
1176
 
            extra_space = ' '
1177
 
        if lco_tree.branch.get_bound_location() is not None:
1178
 
            tree_data += ("%s       checkout root: %s\n" % (extra_space,
1179
 
                friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
 
1130
            tree_data = (" light checkout root: %s" %
 
1131
                lco_tree.bzrdir.root_transport.base)
 
1132
        else:
 
1133
            tree_data = ("       checkout root: %s" %
 
1134
                lco_tree.bzrdir.root_transport.base)
1180
1135
        if shared_repo is not None:
1181
1136
            branch_data = (
1182
 
                "   checkout of branch: %s\n"
1183
 
                "    shared repository: %s\n" %
1184
 
                (friendly_location(repo_branch.bzrdir.root_transport.base),
1185
 
                 friendly_location(shared_repo.bzrdir.root_transport.base)))
 
1137
                "   shared repository: %s\n"
 
1138
                "   repository branch: branch\n" %
 
1139
                shared_repo.bzrdir.root_transport.base)
1186
1140
        elif repo_branch is not None:
1187
1141
            branch_data = (
1188
 
                "%s  checkout of branch: %s\n" %
1189
 
                (extra_space,
1190
 
                 friendly_location(repo_branch.bzrdir.root_transport.base)))
 
1142
                "  checkout of branch: %s\n" % 
 
1143
                repo_branch.bzrdir.root_transport.base)
1191
1144
        else:
1192
 
            branch_data = ("   checkout of branch: %s\n" %
 
1145
            branch_data = ("  checkout of branch: %s\n" % 
1193
1146
                lco_tree.branch.bzrdir.root_transport.base)
1194
1147
        
1195
1148
        if verbose:
1198
1151
            verbose_info = ''
1199
1152
            
1200
1153
        self.assertEqualDiff(
1201
 
"""%s (format: %s)
1202
 
Location:
1203
 
%s%s
 
1154
"""Location:
 
1155
%s
 
1156
%s
1204
1157
Format:
1205
1158
       control: Meta directory format 1
1206
1159
  working tree: %s
1220
1173
Branch history:
1221
1174
         0 revisions
1222
1175
%s
1223
 
Repository:
 
1176
Revision store:
1224
1177
         0 revisions
1225
1178
         0 KiB
1226
 
""" %  (description,
1227
 
        format,
1228
 
        tree_data,
 
1179
""" %  (tree_data,
1229
1180
        branch_data,
1230
1181
        lco_tree._format.get_format_description(),
1231
1182
        lco_tree.branch._format.get_format_description(),
1261
1212
        # W B R
1262
1213
 
1263
1214
        # U U U
1264
 
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1265
 
                                        repo_branch=repo_branch,
1266
 
                                        verbose=True, light_checkout=True)
 
1215
        self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1267
1216
        # U U L
1268
1217
        lco_tree.branch.repository.lock_write()
1269
1218
        try:
1270
 
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1271
 
            lco_tree, repo_branch=repo_branch,
1272
 
            repo_locked=True, verbose=True, light_checkout=True)
 
1219
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1220
            lco_tree,
 
1221
            repo_locked=True)
1273
1222
        finally:
1274
1223
            lco_tree.branch.repository.unlock()
1275
1224
        # U L L
1276
1225
        lco_tree.branch.lock_write()
1277
1226
        try:
1278
 
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1227
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1279
1228
            lco_tree,
1280
1229
            branch_locked=True,
1281
 
            repo_locked=True,
1282
 
            repo_branch=repo_branch,
1283
 
            verbose=True)
 
1230
            repo_locked=True)
1284
1231
        finally:
1285
1232
            lco_tree.branch.unlock()
1286
1233
        # L L L
1287
1234
        lco_tree.lock_write()
1288
1235
        try:
1289
 
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1290
 
            lco_tree, repo_branch=repo_branch,
 
1236
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1237
            lco_tree,
1291
1238
            tree_locked=True,
1292
1239
            branch_locked=True,
1293
 
            repo_locked=True,
1294
 
            verbose=True)
 
1240
            repo_locked=True)
1295
1241
        finally:
1296
1242
            lco_tree.unlock()
1297
1243
        # L L U
1298
1244
        lco_tree.lock_write()
1299
1245
        lco_tree.branch.repository.unlock()
1300
1246
        try:
1301
 
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1302
 
            lco_tree, repo_branch=repo_branch,
 
1247
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1248
            lco_tree,
1303
1249
            tree_locked=True,
1304
 
            branch_locked=True,
1305
 
            verbose=True)
 
1250
            branch_locked=True)
1306
1251
        finally:
1307
1252
            lco_tree.branch.repository.lock_write()
1308
1253
            lco_tree.unlock()
1310
1255
        lco_tree.lock_write()
1311
1256
        lco_tree.branch.unlock()
1312
1257
        try:
1313
 
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1314
 
            lco_tree, repo_branch=repo_branch,
1315
 
            tree_locked=True,
1316
 
            verbose=True)
 
1258
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1259
            lco_tree,
 
1260
            tree_locked=True)
1317
1261
        finally:
1318
1262
            lco_tree.branch.lock_write()
1319
1263
            lco_tree.unlock()
1322
1266
        lco_tree.branch.unlock()
1323
1267
        lco_tree.branch.repository.lock_write()
1324
1268
        try:
1325
 
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1326
 
            lco_tree, repo_branch=repo_branch,
 
1269
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1270
            lco_tree,
1327
1271
            tree_locked=True,
1328
 
            repo_locked=True,
1329
 
            verbose=True)
 
1272
            repo_locked=True)
1330
1273
        finally:
1331
1274
            lco_tree.branch.repository.unlock()
1332
1275
            lco_tree.branch.lock_write()
1335
1278
        lco_tree.branch.lock_write()
1336
1279
        lco_tree.branch.repository.unlock()
1337
1280
        try:
1338
 
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1339
 
            lco_tree, repo_branch=repo_branch,
1340
 
            branch_locked=True,
1341
 
            verbose=True)
 
1281
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1282
            lco_tree,
 
1283
            branch_locked=True)
1342
1284
        finally:
1343
1285
            lco_tree.branch.repository.lock_write()
1344
1286
            lco_tree.branch.unlock()
1345
1287
 
1346
 
        if sys.platform == 'win32':
1347
 
            self.knownFailure('Win32 cannot run "bzr info"'
1348
 
                              ' when the tree is locked.')
1349
 
 
1350
1288
    def test_info_locking_oslocks(self):
1351
1289
        if sys.platform == "win32":
1352
1290
            raise TestSkipped("don't use oslocks on win32 in unix manner")
1361
1299
        # W B R
1362
1300
 
1363
1301
        # U U U
1364
 
        out, err = self.run_bzr('info -v branch')
 
1302
        out, err = self.runbzr('info branch')
1365
1303
        self.assertEqualDiff(
1366
 
"""Standalone tree (format: weave)
1367
 
Location:
 
1304
"""Location:
1368
1305
  branch root: %s
1369
1306
 
1370
1307
Format:
1385
1322
 
1386
1323
Branch history:
1387
1324
         0 revisions
1388
 
         0 committers
1389
1325
 
1390
 
Repository:
 
1326
Revision store:
1391
1327
         0 revisions
1392
1328
         0 KiB
1393
 
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1329
""" % (tree.bzrdir.root_transport.base,
 
1330
       tree.branch.repository._format.get_format_description(),
1394
1331
       ), out)
1395
1332
        self.assertEqual('', err)
1396
1333
        # L L L
1397
1334
        tree.lock_write()
1398
 
        out, err = self.run_bzr('info -v branch')
 
1335
        out, err = self.runbzr('info branch')
1399
1336
        self.assertEqualDiff(
1400
 
"""Standalone tree (format: weave)
1401
 
Location:
 
1337
"""Location:
1402
1338
  branch root: %s
1403
1339
 
1404
1340
Format:
1419
1355
 
1420
1356
Branch history:
1421
1357
         0 revisions
1422
 
         0 committers
1423
1358
 
1424
 
Repository:
 
1359
Revision store:
1425
1360
         0 revisions
1426
1361
         0 KiB
1427
 
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1362
""" % (tree.bzrdir.root_transport.base,
 
1363
       tree.branch.repository._format.get_format_description(),
1428
1364
       ), out)
1429
1365
        self.assertEqual('', err)
1430
1366
        tree.unlock()