/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 breezy/tests/blackbox/test_info.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-08-23 01:15:41 UTC
  • mfrom: (7520.1.4 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200823011541-nv0oh7nzaganx2qy
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/389690

Show diffs side-by-side

added added

removed removed

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