/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: Jelmer Vernooij
  • Date: 2019-10-28 01:38:39 UTC
  • mto: This revision was merged to the branch mainline in revision 7412.
  • Revision ID: jelmer@jelmer.uk-20191028013839-q63zzm4yr0id9b3o
Allow unknown extras in git commits when just inspecting revisions, rather than importing.

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