~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

merge bzr.dev

Show diffs side-by-side

added added

removed removed

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