/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: 2018-11-22 03:51:03 UTC
  • mfrom: (7192.5.2 remove-more-file-ids)
  • Revision ID: breezy.the.bot@gmail.com-20181122035103-1c5jnbdx2t5yujqb
Stop actually accepting optional file_id in many Tree methods.

Merged from https://code.launchpad.net/~jelmer/brz/remove-more-file-ids/+merge/358950

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