/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-01-01 21:38:07 UTC
  • mfrom: (7228 work)
  • mto: This revision was merged to the branch mainline in revision 7233.
  • Revision ID: jelmer@jelmer.uk-20190101213807-ay6uqghz0nnrgjvx
Merge trunk.

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