/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2007-05-18 11:42:33 UTC
  • mto: This revision was merged to the branch mainline in revision 2528.
  • Revision ID: aaron.bentley@utoronto.ca-20070518114233-dhywq002d3fi9cti
Prevent repository.get_set_default_format from corrupting inventory

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