~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: 2006-05-30 04:44:48 UTC
  • mto: (1711.2.26 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1734.
  • Revision ID: john@arbash-meinel.com-20060530044448-81612e2e57c3991f
Update documentation and TODO for compare_trees

Show diffs side-by-side

added added

removed removed

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