~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2008-05-21 11:58:09 UTC
  • mto: (3452.2.9 inter-remote-pack)
  • mto: This revision was merged to the branch mainline in revision 3511.
  • Revision ID: andrew.bennetts@canonical.com-20080521115809-6cw3t8gn4qm0bpg9
Remove a bit more debugging cruft.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 by Canonical Ltd
2
 
# -*- coding: utf-8 -*-
3
 
 
 
1
# Copyright (C) 2006, 2007 Canonical Ltd
 
2
#
4
3
# This program is free software; you can redistribute it and/or modify
5
4
# it under the terms of the GNU General Public License as published by
6
5
# the Free Software Foundation; either version 2 of the License, or
7
6
# (at your option) any later version.
8
 
 
 
7
#
9
8
# This program is distributed in the hope that it will be useful,
10
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
11
# GNU General Public License for more details.
13
 
 
 
12
#
14
13
# You should have received a copy of the GNU General Public License
15
14
# along with this program; if not, write to the Free Software
16
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
17
 
19
18
"""Tests for the info command of bzr."""
20
19
 
 
20
import os
21
21
import sys
22
22
 
23
23
import bzrlib
 
24
from bzrlib import (
 
25
    bzrdir,
 
26
    errors,
 
27
    info,
 
28
    osutils,
 
29
    repository,
 
30
    urlutils,
 
31
    )
24
32
from bzrlib.osutils import format_date
25
33
from bzrlib.tests import TestSkipped
26
34
from bzrlib.tests.blackbox import ExternalBase
33
41
            location = "C:/i/do/not/exist/"
34
42
        else:
35
43
            location = "/i/do/not/exist/"
36
 
        out, err = self.runbzr('info '+location, retcode=3)
 
44
        out, err = self.run_bzr('info '+location, retcode=3)
37
45
        self.assertEqual(out, '')
38
 
        self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
 
46
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
39
47
 
40
48
    def test_info_standalone(self):
41
49
        transport = self.get_transport()
42
50
 
43
51
        # Create initial standalone branch
44
 
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
45
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
46
 
        tree1 = self.make_branch_and_tree('standalone')
47
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
 
52
        tree1 = self.make_branch_and_tree('standalone', 'weave')
48
53
        self.build_tree(['standalone/a'])
49
54
        tree1.add('a')
50
55
        branch1 = tree1.branch
51
 
        out, err = self.runbzr('info standalone')
52
 
        self.assertEqualDiff(
53
 
"""Location:
54
 
  branch root: %s
 
56
 
 
57
        out, err = self.run_bzr('info standalone')
 
58
        self.assertEqualDiff(
 
59
"""Standalone tree (format: weave)
 
60
Location:
 
61
  branch root: standalone
 
62
""", out)
 
63
        self.assertEqual('', err)
 
64
 
 
65
        out, err = self.run_bzr('info standalone -v')
 
66
        self.assertEqualDiff(
 
67
"""Standalone tree (format: weave)
 
68
Location:
 
69
  branch root: standalone
55
70
 
56
71
Format:
57
72
       control: All-in-one format 6
71
86
 
72
87
Branch history:
73
88
         0 revisions
 
89
         0 committers
74
90
 
75
 
Revision store:
 
91
Repository:
76
92
         0 revisions
77
93
         0 KiB
78
 
""" % branch1.bzrdir.root_transport.base, out)
 
94
""", out)
79
95
        self.assertEqual('', err)
80
96
        tree1.commit('commit one')
81
97
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
84
100
        # Branch standalone with push location
85
101
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
86
102
        branch2.set_push_location(branch1.bzrdir.root_transport.base)
87
 
        out, err = self.runbzr('info branch --verbose')
88
 
        self.assertEqualDiff(
89
 
"""Location:
90
 
  branch root: %s
91
 
 
92
 
Related branches:
93
 
      parent branch: %s
94
 
  publish to branch: %s
 
103
 
 
104
        out, err = self.run_bzr('info branch')
 
105
        self.assertEqualDiff(
 
106
"""Standalone tree (format: weave)
 
107
Location:
 
108
  branch root: branch
 
109
 
 
110
Related branches:
 
111
    push branch: standalone
 
112
  parent branch: standalone
 
113
""", out)
 
114
        self.assertEqual('', err)
 
115
 
 
116
        out, err = self.run_bzr('info branch --verbose')
 
117
        self.assertEqualDiff(
 
118
"""Standalone tree (format: weave)
 
119
Location:
 
120
  branch root: branch
 
121
 
 
122
Related branches:
 
123
    push branch: standalone
 
124
  parent branch: standalone
95
125
 
96
126
Format:
97
127
       control: All-in-one format 6
116
146
   first revision: %s
117
147
  latest revision: %s
118
148
 
119
 
Revision store:
 
149
Repository:
120
150
         1 revision
121
151
         %d KiB
122
 
""" % (branch2.bzrdir.root_transport.base,
123
 
       branch1.bzrdir.root_transport.base,
124
 
       branch1.bzrdir.root_transport.base,
125
 
       datestring_first, datestring_first,
 
152
""" % (datestring_first, datestring_first,
126
153
       # poking at _revision_store isn't all that clean, but neither is
127
154
       # having the ui test dependent on the exact overhead of a given store.
128
155
       branch2.repository._revision_store.total_size(
133
160
        # Branch and bind to standalone, needs upgrade to metadir
134
161
        # (creates backup as unknown)
135
162
        branch1.bzrdir.sprout('bound')
136
 
        bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
 
163
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
 
164
        bzrlib.upgrade.upgrade('bound', knit1_format)
137
165
        branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
138
166
        branch3.bind(branch1)
139
 
        out, err = self.runbzr('info bound')
 
167
        bound_tree = branch3.bzrdir.open_workingtree()
 
168
        out, err = self.run_bzr('info -v bound')
140
169
        self.assertEqualDiff(
141
 
"""Location:
142
 
       checkout root: %s
143
 
  checkout of branch: %s
 
170
"""Checkout (format: knit)
 
171
Location:
 
172
       checkout root: bound
 
173
  checkout of branch: standalone
144
174
 
145
175
Related branches:
146
 
  parent branch: %s
 
176
  parent branch: standalone
147
177
 
148
178
Format:
149
179
       control: Meta directory format 1
150
 
  working tree: Working tree format 3
151
 
        branch: Branch format 5
 
180
  working tree: %s
 
181
        branch: %s
152
182
    repository: %s
153
183
 
154
184
In the working tree:
163
193
 
164
194
Branch history:
165
195
         1 revision
 
196
         1 committer
166
197
         0 days old
167
198
   first revision: %s
168
199
  latest revision: %s
169
200
 
170
 
Revision store:
 
201
Repository:
171
202
         1 revision
172
203
         %d KiB
173
 
""" % (branch3.bzrdir.root_transport.base,
174
 
       branch1.bzrdir.root_transport.base,
175
 
       branch1.bzrdir.root_transport.base,
 
204
""" % (bound_tree._format.get_format_description(),
 
205
       branch3._format.get_format_description(),
176
206
       branch3.repository._format.get_format_description(),
177
207
       datestring_first, datestring_first,
178
208
       # poking at _revision_store isn't all that clean, but neither is
183
213
        self.assertEqual('', err)
184
214
 
185
215
        # Checkout standalone (same as above, but does not have parent set)
186
 
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
187
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
188
 
        branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout')
189
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
 
216
        branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
 
217
            format=knit1_format)
190
218
        branch4.bind(branch1)
191
219
        branch4.bzrdir.open_workingtree().update()
192
 
        out, err = self.runbzr('info checkout --verbose')
 
220
        out, err = self.run_bzr('info checkout --verbose')
193
221
        self.assertEqualDiff(
194
 
"""Location:
195
 
       checkout root: %s
196
 
  checkout of branch: %s
 
222
"""Checkout (format: knit)
 
223
Location:
 
224
       checkout root: checkout
 
225
  checkout of branch: standalone
197
226
 
198
227
Format:
199
228
       control: Meta directory format 1
218
247
   first revision: %s
219
248
  latest revision: %s
220
249
 
221
 
Revision store:
 
250
Repository:
222
251
         1 revision
223
252
         %d KiB
224
 
""" % (branch4.bzrdir.root_transport.base,
225
 
       branch1.bzrdir.root_transport.base,
226
 
       branch4.repository._format.get_format_description(),
 
253
""" % (branch4.repository._format.get_format_description(),
227
254
       datestring_first, datestring_first,
228
255
       # poking at _revision_store isn't all that clean, but neither is
229
256
       # having the ui test dependent on the exact overhead of a given store.
233
260
        self.assertEqual('', err)
234
261
 
235
262
        # Lightweight checkout (same as above, different branch and repository)
236
 
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
237
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
238
 
        transport.mkdir('lightcheckout')
239
 
        dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
240
 
        bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
241
 
        dir5.create_workingtree()
242
 
        tree5 = dir5.open_workingtree()
243
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
 
263
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
244
264
        branch5 = tree5.branch
245
 
        out, err = self.runbzr('info lightcheckout')
 
265
        out, err = self.run_bzr('info -v lightcheckout')
246
266
        self.assertEqualDiff(
247
 
"""Location:
248
 
  light checkout root: %s
249
 
   checkout of branch: %s
 
267
"""Lightweight checkout (format: dirstate or dirstate-tags or \
 
268
pack-0.92 or rich-root or rich-root-pack)
 
269
Location:
 
270
  light checkout root: lightcheckout
 
271
   checkout of branch: standalone
250
272
 
251
273
Format:
252
274
       control: Meta directory format 1
253
 
  working tree: Working tree format 3
 
275
  working tree: Working tree format 4
254
276
        branch: Branch format 4
255
277
    repository: Weave repository format 6
256
278
 
266
288
 
267
289
Branch history:
268
290
         1 revision
 
291
         1 committer
269
292
         0 days old
270
293
   first revision: %s
271
294
  latest revision: %s
272
295
 
273
 
Revision store:
 
296
Repository:
274
297
         1 revision
275
298
         0 KiB
276
 
""" % (tree5.bzrdir.root_transport.base,
277
 
       branch1.bzrdir.root_transport.base,
278
 
       datestring_first, datestring_first,
279
 
       ), out)
 
299
""" % (datestring_first, datestring_first,), out)
280
300
        self.assertEqual('', err)
281
301
 
282
302
        # Update initial standalone branch
287
307
        datestring_last = format_date(rev.timestamp, rev.timezone)
288
308
 
289
309
        # Out of date branched standalone branch will not be detected
290
 
        out, err = self.runbzr('info branch')
 
310
        out, err = self.run_bzr('info -v branch')
291
311
        self.assertEqualDiff(
292
 
"""Location:
293
 
  branch root: %s
 
312
"""Standalone tree (format: weave)
 
313
Location:
 
314
  branch root: branch
294
315
 
295
316
Related branches:
296
 
      parent branch: %s
297
 
  publish to branch: %s
 
317
    push branch: standalone
 
318
  parent branch: standalone
298
319
 
299
320
Format:
300
321
       control: All-in-one format 6
314
335
 
315
336
Branch history:
316
337
         1 revision
 
338
         1 committer
317
339
         0 days old
318
340
   first revision: %s
319
341
  latest revision: %s
320
342
 
321
 
Revision store:
 
343
Repository:
322
344
         1 revision
323
345
         0 KiB
324
 
""" % (branch2.bzrdir.root_transport.base,
325
 
       branch1.bzrdir.root_transport.base,
326
 
       branch1.bzrdir.root_transport.base,
327
 
       datestring_first, datestring_first,
 
346
""" % (datestring_first, datestring_first,
328
347
       ), out)
329
348
        self.assertEqual('', err)
330
349
 
331
350
        # Out of date bound branch
332
 
        out, err = self.runbzr('info bound')
 
351
        out, err = self.run_bzr('info -v bound')
333
352
        self.assertEqualDiff(
334
 
"""Location:
335
 
       checkout root: %s
336
 
  checkout of branch: %s
 
353
"""Checkout (format: knit)
 
354
Location:
 
355
       checkout root: bound
 
356
  checkout of branch: standalone
337
357
 
338
358
Related branches:
339
 
  parent branch: %s
 
359
  parent branch: standalone
340
360
 
341
361
Format:
342
362
       control: Meta directory format 1
358
378
 
359
379
Branch history:
360
380
         1 revision
 
381
         1 committer
361
382
         0 days old
362
383
   first revision: %s
363
384
  latest revision: %s
364
385
 
365
 
Revision store:
 
386
Repository:
366
387
         1 revision
367
388
         %d KiB
368
 
""" % (branch3.bzrdir.root_transport.base,
369
 
       branch1.bzrdir.root_transport.base,
370
 
       branch1.bzrdir.root_transport.base,
371
 
       branch3.repository._format.get_format_description(),
 
389
""" % (branch3.repository._format.get_format_description(),
372
390
       datestring_first, datestring_first,
373
391
       # poking at _revision_store isn't all that clean, but neither is
374
392
       # having the ui test dependent on the exact overhead of a given store.
378
396
        self.assertEqual('', err)
379
397
 
380
398
        # Out of date checkout
381
 
        out, err = self.runbzr('info checkout')
 
399
        out, err = self.run_bzr('info -v checkout')
382
400
        self.assertEqualDiff(
383
 
"""Location:
384
 
       checkout root: %s
385
 
  checkout of branch: %s
 
401
"""Checkout (format: knit)
 
402
Location:
 
403
       checkout root: checkout
 
404
  checkout of branch: standalone
386
405
 
387
406
Format:
388
407
       control: Meta directory format 1
404
423
 
405
424
Branch history:
406
425
         1 revision
 
426
         1 committer
407
427
         0 days old
408
428
   first revision: %s
409
429
  latest revision: %s
410
430
 
411
 
Revision store:
 
431
Repository:
412
432
         1 revision
413
433
         %d KiB
414
 
""" % (branch4.bzrdir.root_transport.base,
415
 
       branch1.bzrdir.root_transport.base,
416
 
       branch4.repository._format.get_format_description(),
 
434
""" % (branch4.repository._format.get_format_description(),
417
435
       datestring_first, datestring_first,
418
436
       # poking at _revision_store isn't all that clean, but neither is
419
437
       # having the ui test dependent on the exact overhead of a given store.
423
441
        self.assertEqual('', err)
424
442
 
425
443
        # Out of date lightweight checkout
426
 
        out, err = self.runbzr('info lightcheckout --verbose')
 
444
        out, err = self.run_bzr('info lightcheckout --verbose')
427
445
        self.assertEqualDiff(
428
 
"""Location:
429
 
  light checkout root: %s
430
 
   checkout of branch: %s
 
446
"""Lightweight checkout (format: dirstate or dirstate-tags or \
 
447
pack-0.92 or rich-root or rich-root-pack)
 
448
Location:
 
449
  light checkout root: lightcheckout
 
450
   checkout of branch: standalone
431
451
 
432
452
Format:
433
453
       control: Meta directory format 1
434
 
  working tree: Working tree format 3
 
454
  working tree: Working tree format 4
435
455
        branch: Branch format 4
436
456
    repository: Weave repository format 6
437
457
 
454
474
   first revision: %s
455
475
  latest revision: %s
456
476
 
457
 
Revision store:
 
477
Repository:
458
478
         2 revisions
459
479
         0 KiB
460
 
""" % (tree5.bzrdir.root_transport.base,
461
 
       branch1.bzrdir.root_transport.base,
462
 
       datestring_first, datestring_last,
463
 
       ), out)
 
480
""" % (datestring_first, datestring_last,), out)
464
481
        self.assertEqual('', err)
465
482
 
466
483
    def test_info_standalone_no_tree(self):
467
484
        # create standalone branch without a working tree
 
485
        format = bzrdir.format_registry.make_bzrdir('default')
468
486
        branch = self.make_branch('branch')
469
487
        repo = branch.repository
470
 
        out, err = self.runbzr('info branch')
 
488
        out, err = self.run_bzr('info branch -v')
471
489
        self.assertEqualDiff(
472
 
"""Location:
473
 
  branch root: %s
 
490
"""Standalone branch (format: %s)
 
491
Location:
 
492
  branch root: branch
474
493
 
475
494
Format:
476
495
       control: Meta directory format 1
477
 
        branch: Branch format 5
 
496
        branch: %s
478
497
    repository: %s
479
498
 
480
499
Branch history:
481
500
         0 revisions
 
501
         0 committers
482
502
 
483
 
Revision store:
 
503
Repository:
484
504
         0 revisions
485
505
         0 KiB
486
 
""" % (branch.bzrdir.root_transport.base,
487
 
       repo._format.get_format_description(),
 
506
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
 
507
       format.get_branch_format().get_format_description(),
 
508
       format.repository_format.get_format_description(),
488
509
       ), out)
489
510
        self.assertEqual('', err)
490
511
 
491
512
    def test_info_shared_repository(self):
492
 
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
493
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
 
513
        format = bzrdir.format_registry.make_bzrdir('knit')
494
514
        transport = self.get_transport()
495
515
 
496
516
        # Create shared repository
497
 
        repo = self.make_repository('repo', shared=True)
 
517
        repo = self.make_repository('repo', shared=True, format=format)
498
518
        repo.set_make_working_trees(False)
499
 
        out, err = self.runbzr('info repo')
 
519
        out, err = self.run_bzr('info -v repo')
500
520
        self.assertEqualDiff(
501
 
"""Location:
 
521
"""Shared repository (format: dirstate or dirstate-tags or knit)
 
522
Location:
502
523
  shared repository: %s
503
524
 
504
525
Format:
505
526
       control: Meta directory format 1
506
527
    repository: %s
507
528
 
508
 
Revision store:
 
529
Repository:
509
530
         0 revisions
510
531
         0 KiB
511
 
""" % (repo.bzrdir.root_transport.base,
512
 
       repo._format.get_format_description(),
 
532
""" % ('repo', format.repository_format.get_format_description(),
513
533
       ), out)
514
534
        self.assertEqual('', err)
515
535
 
516
536
        # Create branch inside shared repository
517
537
        repo.bzrdir.root_transport.mkdir('branch')
518
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
519
 
        out, err = self.runbzr('info repo/branch')
 
538
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
 
539
            format=format)
 
540
        out, err = self.run_bzr('info -v repo/branch')
520
541
        self.assertEqualDiff(
521
 
"""Location:
522
 
  shared repository: %s
523
 
  repository branch: branch
 
542
"""Repository branch (format: dirstate or knit)
 
543
Location:
 
544
  shared repository: repo
 
545
  repository branch: repo/branch
524
546
 
525
547
Format:
526
548
       control: Meta directory format 1
527
 
        branch: Branch format 5
 
549
        branch: %s
528
550
    repository: %s
529
551
 
530
552
Branch history:
531
553
         0 revisions
 
554
         0 committers
532
555
 
533
 
Revision store:
 
556
Repository:
534
557
         0 revisions
535
558
         0 KiB
536
 
""" % (repo.bzrdir.root_transport.base,
537
 
       repo._format.get_format_description(),
 
559
""" % (format.get_branch_format().get_format_description(),
 
560
       format.repository_format.get_format_description(),
538
561
       ), out)
539
562
        self.assertEqual('', err)
540
563
 
541
564
        # Create lightweight checkout
542
565
        transport.mkdir('tree')
543
566
        transport.mkdir('tree/lightcheckout')
544
 
        dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
545
 
        bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
546
 
        dir2.create_workingtree()
547
 
        tree2 = dir2.open_workingtree()
 
567
        tree2 = branch1.create_checkout('tree/lightcheckout', 
 
568
            lightweight=True)
548
569
        branch2 = tree2.branch
549
 
        out, err = self.runbzr('info tree/lightcheckout')
550
 
        self.assertEqualDiff(
551
 
"""Location:
552
 
  light checkout root: %s
553
 
    shared repository: %s
554
 
    repository branch: branch
555
 
 
556
 
Format:
557
 
       control: Meta directory format 1
558
 
  working tree: Working tree format 3
559
 
        branch: Branch format 5
560
 
    repository: %s
561
 
 
562
 
In the working tree:
563
 
         0 unchanged
564
 
         0 modified
565
 
         0 added
566
 
         0 removed
567
 
         0 renamed
568
 
         0 unknown
569
 
         0 ignored
570
 
         0 versioned subdirectories
571
 
 
572
 
Branch history:
573
 
         0 revisions
574
 
 
575
 
Revision store:
576
 
         0 revisions
577
 
         0 KiB
578
 
""" % (tree2.bzrdir.root_transport.base,
579
 
       repo.bzrdir.root_transport.base,
580
 
       repo._format.get_format_description(),
581
 
       ), out)
582
 
        self.assertEqual('', err)
 
570
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
 
571
                   shared_repo=repo, repo_branch=branch1, verbose=True)
583
572
 
584
573
        # Create normal checkout
585
 
        branch3 = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout')
586
 
        branch3.bind(branch1)
587
 
        tree3 = branch3.bzrdir.open_workingtree()
588
 
        tree3.update()
589
 
        out, err = self.runbzr('info tree/checkout --verbose')
590
 
        self.assertEqualDiff(
591
 
"""Location:
592
 
       checkout root: %s
593
 
  checkout of branch: %s
594
 
 
595
 
Format:
596
 
       control: Meta directory format 1
597
 
  working tree: Working tree format 3
598
 
        branch: Branch format 5
599
 
    repository: %s
600
 
 
601
 
In the working tree:
602
 
         0 unchanged
603
 
         0 modified
604
 
         0 added
605
 
         0 removed
606
 
         0 renamed
607
 
         0 unknown
608
 
         0 ignored
609
 
         0 versioned subdirectories
610
 
 
611
 
Branch history:
612
 
         0 revisions
613
 
         0 committers
614
 
 
615
 
Revision store:
616
 
         0 revisions
617
 
         0 KiB
618
 
""" % (branch3.bzrdir.root_transport.base,
619
 
       branch1.bzrdir.root_transport.base,
620
 
       repo._format.get_format_description(),
621
 
       ), out)
622
 
        self.assertEqual('', err)
623
 
 
 
574
        tree3 = branch1.create_checkout('tree/checkout')
 
575
        self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
 
576
            verbose=True,
 
577
            light_checkout=False, repo_branch=branch1)
624
578
        # Update lightweight checkout
625
579
        self.build_tree(['tree/lightcheckout/a'])
626
580
        tree2.add('a')
627
581
        tree2.commit('commit one')
628
582
        rev = repo.get_revision(branch2.revision_history()[0])
629
583
        datestring_first = format_date(rev.timestamp, rev.timezone)
630
 
        out, err = self.runbzr('info tree/lightcheckout --verbose')
 
584
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
631
585
        self.assertEqualDiff(
632
 
"""Location:
633
 
  light checkout root: %s
634
 
    shared repository: %s
635
 
    repository branch: branch
 
586
"""Lightweight checkout (format: dirstate or dirstate-tags or \
 
587
pack-0.92 or rich-root or rich-root-pack)
 
588
Location:
 
589
  light checkout root: tree/lightcheckout
 
590
   checkout of branch: repo/branch
 
591
    shared repository: repo
636
592
 
637
593
Format:
638
594
       control: Meta directory format 1
639
 
  working tree: Working tree format 3
640
 
        branch: Branch format 5
 
595
  working tree: Working tree format 4
 
596
        branch: %s
641
597
    repository: %s
642
598
 
643
599
In the working tree:
657
613
   first revision: %s
658
614
  latest revision: %s
659
615
 
660
 
Revision store:
 
616
Repository:
661
617
         1 revision
662
618
         %d KiB
663
 
""" % (tree2.bzrdir.root_transport.base,
664
 
       repo.bzrdir.root_transport.base,
665
 
       repo._format.get_format_description(),
 
619
""" % (format.get_branch_format().get_format_description(),
 
620
       format.repository_format.get_format_description(),
666
621
       datestring_first, datestring_first,
667
622
       # poking at _revision_store isn't all that clean, but neither is
668
623
       # having the ui test dependent on the exact overhead of a given store.
671
626
        self.assertEqual('', err)
672
627
 
673
628
        # Out of date checkout
674
 
        out, err = self.runbzr('info tree/checkout')
 
629
        out, err = self.run_bzr('info -v tree/checkout')
675
630
        self.assertEqualDiff(
676
 
"""Location:
677
 
       checkout root: %s
678
 
  checkout of branch: %s
 
631
"""Checkout (format: dirstate)
 
632
Location:
 
633
       checkout root: tree/checkout
 
634
  checkout of branch: repo/branch
679
635
 
680
636
Format:
681
637
       control: Meta directory format 1
682
 
  working tree: Working tree format 3
683
 
        branch: Branch format 5
 
638
  working tree: Working tree format 4
 
639
        branch: %s
684
640
    repository: %s
685
641
 
686
642
Branch is out of date: missing 1 revision.
697
653
 
698
654
Branch history:
699
655
         0 revisions
 
656
         0 committers
700
657
 
701
 
Revision store:
 
658
Repository:
702
659
         0 revisions
703
660
         0 KiB
704
 
""" % (tree3.bzrdir.root_transport.base,
705
 
       branch1.bzrdir.root_transport.base,
706
 
       repo._format.get_format_description(),
 
661
""" % (format.get_branch_format().get_format_description(),
 
662
       format.repository_format.get_format_description(),
707
663
       ), out)
708
664
        self.assertEqual('', err)
709
665
 
711
667
        tree3.update()
712
668
        self.build_tree(['tree/checkout/b'])
713
669
        tree3.add('b')
714
 
        out, err = self.runbzr('info tree/checkout --verbose')
 
670
        out, err = self.run_bzr('info tree/checkout --verbose')
715
671
        self.assertEqualDiff(
716
 
"""Location:
717
 
       checkout root: %s
718
 
  checkout of branch: %s
 
672
"""Checkout (format: dirstate)
 
673
Location:
 
674
       checkout root: tree/checkout
 
675
  checkout of branch: repo/branch
719
676
 
720
677
Format:
721
678
       control: Meta directory format 1
722
 
  working tree: Working tree format 3
723
 
        branch: Branch format 5
 
679
  working tree: Working tree format 4
 
680
        branch: %s
724
681
    repository: %s
725
682
 
726
683
In the working tree:
740
697
   first revision: %s
741
698
  latest revision: %s
742
699
 
743
 
Revision store:
 
700
Repository:
744
701
         1 revision
745
702
         %d KiB
746
 
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
747
 
       repo._format.get_format_description(),
 
703
""" % (format.get_branch_format().get_format_description(),
 
704
       format.repository_format.get_format_description(),
748
705
       datestring_first, datestring_first,
749
706
       # poking at _revision_store isn't all that clean, but neither is
750
707
       # having the ui test dependent on the exact overhead of a given store.
756
713
        # Out of date lightweight checkout
757
714
        rev = repo.get_revision(branch1.revision_history()[-1])
758
715
        datestring_last = format_date(rev.timestamp, rev.timezone)
759
 
        out, err = self.runbzr('info tree/lightcheckout --verbose')
 
716
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
760
717
        self.assertEqualDiff(
761
 
"""Location:
762
 
  light checkout root: %s
763
 
    shared repository: %s
764
 
    repository branch: branch
 
718
"""Lightweight checkout (format: dirstate or dirstate-tags or \
 
719
pack-0.92 or rich-root or rich-root-pack)
 
720
Location:
 
721
  light checkout root: tree/lightcheckout
 
722
   checkout of branch: repo/branch
 
723
    shared repository: repo
765
724
 
766
725
Format:
767
726
       control: Meta directory format 1
768
 
  working tree: Working tree format 3
769
 
        branch: Branch format 5
 
727
  working tree: Working tree format 4
 
728
        branch: %s
770
729
    repository: %s
771
730
 
772
731
Working tree is out of date: missing 1 revision.
788
747
   first revision: %s
789
748
  latest revision: %s
790
749
 
791
 
Revision store:
 
750
Repository:
792
751
         2 revisions
793
752
         %d KiB
794
 
""" % (tree2.bzrdir.root_transport.base,
795
 
       repo.bzrdir.root_transport.base,
796
 
       repo._format.get_format_description(),
 
753
""" % (format.get_branch_format().get_format_description(),
 
754
       format.repository_format.get_format_description(),
797
755
       datestring_first, datestring_last,
798
756
       # poking at _revision_store isn't all that clean, but neither is
799
757
       # having the ui test dependent on the exact overhead of a given store.
802
760
        self.assertEqual('', err)
803
761
 
804
762
        # Show info about shared branch
805
 
        out, err = self.runbzr('info repo/branch --verbose')
 
763
        out, err = self.run_bzr('info repo/branch --verbose')
806
764
        self.assertEqualDiff(
807
 
"""Location:
808
 
  shared repository: %s
809
 
  repository branch: branch
 
765
"""Repository branch (format: dirstate or knit)
 
766
Location:
 
767
  shared repository: repo
 
768
  repository branch: repo/branch
810
769
 
811
770
Format:
812
771
       control: Meta directory format 1
813
 
        branch: Branch format 5
 
772
        branch: %s
814
773
    repository: %s
815
774
 
816
775
Branch history:
820
779
   first revision: %s
821
780
  latest revision: %s
822
781
 
823
 
Revision store:
 
782
Repository:
824
783
         2 revisions
825
784
         %d KiB
826
 
""" % (repo.bzrdir.root_transport.base,
827
 
       repo._format.get_format_description(),
 
785
""" % (format.get_branch_format().get_format_description(),
 
786
       format.repository_format.get_format_description(),
828
787
       datestring_first, datestring_last,
829
788
       # poking at _revision_store isn't all that clean, but neither is
830
789
       # having the ui test dependent on the exact overhead of a given store.
833
792
        self.assertEqual('', err)
834
793
 
835
794
        # Show info about repository with revisions
836
 
        out, err = self.runbzr('info repo')
 
795
        out, err = self.run_bzr('info -v repo')
837
796
        self.assertEqualDiff(
838
 
"""Location:
839
 
  shared repository: %s
 
797
"""Shared repository (format: dirstate or dirstate-tags or knit)
 
798
Location:
 
799
  shared repository: repo
840
800
 
841
801
Format:
842
802
       control: Meta directory format 1
843
803
    repository: %s
844
804
 
845
 
Revision store:
 
805
Repository:
846
806
         2 revisions
847
807
         %d KiB
848
 
""" % (repo.bzrdir.root_transport.base,
849
 
       repo._format.get_format_description(),
 
808
""" % (format.repository_format.get_format_description(),
850
809
       # poking at _revision_store isn't all that clean, but neither is
851
810
       # having the ui test dependent on the exact overhead of a given store.
852
811
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
853
812
       ), out)
854
813
        self.assertEqual('', err)
855
814
 
856
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
857
 
 
858
815
    def test_info_shared_repository_with_trees(self):
859
 
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
860
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
 
816
        format = bzrdir.format_registry.make_bzrdir('knit')
861
817
        transport = self.get_transport()
862
818
 
863
819
        # Create shared repository with working trees
864
 
        repo = self.make_repository('repo', shared=True)
 
820
        repo = self.make_repository('repo', shared=True, format=format)
865
821
        repo.set_make_working_trees(True)
866
 
        out, err = self.runbzr('info repo')
 
822
        out, err = self.run_bzr('info -v repo')
867
823
        self.assertEqualDiff(
868
 
"""Location:
869
 
  shared repository: %s
 
824
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
825
Location:
 
826
  shared repository: repo
870
827
 
871
828
Format:
872
829
       control: Meta directory format 1
874
831
 
875
832
Create working tree for new branches inside the repository.
876
833
 
877
 
Revision store:
 
834
Repository:
878
835
         0 revisions
879
836
         0 KiB
880
 
""" % (repo.bzrdir.root_transport.base,
881
 
       repo._format.get_format_description(),
 
837
""" % (format.repository_format.get_format_description(),
882
838
       ), out)
883
839
        self.assertEqual('', err)
884
840
 
885
841
        # Create two branches
886
842
        repo.bzrdir.root_transport.mkdir('branch1')
887
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
 
843
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
 
844
            format=format)
888
845
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
889
846
 
890
847
        # Empty first branch
891
 
        out, err = self.runbzr('info repo/branch1 --verbose')
 
848
        out, err = self.run_bzr('info repo/branch1 --verbose')
892
849
        self.assertEqualDiff(
893
 
"""Location:
894
 
    shared repository: %s
895
 
  repository checkout: branch1
 
850
"""Repository tree (format: knit)
 
851
Location:
 
852
  shared repository: repo
 
853
  repository branch: repo/branch1
896
854
 
897
855
Format:
898
856
       control: Meta directory format 1
899
857
  working tree: Working tree format 3
900
 
        branch: Branch format 5
 
858
        branch: %s
901
859
    repository: %s
902
860
 
903
861
In the working tree:
914
872
         0 revisions
915
873
         0 committers
916
874
 
917
 
Revision store:
 
875
Repository:
918
876
         0 revisions
919
877
         0 KiB
920
 
""" % (repo.bzrdir.root_transport.base,
921
 
       repo._format.get_format_description(),
 
878
""" % (format.get_branch_format().get_format_description(),
 
879
       format.repository_format.get_format_description(),
922
880
       ), out)
923
881
        self.assertEqual('', err)
924
882
 
929
887
        tree1.commit('commit one')
930
888
        rev = repo.get_revision(branch1.revision_history()[0])
931
889
        datestring_first = format_date(rev.timestamp, rev.timezone)
932
 
        out, err = self.runbzr('info repo/branch1')
 
890
        out, err = self.run_bzr('info -v repo/branch1')
933
891
        self.assertEqualDiff(
934
 
"""Location:
935
 
    shared repository: %s
936
 
  repository checkout: branch1
 
892
"""Repository tree (format: knit)
 
893
Location:
 
894
  shared repository: repo
 
895
  repository branch: repo/branch1
937
896
 
938
897
Format:
939
898
       control: Meta directory format 1
940
899
  working tree: Working tree format 3
941
 
        branch: Branch format 5
 
900
        branch: %s
942
901
    repository: %s
943
902
 
944
903
In the working tree:
953
912
 
954
913
Branch history:
955
914
         1 revision
 
915
         1 committer
956
916
         0 days old
957
917
   first revision: %s
958
918
  latest revision: %s
959
919
 
960
 
Revision store:
 
920
Repository:
961
921
         1 revision
962
922
         %d KiB
963
 
""" % (repo.bzrdir.root_transport.base,
964
 
       repo._format.get_format_description(),
 
923
""" % (format.get_branch_format().get_format_description(),
 
924
       format.repository_format.get_format_description(),
965
925
       datestring_first, datestring_first,
966
926
       # poking at _revision_store isn't all that clean, but neither is
967
927
       # having the ui test dependent on the exact overhead of a given store.
970
930
        self.assertEqual('', err)
971
931
 
972
932
        # Out of date second branch
973
 
        out, err = self.runbzr('info repo/branch2 --verbose')
 
933
        out, err = self.run_bzr('info repo/branch2 --verbose')
974
934
        self.assertEqualDiff(
975
 
"""Location:
976
 
    shared repository: %s
977
 
  repository checkout: branch2
 
935
"""Repository tree (format: knit)
 
936
Location:
 
937
  shared repository: repo
 
938
  repository branch: repo/branch2
978
939
 
979
940
Related branches:
980
 
  parent branch: %s
 
941
  parent branch: repo/branch1
981
942
 
982
943
Format:
983
944
       control: Meta directory format 1
984
945
  working tree: Working tree format 3
985
 
        branch: Branch format 5
 
946
        branch: %s
986
947
    repository: %s
987
948
 
988
949
In the working tree:
999
960
         0 revisions
1000
961
         0 committers
1001
962
 
1002
 
Revision store:
 
963
Repository:
1003
964
         1 revision
1004
965
         %d KiB
1005
 
""" % (repo.bzrdir.root_transport.base,
1006
 
       branch1.bzrdir.root_transport.base,
1007
 
       repo._format.get_format_description(),
 
966
""" % (format.get_branch_format().get_format_description(),
 
967
       format.repository_format.get_format_description(),
1008
968
       # poking at _revision_store isn't all that clean, but neither is
1009
969
       # having the ui test dependent on the exact overhead of a given store.
1010
970
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1014
974
        # Update second branch
1015
975
        tree2 = branch2.bzrdir.open_workingtree()
1016
976
        tree2.pull(branch1)
1017
 
        out, err = self.runbzr('info repo/branch2')
 
977
        out, err = self.run_bzr('info -v repo/branch2')
1018
978
        self.assertEqualDiff(
1019
 
"""Location:
1020
 
    shared repository: %s
1021
 
  repository checkout: branch2
 
979
"""Repository tree (format: knit)
 
980
Location:
 
981
  shared repository: repo
 
982
  repository branch: repo/branch2
1022
983
 
1023
984
Related branches:
1024
 
  parent branch: %s
 
985
  parent branch: repo/branch1
1025
986
 
1026
987
Format:
1027
988
       control: Meta directory format 1
1028
989
  working tree: Working tree format 3
1029
 
        branch: Branch format 5
 
990
        branch: %s
1030
991
    repository: %s
1031
992
 
1032
993
In the working tree:
1041
1002
 
1042
1003
Branch history:
1043
1004
         1 revision
 
1005
         1 committer
1044
1006
         0 days old
1045
1007
   first revision: %s
1046
1008
  latest revision: %s
1047
1009
 
1048
 
Revision store:
 
1010
Repository:
1049
1011
         1 revision
1050
1012
         %d KiB
1051
 
""" % (repo.bzrdir.root_transport.base,
1052
 
       branch1.bzrdir.root_transport.base,
1053
 
       repo._format.get_format_description(),
 
1013
""" % (format.get_branch_format().get_format_description(),
 
1014
       format.repository_format.get_format_description(),
1054
1015
       datestring_first, datestring_first,
1055
1016
       # poking at _revision_store isn't all that clean, but neither is
1056
1017
       # having the ui test dependent on the exact overhead of a given store.
1059
1020
        self.assertEqual('', err)
1060
1021
 
1061
1022
        # Show info about repository with revisions
1062
 
        out, err = self.runbzr('info repo')
 
1023
        out, err = self.run_bzr('info -v repo')
1063
1024
        self.assertEqualDiff(
1064
 
"""Location:
1065
 
  shared repository: %s
 
1025
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
1026
Location:
 
1027
  shared repository: repo
1066
1028
 
1067
1029
Format:
1068
1030
       control: Meta directory format 1
1070
1032
 
1071
1033
Create working tree for new branches inside the repository.
1072
1034
 
1073
 
Revision store:
 
1035
Repository:
1074
1036
         1 revision
1075
1037
         %d KiB
1076
 
""" % (repo.bzrdir.root_transport.base,
1077
 
       repo._format.get_format_description(),
 
1038
""" % (format.repository_format.get_format_description(),
1078
1039
       # poking at _revision_store isn't all that clean, but neither is
1079
1040
       # having the ui test dependent on the exact overhead of a given store.
1080
1041
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1081
1042
       ),
1082
1043
       out)
1083
1044
        self.assertEqual('', err)
1084
 
 
1085
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1086
1045
    
1087
1046
    def test_info_shared_repository_with_tree_in_root(self):
1088
 
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1089
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
 
1047
        format = bzrdir.format_registry.make_bzrdir('knit')
1090
1048
        transport = self.get_transport()
1091
1049
 
1092
1050
        # Create shared repository with working trees
1093
 
        repo = self.make_repository('repo', shared=True)
 
1051
        repo = self.make_repository('repo', shared=True, format=format)
1094
1052
        repo.set_make_working_trees(True)
1095
 
        out, err = self.runbzr('info repo')
 
1053
        out, err = self.run_bzr('info -v repo')
1096
1054
        self.assertEqualDiff(
1097
 
"""Location:
1098
 
  shared repository: %s
 
1055
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
1056
Location:
 
1057
  shared repository: repo
1099
1058
 
1100
1059
Format:
1101
1060
       control: Meta directory format 1
1103
1062
 
1104
1063
Create working tree for new branches inside the repository.
1105
1064
 
1106
 
Revision store:
 
1065
Repository:
1107
1066
         0 revisions
1108
1067
         0 KiB
1109
 
""" % (repo.bzrdir.root_transport.base,
1110
 
       repo._format.get_format_description(),
 
1068
""" % (format.repository_format.get_format_description(),
1111
1069
       ), out)
1112
1070
        self.assertEqual('', err)
1113
1071
 
1115
1073
        control = repo.bzrdir
1116
1074
        branch = control.create_branch()
1117
1075
        control.create_workingtree()
1118
 
        out, err = self.runbzr('info repo')
 
1076
        out, err = self.run_bzr('info -v repo')
1119
1077
        self.assertEqualDiff(
1120
 
"""Location:
1121
 
    shared repository: %s
1122
 
  repository checkout: .
 
1078
"""Repository tree (format: knit)
 
1079
Location:
 
1080
  shared repository: repo
 
1081
  repository branch: repo
1123
1082
 
1124
1083
Format:
1125
1084
       control: Meta directory format 1
1126
1085
  working tree: Working tree format 3
1127
 
        branch: Branch format 5
 
1086
        branch: %s
1128
1087
    repository: %s
1129
1088
 
1130
1089
In the working tree:
1139
1098
 
1140
1099
Branch history:
1141
1100
         0 revisions
 
1101
         0 committers
1142
1102
 
1143
 
Revision store:
 
1103
Repository:
1144
1104
         0 revisions
1145
1105
         0 KiB
1146
 
""" % (repo.bzrdir.root_transport.base,
1147
 
       repo._format.get_format_description(),
 
1106
""" % (format.get_branch_format().get_format_description(),
 
1107
       format.repository_format.get_format_description(),
1148
1108
       ), out)
1149
1109
        self.assertEqual('', err)
1150
1110
 
1151
 
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
 
1111
    def assertCheckoutStatusOutput(self,
 
1112
        command_string, lco_tree, shared_repo=None,
 
1113
        repo_branch=None,
 
1114
        tree_locked=False,
 
1115
        branch_locked=False, repo_locked=False,
 
1116
        verbose=False,
 
1117
        light_checkout=True,
 
1118
        checkout_root=None):
 
1119
        """Check the output of info in a checkout.
 
1120
 
 
1121
        This is not quite a mirror of the info code: rather than using the
 
1122
        tree being examined to predict output, it uses a bunch of flags which
 
1123
        allow us, the test writers, to document what *should* be present in
 
1124
        the output. Removing this separation would remove the value of the
 
1125
        tests.
 
1126
        
 
1127
        :param path: the path to the light checkout.
 
1128
        :param lco_tree: the tree object for the light checkout.
 
1129
        :param shared_repo: A shared repository is in use, expect that in
 
1130
            the output.
 
1131
        :param repo_branch: A branch in a shared repository for non light
 
1132
            checkouts.
 
1133
        :param tree_locked: If true, expect the tree to be locked.
 
1134
        :param branch_locked: If true, expect the branch to be locked.
 
1135
        :param repo_locked: If true, expect the repository to be locked.
 
1136
            Note that the lco_tree.branch.repository is inspected, and if is not
 
1137
            actually locked then this parameter is overridden. This is because
 
1138
            pack repositories do not have any public API for obtaining an
 
1139
            exclusive repository wide lock.
 
1140
        :param verbose: If true, expect verbose output
 
1141
        """
 
1142
        def friendly_location(url):
 
1143
            path = urlutils.unescape_for_display(url, 'ascii')
 
1144
            try:
 
1145
                return osutils.relpath(osutils.getcwd(), path)
 
1146
            except errors.PathNotChild:
 
1147
                return path
 
1148
 
 
1149
        if tree_locked:
 
1150
            # We expect this to fail because of locking errors.
 
1151
            # (A write-locked file cannot be read-locked
 
1152
            # in the different process -- either on win32 or on linux).
 
1153
            # This should be removed when the locking errors are fixed.
 
1154
            self.expectFailure('OS locks are exclusive '
 
1155
                'for different processes (Bug #174055)',
 
1156
                self.run_bzr_subprocess,
 
1157
                'info ' + command_string)
 
1158
        out, err = self.run_bzr('info %s' % command_string)
 
1159
        description = {
 
1160
            (True, True): 'Lightweight checkout',
 
1161
            (True, False): 'Repository checkout',
 
1162
            (False, True): 'Lightweight checkout',
 
1163
            (False, False): 'Checkout',
 
1164
            }[(shared_repo is not None, light_checkout)]
 
1165
        format = {True: 'dirstate or dirstate-tags or pack-0.92'
 
1166
                        ' or rich-root or rich-root-pack',
 
1167
                  False: 'dirstate'}[light_checkout]
 
1168
        if repo_locked:
 
1169
            repo_locked = lco_tree.branch.repository.get_physical_lock_status()
 
1170
        if repo_locked or branch_locked or tree_locked:
 
1171
            def locked_message(a_bool):
 
1172
                if a_bool:
 
1173
                    return 'locked'
 
1174
                else:
 
1175
                    return 'unlocked'
 
1176
            expected_lock_output = (
 
1177
                "\n"
 
1178
                "Lock status:\n"
 
1179
                "  working tree: %s\n"
 
1180
                "        branch: %s\n"
 
1181
                "    repository: %s\n" % (
 
1182
                    locked_message(tree_locked),
 
1183
                    locked_message(branch_locked),
 
1184
                    locked_message(repo_locked)))
 
1185
        else:
 
1186
            expected_lock_output = ''
 
1187
        tree_data = ''
 
1188
        extra_space = ''
 
1189
        if light_checkout:
 
1190
            tree_data = ("  light checkout root: %s\n" %
 
1191
                friendly_location(lco_tree.bzrdir.root_transport.base))
 
1192
            extra_space = ' '
 
1193
        if lco_tree.branch.get_bound_location() is not None:
 
1194
            tree_data += ("%s       checkout root: %s\n" % (extra_space,
 
1195
                friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
 
1196
        if shared_repo is not None:
 
1197
            branch_data = (
 
1198
                "   checkout of branch: %s\n"
 
1199
                "    shared repository: %s\n" %
 
1200
                (friendly_location(repo_branch.bzrdir.root_transport.base),
 
1201
                 friendly_location(shared_repo.bzrdir.root_transport.base)))
 
1202
        elif repo_branch is not None:
 
1203
            branch_data = (
 
1204
                "%s  checkout of branch: %s\n" %
 
1205
                (extra_space,
 
1206
                 friendly_location(repo_branch.bzrdir.root_transport.base)))
 
1207
        else:
 
1208
            branch_data = ("   checkout of branch: %s\n" %
 
1209
                lco_tree.branch.bzrdir.root_transport.base)
 
1210
        
 
1211
        if verbose:
 
1212
            verbose_info = '         0 committers\n'
 
1213
        else:
 
1214
            verbose_info = ''
 
1215
            
 
1216
        self.assertEqualDiff(
 
1217
"""%s (format: %s)
 
1218
Location:
 
1219
%s%s
 
1220
Format:
 
1221
       control: Meta directory format 1
 
1222
  working tree: %s
 
1223
        branch: %s
 
1224
    repository: %s
 
1225
%s
 
1226
In the working tree:
 
1227
         0 unchanged
 
1228
         0 modified
 
1229
         0 added
 
1230
         0 removed
 
1231
         0 renamed
 
1232
         0 unknown
 
1233
         0 ignored
 
1234
         0 versioned subdirectories
 
1235
 
 
1236
Branch history:
 
1237
         0 revisions
 
1238
%s
 
1239
Repository:
 
1240
         0 revisions
 
1241
         0 KiB
 
1242
""" %  (description,
 
1243
        format,
 
1244
        tree_data,
 
1245
        branch_data,
 
1246
        lco_tree._format.get_format_description(),
 
1247
        lco_tree.branch._format.get_format_description(),
 
1248
        lco_tree.branch.repository._format.get_format_description(),
 
1249
        expected_lock_output,
 
1250
        verbose_info,
 
1251
        ), out)
 
1252
        self.assertEqual('', err)
1152
1253
 
1153
1254
    def test_info_locking(self):
1154
1255
        transport = self.get_transport()
1163
1264
        transport.mkdir('tree')
1164
1265
        transport.mkdir('tree/checkout')
1165
1266
        co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1166
 
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1267
            format=bzrlib.bzrdir.BzrDirMetaFormat1())
1167
1268
        co_branch.bind(repo_branch)
1168
1269
        # Do a light checkout of the heavy one
1169
1270
        transport.mkdir('tree/lightcheckout')
1176
1277
        # W B R
1177
1278
 
1178
1279
        # U U U
1179
 
        out, err = self.runbzr('info tree/lightcheckout')
1180
 
        self.assertEqualDiff(
1181
 
"""Location:
1182
 
  light checkout root: %s
1183
 
   checkout of branch: %s
1184
 
 
1185
 
Format:
1186
 
       control: Meta directory format 1
1187
 
  working tree: Working tree format 3
1188
 
        branch: Branch format 5
1189
 
    repository: %s
1190
 
 
1191
 
In the working tree:
1192
 
         0 unchanged
1193
 
         0 modified
1194
 
         0 added
1195
 
         0 removed
1196
 
         0 renamed
1197
 
         0 unknown
1198
 
         0 ignored
1199
 
         0 versioned subdirectories
1200
 
 
1201
 
Branch history:
1202
 
         0 revisions
1203
 
 
1204
 
Revision store:
1205
 
         0 revisions
1206
 
         0 KiB
1207
 
""" % (lco_tree.bzrdir.root_transport.base,
1208
 
       lco_tree.branch.bzrdir.root_transport.base,
1209
 
       lco_tree.branch.repository._format.get_format_description(),
1210
 
       ), out)
1211
 
        self.assertEqual('', err)
 
1280
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
 
1281
                                        repo_branch=repo_branch,
 
1282
                                        verbose=True, light_checkout=True)
1212
1283
        # U U L
1213
1284
        lco_tree.branch.repository.lock_write()
1214
 
        out, err = self.runbzr('info tree/lightcheckout')
1215
 
        self.assertEqualDiff(
1216
 
"""Location:
1217
 
  light checkout root: %s
1218
 
   checkout of branch: %s
1219
 
 
1220
 
Format:
1221
 
       control: Meta directory format 1
1222
 
  working tree: Working tree format 3
1223
 
        branch: Branch format 5
1224
 
    repository: %s
1225
 
 
1226
 
Lock status:
1227
 
  working tree: unlocked
1228
 
        branch: unlocked
1229
 
    repository: locked
1230
 
 
1231
 
In the working tree:
1232
 
         0 unchanged
1233
 
         0 modified
1234
 
         0 added
1235
 
         0 removed
1236
 
         0 renamed
1237
 
         0 unknown
1238
 
         0 ignored
1239
 
         0 versioned subdirectories
1240
 
 
1241
 
Branch history:
1242
 
         0 revisions
1243
 
 
1244
 
Revision store:
1245
 
         0 revisions
1246
 
         0 KiB
1247
 
""" % (lco_tree.bzrdir.root_transport.base,
1248
 
       lco_tree.branch.bzrdir.root_transport.base,
1249
 
       lco_tree.branch.repository._format.get_format_description(),
1250
 
       ), out)
1251
 
        self.assertEqual('', err)
1252
 
        lco_tree.branch.repository.unlock()
 
1285
        try:
 
1286
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1287
            lco_tree, repo_branch=repo_branch,
 
1288
            repo_locked=True, verbose=True, light_checkout=True)
 
1289
        finally:
 
1290
            lco_tree.branch.repository.unlock()
1253
1291
        # U L L
1254
1292
        lco_tree.branch.lock_write()
1255
 
        out, err = self.runbzr('info tree/lightcheckout')
1256
 
        self.assertEqualDiff(
1257
 
"""Location:
1258
 
  light checkout root: %s
1259
 
   checkout of branch: %s
1260
 
 
1261
 
Format:
1262
 
       control: Meta directory format 1
1263
 
  working tree: Working tree format 3
1264
 
        branch: Branch format 5
1265
 
    repository: %s
1266
 
 
1267
 
Lock status:
1268
 
  working tree: unlocked
1269
 
        branch: locked
1270
 
    repository: locked
1271
 
 
1272
 
In the working tree:
1273
 
         0 unchanged
1274
 
         0 modified
1275
 
         0 added
1276
 
         0 removed
1277
 
         0 renamed
1278
 
         0 unknown
1279
 
         0 ignored
1280
 
         0 versioned subdirectories
1281
 
 
1282
 
Branch history:
1283
 
         0 revisions
1284
 
 
1285
 
Revision store:
1286
 
         0 revisions
1287
 
         0 KiB
1288
 
""" % (lco_tree.bzrdir.root_transport.base,
1289
 
       lco_tree.branch.bzrdir.root_transport.base,
1290
 
       lco_tree.branch.repository._format.get_format_description(),
1291
 
       ), out)
1292
 
        self.assertEqual('', err)
1293
 
        lco_tree.branch.unlock()
 
1293
        try:
 
1294
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1295
            lco_tree,
 
1296
            branch_locked=True,
 
1297
            repo_locked=True,
 
1298
            repo_branch=repo_branch,
 
1299
            verbose=True)
 
1300
        finally:
 
1301
            lco_tree.branch.unlock()
1294
1302
        # L L L
1295
1303
        lco_tree.lock_write()
1296
 
        out, err = self.runbzr('info tree/lightcheckout')
1297
 
        self.assertEqualDiff(
1298
 
"""Location:
1299
 
  light checkout root: %s
1300
 
   checkout of branch: %s
1301
 
 
1302
 
Format:
1303
 
       control: Meta directory format 1
1304
 
  working tree: Working tree format 3
1305
 
        branch: Branch format 5
1306
 
    repository: %s
1307
 
 
1308
 
Lock status:
1309
 
  working tree: locked
1310
 
        branch: locked
1311
 
    repository: locked
1312
 
 
1313
 
In the working tree:
1314
 
         0 unchanged
1315
 
         0 modified
1316
 
         0 added
1317
 
         0 removed
1318
 
         0 renamed
1319
 
         0 unknown
1320
 
         0 ignored
1321
 
         0 versioned subdirectories
1322
 
 
1323
 
Branch history:
1324
 
         0 revisions
1325
 
 
1326
 
Revision store:
1327
 
         0 revisions
1328
 
         0 KiB
1329
 
""" % (lco_tree.bzrdir.root_transport.base,
1330
 
       lco_tree.branch.bzrdir.root_transport.base,
1331
 
       lco_tree.branch.repository._format.get_format_description(),
1332
 
       ), out)
1333
 
        self.assertEqual('', err)
1334
 
        lco_tree.unlock()
 
1304
        try:
 
1305
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1306
            lco_tree, repo_branch=repo_branch,
 
1307
            tree_locked=True,
 
1308
            branch_locked=True,
 
1309
            repo_locked=True,
 
1310
            verbose=True)
 
1311
        finally:
 
1312
            lco_tree.unlock()
1335
1313
        # L L U
1336
1314
        lco_tree.lock_write()
1337
1315
        lco_tree.branch.repository.unlock()
1338
 
        out, err = self.runbzr('info tree/lightcheckout')
1339
 
        self.assertEqualDiff(
1340
 
"""Location:
1341
 
  light checkout root: %s
1342
 
   checkout of branch: %s
1343
 
 
1344
 
Format:
1345
 
       control: Meta directory format 1
1346
 
  working tree: Working tree format 3
1347
 
        branch: Branch format 5
1348
 
    repository: %s
1349
 
 
1350
 
Lock status:
1351
 
  working tree: locked
1352
 
        branch: locked
1353
 
    repository: unlocked
1354
 
 
1355
 
In the working tree:
1356
 
         0 unchanged
1357
 
         0 modified
1358
 
         0 added
1359
 
         0 removed
1360
 
         0 renamed
1361
 
         0 unknown
1362
 
         0 ignored
1363
 
         0 versioned subdirectories
1364
 
 
1365
 
Branch history:
1366
 
         0 revisions
1367
 
 
1368
 
Revision store:
1369
 
         0 revisions
1370
 
         0 KiB
1371
 
""" % (lco_tree.bzrdir.root_transport.base,
1372
 
       lco_tree.branch.bzrdir.root_transport.base,
1373
 
       lco_tree.branch.repository._format.get_format_description(),
1374
 
       ), out)
1375
 
        self.assertEqual('', err)
1376
 
        lco_tree.branch.repository.lock_write()
1377
 
        lco_tree.unlock()
 
1316
        try:
 
1317
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1318
            lco_tree, repo_branch=repo_branch,
 
1319
            tree_locked=True,
 
1320
            branch_locked=True,
 
1321
            verbose=True)
 
1322
        finally:
 
1323
            lco_tree.branch.repository.lock_write()
 
1324
            lco_tree.unlock()
1378
1325
        # L U U
1379
1326
        lco_tree.lock_write()
1380
1327
        lco_tree.branch.unlock()
1381
 
        out, err = self.runbzr('info tree/lightcheckout')
1382
 
        self.assertEqualDiff(
1383
 
"""Location:
1384
 
  light checkout root: %s
1385
 
   checkout of branch: %s
1386
 
 
1387
 
Format:
1388
 
       control: Meta directory format 1
1389
 
  working tree: Working tree format 3
1390
 
        branch: Branch format 5
1391
 
    repository: %s
1392
 
 
1393
 
Lock status:
1394
 
  working tree: locked
1395
 
        branch: unlocked
1396
 
    repository: unlocked
1397
 
 
1398
 
In the working tree:
1399
 
         0 unchanged
1400
 
         0 modified
1401
 
         0 added
1402
 
         0 removed
1403
 
         0 renamed
1404
 
         0 unknown
1405
 
         0 ignored
1406
 
         0 versioned subdirectories
1407
 
 
1408
 
Branch history:
1409
 
         0 revisions
1410
 
 
1411
 
Revision store:
1412
 
         0 revisions
1413
 
         0 KiB
1414
 
""" % (lco_tree.bzrdir.root_transport.base,
1415
 
       lco_tree.branch.bzrdir.root_transport.base,
1416
 
       lco_tree.branch.repository._format.get_format_description(),
1417
 
       ), out)
1418
 
        self.assertEqual('', err)
1419
 
        lco_tree.branch.lock_write()
1420
 
        lco_tree.unlock()
 
1328
        try:
 
1329
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1330
            lco_tree, repo_branch=repo_branch,
 
1331
            tree_locked=True,
 
1332
            verbose=True)
 
1333
        finally:
 
1334
            lco_tree.branch.lock_write()
 
1335
            lco_tree.unlock()
1421
1336
        # L U L
1422
1337
        lco_tree.lock_write()
1423
1338
        lco_tree.branch.unlock()
1424
1339
        lco_tree.branch.repository.lock_write()
1425
 
        out, err = self.runbzr('info tree/lightcheckout')
1426
 
        self.assertEqualDiff(
1427
 
"""Location:
1428
 
  light checkout root: %s
1429
 
   checkout of branch: %s
1430
 
 
1431
 
Format:
1432
 
       control: Meta directory format 1
1433
 
  working tree: Working tree format 3
1434
 
        branch: Branch format 5
1435
 
    repository: %s
1436
 
 
1437
 
Lock status:
1438
 
  working tree: locked
1439
 
        branch: unlocked
1440
 
    repository: locked
1441
 
 
1442
 
In the working tree:
1443
 
         0 unchanged
1444
 
         0 modified
1445
 
         0 added
1446
 
         0 removed
1447
 
         0 renamed
1448
 
         0 unknown
1449
 
         0 ignored
1450
 
         0 versioned subdirectories
1451
 
 
1452
 
Branch history:
1453
 
         0 revisions
1454
 
 
1455
 
Revision store:
1456
 
         0 revisions
1457
 
         0 KiB
1458
 
""" % (lco_tree.bzrdir.root_transport.base,
1459
 
       lco_tree.branch.bzrdir.root_transport.base,
1460
 
       lco_tree.branch.repository._format.get_format_description(),
1461
 
       ), out)
1462
 
        self.assertEqual('', err)
1463
 
        lco_tree.branch.repository.unlock()
1464
 
        lco_tree.branch.lock_write()
1465
 
        lco_tree.unlock()
 
1340
        try:
 
1341
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1342
            lco_tree, repo_branch=repo_branch,
 
1343
            tree_locked=True,
 
1344
            repo_locked=True,
 
1345
            verbose=True)
 
1346
        finally:
 
1347
            lco_tree.branch.repository.unlock()
 
1348
            lco_tree.branch.lock_write()
 
1349
            lco_tree.unlock()
1466
1350
        # U L U
1467
1351
        lco_tree.branch.lock_write()
1468
1352
        lco_tree.branch.repository.unlock()
1469
 
        out, err = self.runbzr('info tree/lightcheckout')
1470
 
        self.assertEqualDiff(
1471
 
"""Location:
1472
 
  light checkout root: %s
1473
 
   checkout of branch: %s
1474
 
 
1475
 
Format:
1476
 
       control: Meta directory format 1
1477
 
  working tree: Working tree format 3
1478
 
        branch: Branch format 5
1479
 
    repository: %s
1480
 
 
1481
 
Lock status:
1482
 
  working tree: unlocked
1483
 
        branch: locked
1484
 
    repository: unlocked
1485
 
 
1486
 
In the working tree:
1487
 
         0 unchanged
1488
 
         0 modified
1489
 
         0 added
1490
 
         0 removed
1491
 
         0 renamed
1492
 
         0 unknown
1493
 
         0 ignored
1494
 
         0 versioned subdirectories
1495
 
 
1496
 
Branch history:
1497
 
         0 revisions
1498
 
 
1499
 
Revision store:
1500
 
         0 revisions
1501
 
         0 KiB
1502
 
""" % (lco_tree.bzrdir.root_transport.base,
1503
 
       lco_tree.branch.bzrdir.root_transport.base,
1504
 
       lco_tree.branch.repository._format.get_format_description(),
1505
 
       ), out)
1506
 
        self.assertEqual('', err)
1507
 
        lco_tree.branch.repository.lock_write()
1508
 
        lco_tree.branch.unlock()
 
1353
        try:
 
1354
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1355
            lco_tree, repo_branch=repo_branch,
 
1356
            branch_locked=True,
 
1357
            verbose=True)
 
1358
        finally:
 
1359
            lco_tree.branch.repository.lock_write()
 
1360
            lco_tree.branch.unlock()
 
1361
 
 
1362
        if sys.platform == 'win32':
 
1363
            self.knownFailure('Win32 cannot run "bzr info"'
 
1364
                              ' when the tree is locked.')
1509
1365
 
1510
1366
    def test_info_locking_oslocks(self):
1511
1367
        if sys.platform == "win32":
1521
1377
        # W B R
1522
1378
 
1523
1379
        # U U U
1524
 
        out, err = self.runbzr('info branch')
 
1380
        out, err = self.run_bzr('info -v branch')
1525
1381
        self.assertEqualDiff(
1526
 
"""Location:
 
1382
"""Standalone tree (format: weave)
 
1383
Location:
1527
1384
  branch root: %s
1528
1385
 
1529
1386
Format:
1544
1401
 
1545
1402
Branch history:
1546
1403
         0 revisions
 
1404
         0 committers
1547
1405
 
1548
 
Revision store:
 
1406
Repository:
1549
1407
         0 revisions
1550
1408
         0 KiB
1551
 
""" % (tree.bzrdir.root_transport.base,
1552
 
       tree.branch.repository._format.get_format_description(),
 
1409
""" % ('branch', tree.branch.repository._format.get_format_description(),
1553
1410
       ), out)
1554
1411
        self.assertEqual('', err)
1555
1412
        # L L L
1556
1413
        tree.lock_write()
1557
 
        out, err = self.runbzr('info branch')
 
1414
        out, err = self.run_bzr('info -v branch')
1558
1415
        self.assertEqualDiff(
1559
 
"""Location:
 
1416
"""Standalone tree (format: weave)
 
1417
Location:
1560
1418
  branch root: %s
1561
1419
 
1562
1420
Format:
1577
1435
 
1578
1436
Branch history:
1579
1437
         0 revisions
 
1438
         0 committers
1580
1439
 
1581
 
Revision store:
 
1440
Repository:
1582
1441
         0 revisions
1583
1442
         0 KiB
1584
 
""" % (tree.bzrdir.root_transport.base,
1585
 
       tree.branch.repository._format.get_format_description(),
 
1443
""" % ('branch', tree.branch.repository._format.get_format_description(),
1586
1444
       ), out)
1587
1445
        self.assertEqual('', err)
1588
1446
        tree.unlock()