~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge from list_dir return type

Show diffs side-by-side

added added

removed removed

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