~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2009-10-02 20:32:50 UTC
  • mto: (4679.6.1 2.1-export-c-api)
  • mto: This revision was merged to the branch mainline in revision 4735.
  • Revision ID: john@arbash-meinel.com-20091002203250-q6iv6o2mwjqp4g53
Add __iter__ support.

Show diffs side-by-side

added added

removed removed

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