~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2007-04-19 02:27:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2426.
  • Revision ID: robertc@robertcollins.net-20070419022744-pfdqz42kp1wizh43
``make docs`` now creates a man page at ``man1/bzr.1`` fixing bug 107388.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
18
"""Tests for the info command of bzr."""
19
19
 
20
20
import sys
21
21
 
 
22
import bzrlib
22
23
from bzrlib import (
23
 
    branch,
24
24
    bzrdir,
25
 
    errors,
26
 
    info,
27
 
    osutils,
28
 
    upgrade,
29
 
    urlutils,
 
25
    repository,
30
26
    )
31
27
from bzrlib.osutils import format_date
32
28
from bzrlib.tests import TestSkipped
40
36
            location = "C:/i/do/not/exist/"
41
37
        else:
42
38
            location = "/i/do/not/exist/"
43
 
        out, err = self.run_bzr('info '+location, retcode=3)
 
39
        out, err = self.runbzr('info '+location, retcode=3)
44
40
        self.assertEqual(out, '')
45
 
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
 
41
        self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
46
42
 
47
43
    def test_info_standalone(self):
48
44
        transport = self.get_transport()
52
48
        self.build_tree(['standalone/a'])
53
49
        tree1.add('a')
54
50
        branch1 = tree1.branch
55
 
 
56
 
        out, err = self.run_bzr('info standalone')
57
 
        self.assertEqualDiff(
58
 
"""Standalone tree (format: weave)
59
 
Location:
60
 
  branch root: standalone
61
 
""", out)
62
 
        self.assertEqual('', err)
63
 
 
64
 
        # Standalone branch - verbose mode
65
 
        out, err = self.run_bzr('info standalone -v')
66
 
        self.assertEqualDiff(
67
 
"""Standalone tree (format: weave)
68
 
Location:
69
 
  branch root: standalone
70
 
 
71
 
Format:
72
 
       control: All-in-one format 6
73
 
  working tree: Working tree format 2
74
 
        branch: Branch format 4
75
 
    repository: Weave repository format 6
76
 
 
77
 
In the working tree:
78
 
         0 unchanged
79
 
         0 modified
80
 
         1 added
81
 
         0 removed
82
 
         0 renamed
83
 
         0 unknown
84
 
         0 ignored
85
 
         0 versioned subdirectories
86
 
 
87
 
Branch history:
88
 
         0 revisions
89
 
 
90
 
Repository:
91
 
         0 revisions
92
 
""", out)
93
 
        self.assertEqual('', err)
94
 
 
95
 
        # Standalone branch - really verbose mode
96
 
        out, err = self.run_bzr('info standalone -vv')
97
 
        self.assertEqualDiff(
98
 
"""Standalone tree (format: weave)
99
 
Location:
100
 
  branch root: standalone
101
 
 
102
 
Format:
103
 
       control: All-in-one format 6
104
 
  working tree: Working tree format 2
105
 
        branch: Branch format 4
106
 
    repository: Weave repository format 6
107
 
 
108
 
In the working tree:
109
 
         0 unchanged
110
 
         0 modified
111
 
         1 added
112
 
         0 removed
113
 
         0 renamed
114
 
         0 unknown
115
 
         0 ignored
116
 
         0 versioned subdirectories
117
 
 
118
 
Branch history:
119
 
         0 revisions
120
 
         0 committers
121
 
 
122
 
Repository:
123
 
         0 revisions
124
 
""", out)
 
51
        out, err = self.runbzr('info standalone')
 
52
        self.assertEqualDiff(
 
53
"""Location:
 
54
  branch root: %s
 
55
 
 
56
Format:
 
57
       control: All-in-one format 6
 
58
  working tree: Working tree format 2
 
59
        branch: Branch format 4
 
60
    repository: Weave repository format 6
 
61
 
 
62
In the working tree:
 
63
         0 unchanged
 
64
         0 modified
 
65
         1 added
 
66
         0 removed
 
67
         0 renamed
 
68
         0 unknown
 
69
         0 ignored
 
70
         0 versioned subdirectories
 
71
 
 
72
Branch history:
 
73
         0 revisions
 
74
 
 
75
Repository:
 
76
         0 revisions
 
77
         0 KiB
 
78
""" % branch1.bzrdir.root_transport.base, out)
125
79
        self.assertEqual('', err)
126
80
        tree1.commit('commit one')
127
81
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
130
84
        # Branch standalone with push location
131
85
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
132
86
        branch2.set_push_location(branch1.bzrdir.root_transport.base)
133
 
 
134
 
        out, err = self.run_bzr('info branch')
135
 
        self.assertEqualDiff(
136
 
"""Standalone tree (format: weave)
137
 
Location:
138
 
  branch root: branch
139
 
 
140
 
Related branches:
141
 
    push branch: standalone
142
 
  parent branch: standalone
143
 
""", out)
144
 
        self.assertEqual('', err)
145
 
 
146
 
        out, err = self.run_bzr('info branch --verbose')
147
 
        self.assertEqualDiff(
148
 
"""Standalone tree (format: weave)
149
 
Location:
150
 
  branch root: branch
151
 
 
152
 
Related branches:
153
 
    push branch: standalone
154
 
  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
155
95
 
156
96
Format:
157
97
       control: All-in-one format 6
171
111
 
172
112
Branch history:
173
113
         1 revision
 
114
         1 committer
174
115
         0 days old
175
116
   first revision: %s
176
117
  latest revision: %s
177
118
 
178
119
Repository:
179
120
         1 revision
180
 
""" % (datestring_first, datestring_first,
 
121
         %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,
 
126
       # poking at _revision_store isn't all that clean, but neither is
 
127
       # having the ui test dependent on the exact overhead of a given store.
 
128
       branch2.repository._revision_store.total_size(
 
129
        branch2.repository.get_transaction())[1] / 1024,
181
130
       ), out)
182
131
        self.assertEqual('', err)
183
132
 
185
134
        # (creates backup as unknown)
186
135
        branch1.bzrdir.sprout('bound')
187
136
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
188
 
        upgrade.upgrade('bound', knit1_format)
189
 
        branch3 = bzrdir.BzrDir.open('bound').open_branch()
 
137
        bzrlib.upgrade.upgrade('bound', knit1_format)
 
138
        branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
190
139
        branch3.bind(branch1)
191
140
        bound_tree = branch3.bzrdir.open_workingtree()
192
 
        out, err = self.run_bzr('info -v bound')
 
141
        out, err = self.runbzr('info bound')
193
142
        self.assertEqualDiff(
194
 
"""Checkout (format: knit)
195
 
Location:
196
 
       checkout root: bound
197
 
  checkout of branch: standalone
 
143
"""Location:
 
144
       checkout root: %s
 
145
  checkout of branch: %s
198
146
 
199
147
Related branches:
200
 
  parent branch: standalone
 
148
  parent branch: %s
201
149
 
202
150
Format:
203
151
       control: Meta directory format 1
223
171
 
224
172
Repository:
225
173
         1 revision
226
 
""" % (bound_tree._format.get_format_description(),
 
174
         %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(),      
227
179
       branch3._format.get_format_description(),
228
180
       branch3.repository._format.get_format_description(),
229
181
       datestring_first, datestring_first,
 
182
       # poking at _revision_store isn't all that clean, but neither is
 
183
       # having the ui test dependent on the exact overhead of a given store.
 
184
       branch3.repository._revision_store.total_size(
 
185
        branch3.repository.get_transaction())[1] / 1024,
230
186
       ), out)
231
187
        self.assertEqual('', err)
232
188
 
233
189
        # Checkout standalone (same as above, but does not have parent set)
234
 
        branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
 
190
        branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
235
191
            format=knit1_format)
236
192
        branch4.bind(branch1)
237
193
        branch4.bzrdir.open_workingtree().update()
238
 
        out, err = self.run_bzr('info checkout --verbose')
 
194
        out, err = self.runbzr('info checkout --verbose')
239
195
        self.assertEqualDiff(
240
 
"""Checkout (format: knit)
241
 
Location:
242
 
       checkout root: checkout
243
 
  checkout of branch: standalone
 
196
"""Location:
 
197
       checkout root: %s
 
198
  checkout of branch: %s
244
199
 
245
200
Format:
246
201
       control: Meta directory format 1
260
215
 
261
216
Branch history:
262
217
         1 revision
 
218
         1 committer
263
219
         0 days old
264
220
   first revision: %s
265
221
  latest revision: %s
266
222
 
267
223
Repository:
268
224
         1 revision
269
 
""" % (branch4.repository._format.get_format_description(),
 
225
         %d KiB
 
226
""" % (branch4.bzrdir.root_transport.base,
 
227
       branch1.bzrdir.root_transport.base,
 
228
       branch4.repository._format.get_format_description(),
270
229
       datestring_first, datestring_first,
 
230
       # poking at _revision_store isn't all that clean, but neither is
 
231
       # having the ui test dependent on the exact overhead of a given store.
 
232
       branch4.repository._revision_store.total_size(
 
233
        branch4.repository.get_transaction())[1] / 1024,
271
234
       ), out)
272
235
        self.assertEqual('', err)
273
236
 
274
237
        # Lightweight checkout (same as above, different branch and repository)
275
238
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
276
239
        branch5 = tree5.branch
277
 
        out, err = self.run_bzr('info -v lightcheckout')
 
240
        out, err = self.runbzr('info lightcheckout')
278
241
        self.assertEqualDiff(
279
 
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root \
280
 
or 1.9 or 1.9-rich-root \
281
 
or dirstate or dirstate-tags or \
282
 
pack-0.92 or rich-root or rich-root-pack)
283
 
Location:
284
 
  light checkout root: lightcheckout
285
 
   checkout of branch: standalone
 
242
"""Location:
 
243
 light checkout root: %s
 
244
  checkout of branch: %s
286
245
 
287
246
Format:
288
247
       control: Meta directory format 1
308
267
 
309
268
Repository:
310
269
         1 revision
311
 
""" % (datestring_first, datestring_first,), out)
 
270
         0 KiB
 
271
""" % (tree5.bzrdir.root_transport.base,
 
272
       branch1.bzrdir.root_transport.base,
 
273
       datestring_first, datestring_first,
 
274
       ), out)
312
275
        self.assertEqual('', err)
313
276
 
314
277
        # Update initial standalone branch
319
282
        datestring_last = format_date(rev.timestamp, rev.timezone)
320
283
 
321
284
        # Out of date branched standalone branch will not be detected
322
 
        out, err = self.run_bzr('info -v branch')
 
285
        out, err = self.runbzr('info branch')
323
286
        self.assertEqualDiff(
324
 
"""Standalone tree (format: weave)
325
 
Location:
326
 
  branch root: branch
 
287
"""Location:
 
288
  branch root: %s
327
289
 
328
290
Related branches:
329
 
    push branch: standalone
330
 
  parent branch: standalone
 
291
      parent branch: %s
 
292
  publish to branch: %s
331
293
 
332
294
Format:
333
295
       control: All-in-one format 6
353
315
 
354
316
Repository:
355
317
         1 revision
356
 
""" % (datestring_first, datestring_first,
 
318
         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,
357
323
       ), out)
358
324
        self.assertEqual('', err)
359
325
 
360
326
        # Out of date bound branch
361
 
        out, err = self.run_bzr('info -v bound')
 
327
        out, err = self.runbzr('info bound')
362
328
        self.assertEqualDiff(
363
 
"""Checkout (format: knit)
364
 
Location:
365
 
       checkout root: bound
366
 
  checkout of branch: standalone
 
329
"""Location:
 
330
       checkout root: %s
 
331
  checkout of branch: %s
367
332
 
368
333
Related branches:
369
 
  parent branch: standalone
 
334
  parent branch: %s
370
335
 
371
336
Format:
372
337
       control: Meta directory format 1
394
359
 
395
360
Repository:
396
361
         1 revision
397
 
""" % (branch3.repository._format.get_format_description(),
 
362
         %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(),
398
367
       datestring_first, datestring_first,
 
368
       # poking at _revision_store isn't all that clean, but neither is
 
369
       # having the ui test dependent on the exact overhead of a given store.
 
370
       branch3.repository._revision_store.total_size(
 
371
        branch3.repository.get_transaction())[1] / 1024,
399
372
       ), out)
400
373
        self.assertEqual('', err)
401
374
 
402
375
        # Out of date checkout
403
 
        out, err = self.run_bzr('info -v checkout')
 
376
        out, err = self.runbzr('info checkout')
404
377
        self.assertEqualDiff(
405
 
"""Checkout (format: knit)
406
 
Location:
407
 
       checkout root: checkout
408
 
  checkout of branch: standalone
 
378
"""Location:
 
379
       checkout root: %s
 
380
  checkout of branch: %s
409
381
 
410
382
Format:
411
383
       control: Meta directory format 1
433
405
 
434
406
Repository:
435
407
         1 revision
436
 
""" % (branch4.repository._format.get_format_description(),
 
408
         %d KiB
 
409
""" % (branch4.bzrdir.root_transport.base,
 
410
       branch1.bzrdir.root_transport.base,
 
411
       branch4.repository._format.get_format_description(),
437
412
       datestring_first, datestring_first,
 
413
       # poking at _revision_store isn't all that clean, but neither is
 
414
       # having the ui test dependent on the exact overhead of a given store.
 
415
       branch4.repository._revision_store.total_size(
 
416
        branch4.repository.get_transaction())[1] / 1024,
438
417
       ), out)
439
418
        self.assertEqual('', err)
440
419
 
441
420
        # Out of date lightweight checkout
442
 
        out, err = self.run_bzr('info lightcheckout --verbose')
 
421
        out, err = self.runbzr('info lightcheckout --verbose')
443
422
        self.assertEqualDiff(
444
 
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
445
 
1.9 or 1.9-rich-root or \
446
 
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
469
444
 
470
445
Branch history:
471
446
         2 revisions
 
447
         1 committer
472
448
         0 days old
473
449
   first revision: %s
474
450
  latest revision: %s
475
451
 
476
452
Repository:
477
453
         2 revisions
478
 
""" % (datestring_first, datestring_last,), out)
 
454
         0 KiB
 
455
""" % (tree5.bzrdir.root_transport.base,
 
456
       branch1.bzrdir.root_transport.base,
 
457
       datestring_first, datestring_last,
 
458
       ), out)
479
459
        self.assertEqual('', err)
480
460
 
481
461
    def test_info_standalone_no_tree(self):
483
463
        format = bzrdir.format_registry.make_bzrdir('default')
484
464
        branch = self.make_branch('branch')
485
465
        repo = branch.repository
486
 
        out, err = self.run_bzr('info branch -v')
 
466
        out, err = self.runbzr('info branch')
487
467
        self.assertEqualDiff(
488
 
"""Standalone branch (format: %s)
489
 
Location:
490
 
  branch root: branch
 
468
"""Location:
 
469
  branch root: %s
491
470
 
492
471
Format:
493
472
       control: Meta directory format 1
499
478
 
500
479
Repository:
501
480
         0 revisions
502
 
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
 
481
         0 KiB
 
482
""" % (branch.bzrdir.root_transport.base,
503
483
       format.get_branch_format().get_format_description(),
504
484
       format.repository_format.get_format_description(),
505
485
       ), out)
512
492
        # Create shared repository
513
493
        repo = self.make_repository('repo', shared=True, format=format)
514
494
        repo.set_make_working_trees(False)
515
 
        out, err = self.run_bzr('info -v repo')
 
495
        out, err = self.runbzr('info repo')
516
496
        self.assertEqualDiff(
517
 
"""Shared repository (format: dirstate or dirstate-tags or knit)
518
 
Location:
 
497
"""Location:
519
498
  shared repository: %s
520
499
 
521
500
Format:
524
503
 
525
504
Repository:
526
505
         0 revisions
527
 
""" % ('repo', format.repository_format.get_format_description(),
 
506
         0 KiB
 
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
549
529
 
550
530
Repository:
551
531
         0 revisions
552
 
""" % (format.get_branch_format().get_format_description(),
 
532
         0 KiB
 
533
""" % (repo.bzrdir.root_transport.base,
 
534
       format.get_branch_format().get_format_description(),
553
535
       format.repository_format.get_format_description(),
554
536
       ), out)
555
537
        self.assertEqual('', err)
557
539
        # Create lightweight checkout
558
540
        transport.mkdir('tree')
559
541
        transport.mkdir('tree/lightcheckout')
560
 
        tree2 = branch1.create_checkout('tree/lightcheckout',
 
542
        tree2 = branch1.create_checkout('tree/lightcheckout', 
561
543
            lightweight=True)
562
544
        branch2 = tree2.branch
563
 
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
564
 
                   shared_repo=repo, repo_branch=branch1, verbose=True)
 
545
        self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, 
 
546
                   shared_repo=repo)
565
547
 
566
548
        # Create normal checkout
567
549
        tree3 = branch1.create_checkout('tree/checkout')
574
556
        tree2.commit('commit one')
575
557
        rev = repo.get_revision(branch2.revision_history()[0])
576
558
        datestring_first = format_date(rev.timestamp, rev.timezone)
577
 
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
 
559
        out, err = self.runbzr('info tree/lightcheckout --verbose')
578
560
        self.assertEqualDiff(
579
 
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
580
 
1.9 or 1.9-rich-root or \
581
 
dirstate or dirstate-tags or \
582
 
pack-0.92 or rich-root or rich-root-pack)
583
 
Location:
584
 
  light checkout root: tree/lightcheckout
585
 
   checkout of branch: repo/branch
586
 
    shared repository: repo
 
561
"""Location:
 
562
 light checkout root: %s
 
563
   shared repository: %s
 
564
   repository branch: branch
587
565
 
588
566
Format:
589
567
       control: Meta directory format 1
603
581
 
604
582
Branch history:
605
583
         1 revision
 
584
         1 committer
606
585
         0 days old
607
586
   first revision: %s
608
587
  latest revision: %s
609
588
 
610
589
Repository:
611
590
         1 revision
612
 
""" % (format.get_branch_format().get_format_description(),
 
591
         %d KiB
 
592
""" % (tree2.bzrdir.root_transport.base,
 
593
       repo.bzrdir.root_transport.base,
 
594
       format.get_branch_format().get_format_description(),
613
595
       format.repository_format.get_format_description(),
614
596
       datestring_first, datestring_first,
 
597
       # poking at _revision_store isn't all that clean, but neither is
 
598
       # having the ui test dependent on the exact overhead of a given store.
 
599
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
615
600
       ), out)
616
601
        self.assertEqual('', err)
617
602
 
618
603
        # Out of date checkout
619
 
        out, err = self.run_bzr('info -v tree/checkout')
 
604
        out, err = self.runbzr('info tree/checkout')
620
605
        self.assertEqualDiff(
621
 
"""Checkout (format: dirstate)
622
 
Location:
623
 
       checkout root: tree/checkout
624
 
  checkout of branch: repo/branch
 
606
"""Location:
 
607
       checkout root: %s
 
608
  checkout of branch: %s
625
609
 
626
610
Format:
627
611
       control: Meta directory format 1
646
630
 
647
631
Repository:
648
632
         0 revisions
649
 
""" % (format.get_branch_format().get_format_description(),
 
633
         0 KiB
 
634
""" % (tree3.bzrdir.root_transport.base,
 
635
       branch1.bzrdir.root_transport.base,
 
636
       format.get_branch_format().get_format_description(),
650
637
       format.repository_format.get_format_description(),
651
638
       ), out)
652
639
        self.assertEqual('', err)
655
642
        tree3.update()
656
643
        self.build_tree(['tree/checkout/b'])
657
644
        tree3.add('b')
658
 
        out, err = self.run_bzr('info tree/checkout --verbose')
 
645
        out, err = self.runbzr('info tree/checkout --verbose')
659
646
        self.assertEqualDiff(
660
 
"""Checkout (format: dirstate)
661
 
Location:
662
 
       checkout root: tree/checkout
663
 
  checkout of branch: repo/branch
 
647
"""Location:
 
648
       checkout root: %s
 
649
  checkout of branch: %s
664
650
 
665
651
Format:
666
652
       control: Meta directory format 1
680
666
 
681
667
Branch history:
682
668
         1 revision
 
669
         1 committer
683
670
         0 days old
684
671
   first revision: %s
685
672
  latest revision: %s
686
673
 
687
674
Repository:
688
675
         1 revision
689
 
""" % (format.get_branch_format().get_format_description(),
 
676
         %d KiB
 
677
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
 
678
       format.get_branch_format().get_format_description(),
690
679
       format.repository_format.get_format_description(),
691
680
       datestring_first, datestring_first,
 
681
       # poking at _revision_store isn't all that clean, but neither is
 
682
       # having the ui test dependent on the exact overhead of a given store.
 
683
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
692
684
       ), out)
693
685
        self.assertEqual('', err)
694
686
        tree3.commit('commit two')
696
688
        # Out of date lightweight checkout
697
689
        rev = repo.get_revision(branch1.revision_history()[-1])
698
690
        datestring_last = format_date(rev.timestamp, rev.timezone)
699
 
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
 
691
        out, err = self.runbzr('info tree/lightcheckout --verbose')
700
692
        self.assertEqualDiff(
701
 
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
702
 
1.9 or 1.9-rich-root or \
703
 
dirstate or dirstate-tags or \
704
 
pack-0.92 or rich-root or rich-root-pack)
705
 
Location:
706
 
  light checkout root: tree/lightcheckout
707
 
   checkout of branch: repo/branch
708
 
    shared repository: repo
 
693
"""Location:
 
694
 light checkout root: %s
 
695
   shared repository: %s
 
696
   repository branch: branch
709
697
 
710
698
Format:
711
699
       control: Meta directory format 1
727
715
 
728
716
Branch history:
729
717
         2 revisions
 
718
         1 committer
730
719
         0 days old
731
720
   first revision: %s
732
721
  latest revision: %s
733
722
 
734
723
Repository:
735
724
         2 revisions
736
 
""" % (format.get_branch_format().get_format_description(),
 
725
         %d KiB
 
726
""" % (tree2.bzrdir.root_transport.base,
 
727
       repo.bzrdir.root_transport.base,
 
728
       format.get_branch_format().get_format_description(),
737
729
       format.repository_format.get_format_description(),
738
730
       datestring_first, datestring_last,
 
731
       # poking at _revision_store isn't all that clean, but neither is
 
732
       # having the ui test dependent on the exact overhead of a given store.
 
733
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
739
734
       ), out)
740
735
        self.assertEqual('', err)
741
736
 
742
737
        # Show info about shared branch
743
 
        out, err = self.run_bzr('info repo/branch --verbose')
 
738
        out, err = self.runbzr('info repo/branch --verbose')
744
739
        self.assertEqualDiff(
745
 
"""Repository branch (format: dirstate or knit)
746
 
Location:
747
 
  shared repository: repo
748
 
  repository branch: repo/branch
 
740
"""Location:
 
741
  shared repository: %s
 
742
  repository branch: branch
749
743
 
750
744
Format:
751
745
       control: Meta directory format 1
754
748
 
755
749
Branch history:
756
750
         2 revisions
 
751
         1 committer
757
752
         0 days old
758
753
   first revision: %s
759
754
  latest revision: %s
760
755
 
761
756
Repository:
762
757
         2 revisions
763
 
""" % (format.get_branch_format().get_format_description(),
 
758
         %d KiB
 
759
""" % (repo.bzrdir.root_transport.base,
 
760
       format.get_branch_format().get_format_description(),
764
761
       format.repository_format.get_format_description(),
765
762
       datestring_first, datestring_last,
 
763
       # poking at _revision_store isn't all that clean, but neither is
 
764
       # having the ui test dependent on the exact overhead of a given store.
 
765
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
766
766
       ), out)
767
767
        self.assertEqual('', err)
768
768
 
769
769
        # Show info about repository with revisions
770
 
        out, err = self.run_bzr('info -v repo')
 
770
        out, err = self.runbzr('info repo')
771
771
        self.assertEqualDiff(
772
 
"""Shared repository (format: dirstate or dirstate-tags or knit)
773
 
Location:
774
 
  shared repository: repo
 
772
"""Location:
 
773
  shared repository: %s
775
774
 
776
775
Format:
777
776
       control: Meta directory format 1
779
778
 
780
779
Repository:
781
780
         2 revisions
782
 
""" % (format.repository_format.get_format_description(),
 
781
         %d KiB
 
782
""" % (repo.bzrdir.root_transport.base,
 
783
       format.repository_format.get_format_description(),
 
784
       # poking at _revision_store isn't all that clean, but neither is
 
785
       # having the ui test dependent on the exact overhead of a given store.
 
786
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
783
787
       ), out)
784
788
        self.assertEqual('', err)
785
789
 
790
794
        # Create shared repository with working trees
791
795
        repo = self.make_repository('repo', shared=True, format=format)
792
796
        repo.set_make_working_trees(True)
793
 
        out, err = self.run_bzr('info -v repo')
 
797
        out, err = self.runbzr('info repo')
794
798
        self.assertEqualDiff(
795
 
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
796
 
Location:
797
 
  shared repository: repo
 
799
"""Location:
 
800
  shared repository: %s
798
801
 
799
802
Format:
800
803
       control: Meta directory format 1
804
807
 
805
808
Repository:
806
809
         0 revisions
807
 
""" % (format.repository_format.get_format_description(),
 
810
         0 KiB
 
811
""" % (repo.bzrdir.root_transport.base,
 
812
       format.repository_format.get_format_description(),
808
813
       ), out)
809
814
        self.assertEqual('', err)
810
815
 
815
820
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
816
821
 
817
822
        # Empty first branch
818
 
        out, err = self.run_bzr('info repo/branch1 --verbose')
 
823
        out, err = self.runbzr('info repo/branch1 --verbose')
819
824
        self.assertEqualDiff(
820
 
"""Repository tree (format: knit)
821
 
Location:
822
 
  shared repository: repo
823
 
  repository branch: repo/branch1
 
825
"""Location:
 
826
    shared repository: %s
 
827
  repository checkout: branch1
824
828
 
825
829
Format:
826
830
       control: Meta directory format 1
840
844
 
841
845
Branch history:
842
846
         0 revisions
 
847
         0 committers
843
848
 
844
849
Repository:
845
850
         0 revisions
846
 
""" % (format.get_branch_format().get_format_description(),
 
851
         0 KiB
 
852
""" % (repo.bzrdir.root_transport.base,
 
853
       format.get_branch_format().get_format_description(),
847
854
       format.repository_format.get_format_description(),
848
855
       ), out)
849
856
        self.assertEqual('', err)
855
862
        tree1.commit('commit one')
856
863
        rev = repo.get_revision(branch1.revision_history()[0])
857
864
        datestring_first = format_date(rev.timestamp, rev.timezone)
858
 
        out, err = self.run_bzr('info -v repo/branch1')
 
865
        out, err = self.runbzr('info repo/branch1')
859
866
        self.assertEqualDiff(
860
 
"""Repository tree (format: knit)
861
 
Location:
862
 
  shared repository: repo
863
 
  repository branch: repo/branch1
 
867
"""Location:
 
868
    shared repository: %s
 
869
  repository checkout: branch1
864
870
 
865
871
Format:
866
872
       control: Meta directory format 1
886
892
 
887
893
Repository:
888
894
         1 revision
889
 
""" % (format.get_branch_format().get_format_description(),
 
895
         %d KiB
 
896
""" % (repo.bzrdir.root_transport.base,
 
897
       format.get_branch_format().get_format_description(),
890
898
       format.repository_format.get_format_description(),
891
899
       datestring_first, datestring_first,
 
900
       # poking at _revision_store isn't all that clean, but neither is
 
901
       # having the ui test dependent on the exact overhead of a given store.
 
902
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
892
903
       ), out)
893
904
        self.assertEqual('', err)
894
905
 
895
906
        # Out of date second branch
896
 
        out, err = self.run_bzr('info repo/branch2 --verbose')
 
907
        out, err = self.runbzr('info repo/branch2 --verbose')
897
908
        self.assertEqualDiff(
898
 
"""Repository tree (format: knit)
899
 
Location:
900
 
  shared repository: repo
901
 
  repository branch: repo/branch2
 
909
"""Location:
 
910
    shared repository: %s
 
911
  repository checkout: branch2
902
912
 
903
913
Related branches:
904
 
  parent branch: repo/branch1
 
914
  parent branch: %s
905
915
 
906
916
Format:
907
917
       control: Meta directory format 1
921
931
 
922
932
Branch history:
923
933
         0 revisions
 
934
         0 committers
924
935
 
925
936
Repository:
926
937
         1 revision
927
 
""" % (format.get_branch_format().get_format_description(),
 
938
         %d KiB
 
939
""" % (repo.bzrdir.root_transport.base,
 
940
       branch1.bzrdir.root_transport.base,
 
941
       format.get_branch_format().get_format_description(),
928
942
       format.repository_format.get_format_description(),
 
943
       # poking at _revision_store isn't all that clean, but neither is
 
944
       # having the ui test dependent on the exact overhead of a given store.
 
945
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
929
946
       ), out)
930
947
        self.assertEqual('', err)
931
948
 
932
949
        # Update second branch
933
950
        tree2 = branch2.bzrdir.open_workingtree()
934
951
        tree2.pull(branch1)
935
 
        out, err = self.run_bzr('info -v repo/branch2')
 
952
        out, err = self.runbzr('info repo/branch2')
936
953
        self.assertEqualDiff(
937
 
"""Repository tree (format: knit)
938
 
Location:
939
 
  shared repository: repo
940
 
  repository branch: repo/branch2
 
954
"""Location:
 
955
    shared repository: %s
 
956
  repository checkout: branch2
941
957
 
942
958
Related branches:
943
 
  parent branch: repo/branch1
 
959
  parent branch: %s
944
960
 
945
961
Format:
946
962
       control: Meta directory format 1
966
982
 
967
983
Repository:
968
984
         1 revision
969
 
""" % (format.get_branch_format().get_format_description(),
 
985
         %d KiB
 
986
""" % (repo.bzrdir.root_transport.base,
 
987
       branch1.bzrdir.root_transport.base,
 
988
       format.get_branch_format().get_format_description(),
970
989
       format.repository_format.get_format_description(),
971
990
       datestring_first, datestring_first,
 
991
       # poking at _revision_store isn't all that clean, but neither is
 
992
       # having the ui test dependent on the exact overhead of a given store.
 
993
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
972
994
       ), out)
973
995
        self.assertEqual('', err)
974
996
 
975
997
        # Show info about repository with revisions
976
 
        out, err = self.run_bzr('info -v repo')
 
998
        out, err = self.runbzr('info repo')
977
999
        self.assertEqualDiff(
978
 
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
979
 
Location:
980
 
  shared repository: repo
 
1000
"""Location:
 
1001
  shared repository: %s
981
1002
 
982
1003
Format:
983
1004
       control: Meta directory format 1
987
1008
 
988
1009
Repository:
989
1010
         1 revision
990
 
""" % (format.repository_format.get_format_description(),
 
1011
         %d KiB
 
1012
""" % (repo.bzrdir.root_transport.base,
 
1013
       format.repository_format.get_format_description(),
 
1014
       # poking at _revision_store isn't all that clean, but neither is
 
1015
       # having the ui test dependent on the exact overhead of a given store.
 
1016
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
991
1017
       ),
992
1018
       out)
993
1019
        self.assertEqual('', err)
994
 
 
 
1020
    
995
1021
    def test_info_shared_repository_with_tree_in_root(self):
996
1022
        format = bzrdir.format_registry.make_bzrdir('knit')
997
1023
        transport = self.get_transport()
999
1025
        # Create shared repository with working trees
1000
1026
        repo = self.make_repository('repo', shared=True, format=format)
1001
1027
        repo.set_make_working_trees(True)
1002
 
        out, err = self.run_bzr('info -v repo')
 
1028
        out, err = self.runbzr('info repo')
1003
1029
        self.assertEqualDiff(
1004
 
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1005
 
Location:
1006
 
  shared repository: repo
 
1030
"""Location:
 
1031
  shared repository: %s
1007
1032
 
1008
1033
Format:
1009
1034
       control: Meta directory format 1
1013
1038
 
1014
1039
Repository:
1015
1040
         0 revisions
1016
 
""" % (format.repository_format.get_format_description(),
 
1041
         0 KiB
 
1042
""" % (repo.bzrdir.root_transport.base,
 
1043
       format.repository_format.get_format_description(),
1017
1044
       ), out)
1018
1045
        self.assertEqual('', err)
1019
1046
 
1021
1048
        control = repo.bzrdir
1022
1049
        branch = control.create_branch()
1023
1050
        control.create_workingtree()
1024
 
        out, err = self.run_bzr('info -v repo')
 
1051
        out, err = self.runbzr('info repo')
1025
1052
        self.assertEqualDiff(
1026
 
"""Repository tree (format: knit)
1027
 
Location:
1028
 
  shared repository: repo
1029
 
  repository branch: repo
 
1053
"""Location:
 
1054
    shared repository: %s
 
1055
  repository checkout: .
1030
1056
 
1031
1057
Format:
1032
1058
       control: Meta directory format 1
1049
1075
 
1050
1076
Repository:
1051
1077
         0 revisions
1052
 
""" % (format.get_branch_format().get_format_description(),
 
1078
         0 KiB
 
1079
""" % (repo.bzrdir.root_transport.base,
 
1080
       format.get_branch_format().get_format_description(),
1053
1081
       format.repository_format.get_format_description(),
1054
1082
       ), out)
1055
1083
        self.assertEqual('', err)
1056
1084
 
1057
 
    def test_info_repository_hook(self):
1058
 
        format = bzrdir.format_registry.make_bzrdir('knit')
1059
 
        def repo_info(repo, stats, outf):
1060
 
            outf.write("more info\n")
1061
 
        info.hooks.install_named_hook('repository', repo_info, None)
1062
 
        # Create shared repository with working trees
1063
 
        repo = self.make_repository('repo', shared=True, format=format)
1064
 
        out, err = self.run_bzr('info -v repo')
1065
 
        self.assertEqualDiff(
1066
 
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1067
 
Location:
1068
 
  shared repository: repo
1069
 
 
1070
 
Format:
1071
 
       control: Meta directory format 1
1072
 
    repository: %s
1073
 
 
1074
 
Create working tree for new branches inside the repository.
1075
 
 
1076
 
Repository:
1077
 
         0 revisions
1078
 
more info
1079
 
""" % (format.repository_format.get_format_description(),
1080
 
       ), out)
1081
 
        self.assertEqual('', err)
1082
 
 
1083
 
    def assertCheckoutStatusOutput(self,
 
1085
    def assertCheckoutStatusOutput(self, 
1084
1086
        command_string, lco_tree, shared_repo=None,
1085
1087
        repo_branch=None,
1086
1088
        tree_locked=False,
1087
1089
        branch_locked=False, repo_locked=False,
1088
1090
        verbose=False,
1089
 
        light_checkout=True,
1090
 
        checkout_root=None):
1091
 
        """Check the output of info in a checkout.
 
1091
        light_checkout=True):
 
1092
        """Check the output of info in a light checkout tree.
1092
1093
 
1093
1094
        This is not quite a mirror of the info code: rather than using the
1094
1095
        tree being examined to predict output, it uses a bunch of flags which
1095
1096
        allow us, the test writers, to document what *should* be present in
1096
1097
        the output. Removing this separation would remove the value of the
1097
1098
        tests.
1098
 
 
 
1099
        
1099
1100
        :param path: the path to the light checkout.
1100
1101
        :param lco_tree: the tree object for the light checkout.
1101
1102
        :param shared_repo: A shared repository is in use, expect that in
1105
1106
        :param tree_locked: If true, expect the tree to be locked.
1106
1107
        :param branch_locked: If true, expect the branch to be locked.
1107
1108
        :param repo_locked: If true, expect the repository to be locked.
1108
 
            Note that the lco_tree.branch.repository is inspected, and if is not
1109
 
            actually locked then this parameter is overridden. This is because
1110
 
            pack repositories do not have any public API for obtaining an
1111
 
            exclusive repository wide lock.
1112
 
        :param verbose: verbosity level: 2 or higher to show committers
 
1109
        :param verbose: If true, expect verbose output
1113
1110
        """
1114
 
        def friendly_location(url):
1115
 
            path = urlutils.unescape_for_display(url, 'ascii')
1116
 
            try:
1117
 
                return osutils.relpath(osutils.getcwd(), path)
1118
 
            except errors.PathNotChild:
1119
 
                return path
1120
 
 
1121
 
        if tree_locked:
1122
 
            # We expect this to fail because of locking errors.
1123
 
            # (A write-locked file cannot be read-locked
1124
 
            # in the different process -- either on win32 or on linux).
1125
 
            # This should be removed when the locking errors are fixed.
1126
 
            self.expectFailure('OS locks are exclusive '
1127
 
                'for different processes (Bug #174055)',
1128
 
                self.run_bzr_subprocess,
1129
 
                'info ' + command_string)
1130
 
        out, err = self.run_bzr('info %s' % command_string)
1131
 
        description = {
1132
 
            (True, True): 'Lightweight checkout',
1133
 
            (True, False): 'Repository checkout',
1134
 
            (False, True): 'Lightweight checkout',
1135
 
            (False, False): 'Checkout',
1136
 
            }[(shared_repo is not None, light_checkout)]
1137
 
        format = {True: '1.6 or 1.6.1-rich-root'
1138
 
                        ' or 1.9 or 1.9-rich-root'
1139
 
                        ' or dirstate or dirstate-tags or pack-0.92'
1140
 
                        ' or rich-root or rich-root-pack',
1141
 
                  False: 'dirstate'}[light_checkout]
1142
 
        if repo_locked:
1143
 
            repo_locked = lco_tree.branch.repository.get_physical_lock_status()
 
1111
        out, err = self.runbzr('info %s' % command_string)
1144
1112
        if repo_locked or branch_locked or tree_locked:
1145
1113
            def locked_message(a_bool):
1146
1114
                if a_bool:
1158
1126
                    locked_message(repo_locked)))
1159
1127
        else:
1160
1128
            expected_lock_output = ''
1161
 
        tree_data = ''
1162
 
        extra_space = ''
1163
1129
        if light_checkout:
1164
 
            tree_data = ("  light checkout root: %s\n" %
1165
 
                friendly_location(lco_tree.bzrdir.root_transport.base))
1166
 
            extra_space = ' '
1167
 
        if lco_tree.branch.get_bound_location() is not None:
1168
 
            tree_data += ("%s       checkout root: %s\n" % (extra_space,
1169
 
                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)
1170
1135
        if shared_repo is not None:
1171
1136
            branch_data = (
1172
 
                "   checkout of branch: %s\n"
1173
 
                "    shared repository: %s\n" %
1174
 
                (friendly_location(repo_branch.bzrdir.root_transport.base),
1175
 
                 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)
1176
1140
        elif repo_branch is not None:
1177
1141
            branch_data = (
1178
 
                "%s  checkout of branch: %s\n" %
1179
 
                (extra_space,
1180
 
                 friendly_location(repo_branch.bzrdir.root_transport.base)))
 
1142
                "  checkout of branch: %s\n" % 
 
1143
                repo_branch.bzrdir.root_transport.base)
1181
1144
        else:
1182
 
            branch_data = ("   checkout of branch: %s\n" %
 
1145
            branch_data = ("  checkout of branch: %s\n" % 
1183
1146
                lco_tree.branch.bzrdir.root_transport.base)
1184
 
 
1185
 
        if verbose >= 2:
 
1147
        
 
1148
        if verbose:
1186
1149
            verbose_info = '         0 committers\n'
1187
1150
        else:
1188
1151
            verbose_info = ''
1189
 
 
 
1152
            
1190
1153
        self.assertEqualDiff(
1191
 
"""%s (format: %s)
1192
 
Location:
1193
 
%s%s
 
1154
"""Location:
 
1155
%s
 
1156
%s
1194
1157
Format:
1195
1158
       control: Meta directory format 1
1196
1159
  working tree: %s
1212
1175
%s
1213
1176
Repository:
1214
1177
         0 revisions
1215
 
""" %  (description,
1216
 
        format,
1217
 
        tree_data,
 
1178
         0 KiB
 
1179
""" %  (tree_data,
1218
1180
        branch_data,
1219
1181
        lco_tree._format.get_format_description(),
1220
1182
        lco_tree.branch._format.get_format_description(),
1228
1190
        transport = self.get_transport()
1229
1191
        # Create shared repository with a branch
1230
1192
        repo = self.make_repository('repo', shared=True,
1231
 
                                    format=bzrdir.BzrDirMetaFormat1())
 
1193
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
1232
1194
        repo.set_make_working_trees(False)
1233
1195
        repo.bzrdir.root_transport.mkdir('branch')
1234
1196
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1235
 
                                    format=bzrdir.BzrDirMetaFormat1())
 
1197
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
1236
1198
        # Do a heavy checkout
1237
1199
        transport.mkdir('tree')
1238
1200
        transport.mkdir('tree/checkout')
1239
 
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1240
 
            format=bzrdir.BzrDirMetaFormat1())
 
1201
        co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
 
1202
            format=bzrlib.bzrdir.BzrDirMetaFormat1())
1241
1203
        co_branch.bind(repo_branch)
1242
1204
        # Do a light checkout of the heavy one
1243
1205
        transport.mkdir('tree/lightcheckout')
1244
 
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1245
 
        branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
 
1206
        lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
 
1207
        bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1246
1208
        lco_dir.create_workingtree()
1247
1209
        lco_tree = lco_dir.open_workingtree()
1248
1210
 
1250
1212
        # W B R
1251
1213
 
1252
1214
        # U U U
1253
 
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
1254
 
                                        repo_branch=repo_branch,
1255
 
                                        verbose=True, light_checkout=True)
 
1215
        self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1256
1216
        # U U L
1257
1217
        lco_tree.branch.repository.lock_write()
1258
1218
        try:
1259
 
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1260
 
            lco_tree, repo_branch=repo_branch,
1261
 
            repo_locked=True, verbose=True, light_checkout=True)
 
1219
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1220
            lco_tree,
 
1221
            repo_locked=True)
1262
1222
        finally:
1263
1223
            lco_tree.branch.repository.unlock()
1264
1224
        # U L L
1265
1225
        lco_tree.branch.lock_write()
1266
1226
        try:
1267
 
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1227
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1268
1228
            lco_tree,
1269
1229
            branch_locked=True,
1270
 
            repo_locked=True,
1271
 
            repo_branch=repo_branch,
1272
 
            verbose=True)
 
1230
            repo_locked=True)
1273
1231
        finally:
1274
1232
            lco_tree.branch.unlock()
1275
1233
        # L L L
1276
1234
        lco_tree.lock_write()
1277
1235
        try:
1278
 
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1279
 
            lco_tree, repo_branch=repo_branch,
 
1236
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1237
            lco_tree,
1280
1238
            tree_locked=True,
1281
1239
            branch_locked=True,
1282
 
            repo_locked=True,
1283
 
            verbose=True)
 
1240
            repo_locked=True)
1284
1241
        finally:
1285
1242
            lco_tree.unlock()
1286
1243
        # L L U
1287
1244
        lco_tree.lock_write()
1288
1245
        lco_tree.branch.repository.unlock()
1289
1246
        try:
1290
 
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1291
 
            lco_tree, repo_branch=repo_branch,
 
1247
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1248
            lco_tree,
1292
1249
            tree_locked=True,
1293
 
            branch_locked=True,
1294
 
            verbose=True)
 
1250
            branch_locked=True)
1295
1251
        finally:
1296
1252
            lco_tree.branch.repository.lock_write()
1297
1253
            lco_tree.unlock()
1299
1255
        lco_tree.lock_write()
1300
1256
        lco_tree.branch.unlock()
1301
1257
        try:
1302
 
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1303
 
            lco_tree, repo_branch=repo_branch,
1304
 
            tree_locked=True,
1305
 
            verbose=True)
 
1258
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1259
            lco_tree,
 
1260
            tree_locked=True)
1306
1261
        finally:
1307
1262
            lco_tree.branch.lock_write()
1308
1263
            lco_tree.unlock()
1311
1266
        lco_tree.branch.unlock()
1312
1267
        lco_tree.branch.repository.lock_write()
1313
1268
        try:
1314
 
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1315
 
            lco_tree, repo_branch=repo_branch,
 
1269
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1270
            lco_tree,
1316
1271
            tree_locked=True,
1317
 
            repo_locked=True,
1318
 
            verbose=True)
 
1272
            repo_locked=True)
1319
1273
        finally:
1320
1274
            lco_tree.branch.repository.unlock()
1321
1275
            lco_tree.branch.lock_write()
1324
1278
        lco_tree.branch.lock_write()
1325
1279
        lco_tree.branch.repository.unlock()
1326
1280
        try:
1327
 
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
1328
 
            lco_tree, repo_branch=repo_branch,
1329
 
            branch_locked=True,
1330
 
            verbose=True)
 
1281
            self.assertCheckoutStatusOutput('tree/lightcheckout',
 
1282
            lco_tree,
 
1283
            branch_locked=True)
1331
1284
        finally:
1332
1285
            lco_tree.branch.repository.lock_write()
1333
1286
            lco_tree.branch.unlock()
1334
1287
 
1335
 
        if sys.platform == 'win32':
1336
 
            self.knownFailure('Win32 cannot run "bzr info"'
1337
 
                              ' when the tree is locked.')
1338
 
 
1339
1288
    def test_info_locking_oslocks(self):
1340
1289
        if sys.platform == "win32":
1341
1290
            raise TestSkipped("don't use oslocks on win32 in unix manner")
1342
1291
 
1343
1292
        tree = self.make_branch_and_tree('branch',
1344
 
                                         format=bzrdir.BzrDirFormat6())
 
1293
                                         format=bzrlib.bzrdir.BzrDirFormat6())
1345
1294
 
1346
1295
        # Test all permutations of locking the working tree, branch and repository
1347
1296
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1350
1299
        # W B R
1351
1300
 
1352
1301
        # U U U
1353
 
        out, err = self.run_bzr('info -v branch')
 
1302
        out, err = self.runbzr('info branch')
1354
1303
        self.assertEqualDiff(
1355
 
"""Standalone tree (format: weave)
1356
 
Location:
 
1304
"""Location:
1357
1305
  branch root: %s
1358
1306
 
1359
1307
Format:
1377
1325
 
1378
1326
Repository:
1379
1327
         0 revisions
1380
 
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1328
         0 KiB
 
1329
""" % (tree.bzrdir.root_transport.base,
 
1330
       tree.branch.repository._format.get_format_description(),
1381
1331
       ), out)
1382
1332
        self.assertEqual('', err)
1383
1333
        # L L L
1384
1334
        tree.lock_write()
1385
 
        out, err = self.run_bzr('info -v branch')
 
1335
        out, err = self.runbzr('info branch')
1386
1336
        self.assertEqualDiff(
1387
 
"""Standalone tree (format: weave)
1388
 
Location:
 
1337
"""Location:
1389
1338
  branch root: %s
1390
1339
 
1391
1340
Format:
1409
1358
 
1410
1359
Repository:
1411
1360
         0 revisions
1412
 
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1361
         0 KiB
 
1362
""" % (tree.bzrdir.root_transport.base,
 
1363
       tree.branch.repository._format.get_format_description(),
1413
1364
       ), out)
1414
1365
        self.assertEqual('', err)
1415
1366
        tree.unlock()
1416
 
 
1417
 
    def test_info_stacked(self):
1418
 
        # We have a mainline
1419
 
        trunk_tree = self.make_branch_and_tree('mainline',
1420
 
            format='1.6')
1421
 
        trunk_tree.commit('mainline')
1422
 
        # and a branch from it which is stacked
1423
 
        new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1424
 
        out, err = self.run_bzr('info newbranch')
1425
 
        self.assertEqual(
1426
 
"""Standalone tree (format: 1.6)
1427
 
Location:
1428
 
  branch root: newbranch
1429
 
 
1430
 
Related branches:
1431
 
  parent branch: mainline
1432
 
     stacked on: mainline
1433
 
""", out)
1434
 
        self.assertEqual("", err)