/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2007-02-06 06:27:24 UTC
  • mto: This revision was merged to the branch mainline in revision 2283.
  • Revision ID: mbp@sourcefrog.net-20070206062724-a5uo1u27jxsal2t0
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo.

Change help for --format to just say 'see help formats'

RepositoryFormat.register_metadir gains an optional parameter for the
module name containing the repository format, and lazily loads from there.

Disable test_interrepository_get_returns_correct_optimiser, because it
seems too brittle.

Remove InterWeaveRepo, these should now just be upgraded.

Show diffs side-by-side

added added

removed removed

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