~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2006-06-21 14:30:57 UTC
  • mfrom: (1801.1.1 bzr.dev)
  • mto: This revision was merged to the branch mainline in revision 1803.
  • Revision ID: abentley@panoramicfeedback.com-20060621143057-776e4b8d707e430e
Install benchmarks. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

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