/brz/remove-bazaar

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

« back to all changes in this revision

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

  • Committer: Marius Kruger
  • Date: 2010-07-10 21:28:56 UTC
  • mto: (5384.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5385.
  • Revision ID: marius.kruger@enerweb.co.za-20100710212856-uq4ji3go0u5se7hx
* Update documentation
* add NEWS

Show diffs side-by-side

added added

removed removed

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