~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2007-01-24 07:12:09 UTC
  • mto: This revision was merged to the branch mainline in revision 2244.
  • Revision ID: mbp@sourcefrog.net-20070124071209-yqiths20n6wxqaqr
Change RepositoryFormat to use a Registry rather than ad-hoc dictionary

Show diffs side-by-side

added added

removed removed

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