~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

(vila) Forbid more operations on ReadonlyTransportDecorator (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006-2012 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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
"""Tests for the info command of bzr."""
19
19
 
20
 
import os
 
20
import shutil
21
21
import sys
22
22
 
23
 
import bzrlib
24
23
from bzrlib import (
 
24
    branch,
25
25
    bzrdir,
 
26
    controldir,
 
27
    errors,
 
28
    info,
26
29
    osutils,
27
 
    repository,
 
30
    tests,
 
31
    upgrade,
28
32
    urlutils,
29
33
    )
30
 
from bzrlib.osutils import format_date
31
 
from bzrlib.tests import TestSkipped
32
 
from bzrlib.tests.blackbox import ExternalBase
33
 
 
34
 
 
35
 
class TestInfo(ExternalBase):
 
34
from bzrlib.tests.matchers import ContainsNoVfsCalls
 
35
from bzrlib.transport import memory
 
36
 
 
37
 
 
38
class TestInfo(tests.TestCaseWithTransport):
 
39
 
 
40
    def setUp(self):
 
41
        super(TestInfo, self).setUp()
 
42
        self._repo_strings = "2a"
36
43
 
37
44
    def test_info_non_existing(self):
38
 
        if sys.platform == "win32":
39
 
            location = "C:/i/do/not/exist/"
40
 
        else:
41
 
            location = "/i/do/not/exist/"
 
45
        self.vfs_transport_factory = memory.MemoryServer
 
46
        location = self.get_url()
42
47
        out, err = self.run_bzr('info '+location, retcode=3)
43
48
        self.assertEqual(out, '')
44
 
        self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
 
49
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
 
50
 
 
51
    def test_info_empty_controldir(self):
 
52
        self.make_bzrdir('ctrl')
 
53
        out, err = self.run_bzr('info ctrl')
 
54
        self.assertEquals(out,
 
55
            'Empty control directory (format: 2a or pack-0.92)\n'
 
56
            'Location:\n'
 
57
            '  control directory: ctrl\n')
 
58
        self.assertEquals(err, '')
 
59
 
 
60
    def test_info_empty_controldir_verbose(self):
 
61
        self.make_bzrdir('ctrl')
 
62
        out, err = self.run_bzr('info -v ctrl')
 
63
        self.assertEqualDiff(out,
 
64
            'Empty control directory (format: 2a or pack-0.92)\n'
 
65
            'Location:\n'
 
66
            '  control directory: ctrl\n\n'
 
67
            'Format:\n'
 
68
            '       control: Meta directory format 1\n\n'
 
69
            'Control directory:\n'
 
70
            '         0 branches\n')
 
71
        self.assertEquals(err, '')
 
72
 
 
73
    def test_info_dangling_branch_reference(self):
 
74
        br = self.make_branch('target')
 
75
        br.create_checkout('from', lightweight=True)
 
76
        shutil.rmtree('target')
 
77
        out, err = self.run_bzr('info from')
 
78
        self.assertEquals(out,
 
79
            'Dangling branch reference (format: 2a or pack-0.92)\n'
 
80
            'Location:\n'
 
81
            '   control directory: from\n'
 
82
            '  checkout of branch: target\n')
 
83
        self.assertEquals(err, '')
45
84
 
46
85
    def test_info_standalone(self):
47
86
        transport = self.get_transport()
48
87
 
49
88
        # Create initial standalone branch
50
 
        tree1 = self.make_branch_and_tree('standalone', 'weave')
 
89
        tree1 = self.make_branch_and_tree('standalone', 'knit')
51
90
        self.build_tree(['standalone/a'])
52
91
        tree1.add('a')
53
92
        branch1 = tree1.branch
54
93
 
55
94
        out, err = self.run_bzr('info standalone')
56
95
        self.assertEqualDiff(
57
 
"""Standalone tree (format: weave)
 
96
"""Standalone tree (format: knit)
58
97
Location:
59
98
  branch root: standalone
60
99
""", out)
61
100
        self.assertEqual('', err)
62
101
 
 
102
        # Standalone branch - verbose mode
63
103
        out, err = self.run_bzr('info standalone -v')
64
104
        self.assertEqualDiff(
65
 
"""Standalone tree (format: weave)
66
 
Location:
67
 
  branch root: standalone
68
 
 
69
 
Format:
70
 
       control: All-in-one format 6
71
 
  working tree: Working tree format 2
72
 
        branch: Branch format 4
73
 
    repository: Weave repository format 6
 
105
"""Standalone tree (format: knit)
 
106
Location:
 
107
  branch root: standalone
 
108
 
 
109
Format:
 
110
       control: Meta directory format 1
 
111
  working tree: Working tree format 3
 
112
        branch: Branch format 5
 
113
    repository: Knit repository format 1
 
114
 
 
115
Control directory:
 
116
         1 branches
 
117
 
 
118
In the working tree:
 
119
         0 unchanged
 
120
         0 modified
 
121
         1 added
 
122
         0 removed
 
123
         0 renamed
 
124
         0 unknown
 
125
         0 ignored
 
126
         0 versioned subdirectories
 
127
 
 
128
Branch history:
 
129
         0 revisions
 
130
 
 
131
Repository:
 
132
         0 revisions
 
133
""", out)
 
134
        self.assertEqual('', err)
 
135
 
 
136
        # Standalone branch - really verbose mode
 
137
        out, err = self.run_bzr('info standalone -vv')
 
138
        self.assertEqualDiff(
 
139
"""Standalone tree (format: knit)
 
140
Location:
 
141
  branch root: standalone
 
142
 
 
143
Format:
 
144
       control: Meta directory format 1
 
145
  working tree: Working tree format 3
 
146
        branch: Branch format 5
 
147
    repository: Knit repository format 1
 
148
 
 
149
Control directory:
 
150
         1 branches
74
151
 
75
152
In the working tree:
76
153
         0 unchanged
88
165
 
89
166
Repository:
90
167
         0 revisions
91
 
         0 KiB
92
168
""", out)
93
169
        self.assertEqual('', err)
94
170
        tree1.commit('commit one')
95
 
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
96
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
171
        rev = branch1.repository.get_revision(branch1.last_revision())
 
172
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
97
173
 
98
174
        # Branch standalone with push location
99
175
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
101
177
 
102
178
        out, err = self.run_bzr('info branch')
103
179
        self.assertEqualDiff(
104
 
"""Standalone tree (format: weave)
 
180
"""Standalone tree (format: knit)
105
181
Location:
106
182
  branch root: branch
107
183
 
113
189
 
114
190
        out, err = self.run_bzr('info branch --verbose')
115
191
        self.assertEqualDiff(
116
 
"""Standalone tree (format: weave)
 
192
"""Standalone tree (format: knit)
117
193
Location:
118
194
  branch root: branch
119
195
 
122
198
  parent branch: standalone
123
199
 
124
200
Format:
125
 
       control: All-in-one format 6
126
 
  working tree: Working tree format 2
127
 
        branch: Branch format 4
128
 
    repository: Weave repository format 6
 
201
       control: Meta directory format 1
 
202
  working tree: Working tree format 3
 
203
        branch: Branch format 5
 
204
    repository: Knit repository format 1
 
205
 
 
206
Control directory:
 
207
         1 branches
129
208
 
130
209
In the working tree:
131
210
         1 unchanged
139
218
 
140
219
Branch history:
141
220
         1 revision
142
 
         1 committer
143
221
         0 days old
144
222
   first revision: %s
145
223
  latest revision: %s
146
224
 
147
225
Repository:
148
226
         1 revision
149
 
         %d KiB
150
227
""" % (datestring_first, datestring_first,
151
 
       # poking at _revision_store isn't all that clean, but neither is
152
 
       # having the ui test dependent on the exact overhead of a given store.
153
 
       branch2.repository._revision_store.total_size(
154
 
        branch2.repository.get_transaction())[1] / 1024,
155
228
       ), out)
156
229
        self.assertEqual('', err)
157
230
 
158
231
        # Branch and bind to standalone, needs upgrade to metadir
159
232
        # (creates backup as unknown)
160
233
        branch1.bzrdir.sprout('bound')
161
 
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
162
 
        bzrlib.upgrade.upgrade('bound', knit1_format)
163
 
        branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
 
234
        knit1_format = controldir.format_registry.make_bzrdir('knit')
 
235
        upgrade.upgrade('bound', knit1_format)
 
236
        branch3 = controldir.ControlDir.open('bound').open_branch()
164
237
        branch3.bind(branch1)
165
238
        bound_tree = branch3.bzrdir.open_workingtree()
166
239
        out, err = self.run_bzr('info -v bound')
179
252
        branch: %s
180
253
    repository: %s
181
254
 
 
255
Control directory:
 
256
         1 branches
 
257
 
182
258
In the working tree:
183
259
         1 unchanged
184
260
         0 modified
185
261
         0 added
186
262
         0 removed
187
263
         0 renamed
188
 
         1 unknown
 
264
         0 unknown
189
265
         0 ignored
190
266
         0 versioned subdirectories
191
267
 
192
268
Branch history:
193
269
         1 revision
194
 
         1 committer
195
270
         0 days old
196
271
   first revision: %s
197
272
  latest revision: %s
198
273
 
199
274
Repository:
200
275
         1 revision
201
 
         %d KiB
202
276
""" % (bound_tree._format.get_format_description(),
203
277
       branch3._format.get_format_description(),
204
278
       branch3.repository._format.get_format_description(),
205
279
       datestring_first, datestring_first,
206
 
       # poking at _revision_store isn't all that clean, but neither is
207
 
       # having the ui test dependent on the exact overhead of a given store.
208
 
       branch3.repository._revision_store.total_size(
209
 
        branch3.repository.get_transaction())[1] / 1024,
210
280
       ), out)
211
281
        self.assertEqual('', err)
212
282
 
213
283
        # Checkout standalone (same as above, but does not have parent set)
214
 
        branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
 
284
        branch4 = controldir.ControlDir.create_branch_convenience('checkout',
215
285
            format=knit1_format)
216
286
        branch4.bind(branch1)
217
287
        branch4.bzrdir.open_workingtree().update()
228
298
        branch: Branch format 5
229
299
    repository: %s
230
300
 
 
301
Control directory:
 
302
         1 branches
 
303
 
231
304
In the working tree:
232
305
         1 unchanged
233
306
         0 modified
240
313
 
241
314
Branch history:
242
315
         1 revision
243
 
         1 committer
244
316
         0 days old
245
317
   first revision: %s
246
318
  latest revision: %s
247
319
 
248
320
Repository:
249
321
         1 revision
250
 
         %d KiB
251
322
""" % (branch4.repository._format.get_format_description(),
252
323
       datestring_first, datestring_first,
253
 
       # poking at _revision_store isn't all that clean, but neither is
254
 
       # having the ui test dependent on the exact overhead of a given store.
255
 
       branch4.repository._revision_store.total_size(
256
 
        branch4.repository.get_transaction())[1] / 1024,
257
324
       ), out)
258
325
        self.assertEqual('', err)
259
326
 
261
328
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
262
329
        branch5 = tree5.branch
263
330
        out, err = self.run_bzr('info -v lightcheckout')
 
331
        if "metaweave" in controldir.format_registry:
 
332
            format_description = "knit or metaweave"
 
333
        else:
 
334
            format_description = "knit"
264
335
        self.assertEqualDiff(
265
 
"""Lightweight checkout (format: dirstate or dirstate-tags)
 
336
"""Lightweight checkout (format: %s)
266
337
Location:
267
338
  light checkout root: lightcheckout
268
339
   checkout of branch: standalone
269
340
 
270
341
Format:
271
342
       control: Meta directory format 1
272
 
  working tree: Working tree format 4
273
 
        branch: Branch format 4
274
 
    repository: Weave repository format 6
 
343
  working tree: Working tree format 3
 
344
        branch: Branch format 5
 
345
    repository: Knit repository format 1
 
346
 
 
347
Control directory:
 
348
         1 branches
275
349
 
276
350
In the working tree:
277
351
         1 unchanged
285
359
 
286
360
Branch history:
287
361
         1 revision
288
 
         1 committer
289
362
         0 days old
290
363
   first revision: %s
291
364
  latest revision: %s
292
365
 
293
366
Repository:
294
367
         1 revision
295
 
         0 KiB
296
 
""" % (datestring_first, datestring_first,), out)
 
368
""" % (format_description, datestring_first, datestring_first,), out)
297
369
        self.assertEqual('', err)
298
370
 
299
371
        # Update initial standalone branch
300
372
        self.build_tree(['standalone/b'])
301
373
        tree1.add('b')
302
374
        tree1.commit('commit two')
303
 
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
304
 
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
375
        rev = branch1.repository.get_revision(branch1.last_revision())
 
376
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
305
377
 
306
378
        # Out of date branched standalone branch will not be detected
307
379
        out, err = self.run_bzr('info -v branch')
308
380
        self.assertEqualDiff(
309
 
"""Standalone tree (format: weave)
 
381
"""Standalone tree (format: knit)
310
382
Location:
311
383
  branch root: branch
312
384
 
315
387
  parent branch: standalone
316
388
 
317
389
Format:
318
 
       control: All-in-one format 6
319
 
  working tree: Working tree format 2
320
 
        branch: Branch format 4
321
 
    repository: Weave repository format 6
 
390
       control: Meta directory format 1
 
391
  working tree: Working tree format 3
 
392
        branch: Branch format 5
 
393
    repository: Knit repository format 1
 
394
 
 
395
Control directory:
 
396
         1 branches
322
397
 
323
398
In the working tree:
324
399
         1 unchanged
332
407
 
333
408
Branch history:
334
409
         1 revision
335
 
         1 committer
336
410
         0 days old
337
411
   first revision: %s
338
412
  latest revision: %s
339
413
 
340
414
Repository:
341
415
         1 revision
342
 
         0 KiB
343
416
""" % (datestring_first, datestring_first,
344
417
       ), out)
345
418
        self.assertEqual('', err)
361
434
        branch: Branch format 5
362
435
    repository: %s
363
436
 
 
437
Control directory:
 
438
         1 branches
 
439
 
364
440
Branch is out of date: missing 1 revision.
365
441
 
366
442
In the working tree:
369
445
         0 added
370
446
         0 removed
371
447
         0 renamed
372
 
         1 unknown
 
448
         0 unknown
373
449
         0 ignored
374
450
         0 versioned subdirectories
375
451
 
376
452
Branch history:
377
453
         1 revision
378
 
         1 committer
379
454
         0 days old
380
455
   first revision: %s
381
456
  latest revision: %s
382
457
 
383
458
Repository:
384
459
         1 revision
385
 
         %d KiB
386
460
""" % (branch3.repository._format.get_format_description(),
387
461
       datestring_first, datestring_first,
388
 
       # poking at _revision_store isn't all that clean, but neither is
389
 
       # having the ui test dependent on the exact overhead of a given store.
390
 
       branch3.repository._revision_store.total_size(
391
 
        branch3.repository.get_transaction())[1] / 1024,
392
462
       ), out)
393
463
        self.assertEqual('', err)
394
464
 
406
476
        branch: Branch format 5
407
477
    repository: %s
408
478
 
 
479
Control directory:
 
480
         1 branches
 
481
 
409
482
Branch is out of date: missing 1 revision.
410
483
 
411
484
In the working tree:
420
493
 
421
494
Branch history:
422
495
         1 revision
423
 
         1 committer
424
496
         0 days old
425
497
   first revision: %s
426
498
  latest revision: %s
427
499
 
428
500
Repository:
429
501
         1 revision
430
 
         %d KiB
431
502
""" % (branch4.repository._format.get_format_description(),
432
503
       datestring_first, datestring_first,
433
 
       # poking at _revision_store isn't all that clean, but neither is
434
 
       # having the ui test dependent on the exact overhead of a given store.
435
 
       branch4.repository._revision_store.total_size(
436
 
        branch4.repository.get_transaction())[1] / 1024,
437
504
       ), out)
438
505
        self.assertEqual('', err)
439
506
 
440
507
        # Out of date lightweight checkout
441
508
        out, err = self.run_bzr('info lightcheckout --verbose')
442
509
        self.assertEqualDiff(
443
 
"""Lightweight checkout (format: dirstate or dirstate-tags)
 
510
"""Lightweight checkout (format: %s)
444
511
Location:
445
512
  light checkout root: lightcheckout
446
513
   checkout of branch: standalone
447
514
 
448
515
Format:
449
516
       control: Meta directory format 1
450
 
  working tree: Working tree format 4
451
 
        branch: Branch format 4
452
 
    repository: Weave repository format 6
 
517
  working tree: Working tree format 3
 
518
        branch: Branch format 5
 
519
    repository: Knit repository format 1
 
520
 
 
521
Control directory:
 
522
         1 branches
453
523
 
454
524
Working tree is out of date: missing 1 revision.
455
525
 
465
535
 
466
536
Branch history:
467
537
         2 revisions
468
 
         1 committer
469
538
         0 days old
470
539
   first revision: %s
471
540
  latest revision: %s
472
541
 
473
542
Repository:
474
543
         2 revisions
475
 
         0 KiB
476
 
""" % (datestring_first, datestring_last,), out)
 
544
""" % (format_description, datestring_first, datestring_last,), out)
477
545
        self.assertEqual('', err)
478
546
 
479
547
    def test_info_standalone_no_tree(self):
480
548
        # create standalone branch without a working tree
481
 
        format = bzrdir.format_registry.make_bzrdir('default')
 
549
        format = controldir.format_registry.make_bzrdir('default')
482
550
        branch = self.make_branch('branch')
483
551
        repo = branch.repository
484
552
        out, err = self.run_bzr('info branch -v')
485
553
        self.assertEqualDiff(
486
 
"""Standalone branch (format: dirstate or knit)
 
554
"""Standalone branch (format: %s)
487
555
Location:
488
556
  branch root: branch
489
557
 
492
560
        branch: %s
493
561
    repository: %s
494
562
 
 
563
Control directory:
 
564
         1 branches
 
565
 
495
566
Branch history:
496
567
         0 revisions
497
 
         0 committers
498
568
 
499
569
Repository:
500
570
         0 revisions
501
 
         0 KiB
502
 
""" % (format.get_branch_format().get_format_description(),
 
571
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
 
572
       format.get_branch_format().get_format_description(),
503
573
       format.repository_format.get_format_description(),
504
574
       ), out)
505
575
        self.assertEqual('', err)
506
576
 
507
577
    def test_info_shared_repository(self):
508
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
578
        format = controldir.format_registry.make_bzrdir('knit')
509
579
        transport = self.get_transport()
510
580
 
511
581
        # Create shared repository
521
591
       control: Meta directory format 1
522
592
    repository: %s
523
593
 
 
594
Control directory:
 
595
         0 branches
 
596
 
524
597
Repository:
525
598
         0 revisions
526
 
         0 KiB
527
599
""" % ('repo', format.repository_format.get_format_description(),
528
600
       ), out)
529
601
        self.assertEqual('', err)
530
602
 
531
603
        # Create branch inside shared repository
532
604
        repo.bzrdir.root_transport.mkdir('branch')
533
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
534
 
            format=format)
 
605
        branch1 = controldir.ControlDir.create_branch_convenience(
 
606
            'repo/branch', format=format)
535
607
        out, err = self.run_bzr('info -v repo/branch')
536
608
        self.assertEqualDiff(
537
609
"""Repository branch (format: dirstate or knit)
544
616
        branch: %s
545
617
    repository: %s
546
618
 
 
619
Control directory:
 
620
         1 branches
 
621
 
547
622
Branch history:
548
623
         0 revisions
549
 
         0 committers
550
624
 
551
625
Repository:
552
626
         0 revisions
553
 
         0 KiB
554
627
""" % (format.get_branch_format().get_format_description(),
555
628
       format.repository_format.get_format_description(),
556
629
       ), out)
559
632
        # Create lightweight checkout
560
633
        transport.mkdir('tree')
561
634
        transport.mkdir('tree/lightcheckout')
562
 
        tree2 = branch1.create_checkout('tree/lightcheckout', 
 
635
        tree2 = branch1.create_checkout('tree/lightcheckout',
563
636
            lightweight=True)
564
637
        branch2 = tree2.branch
565
638
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
574
647
        self.build_tree(['tree/lightcheckout/a'])
575
648
        tree2.add('a')
576
649
        tree2.commit('commit one')
577
 
        rev = repo.get_revision(branch2.revision_history()[0])
578
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
650
        rev = repo.get_revision(branch2.last_revision())
 
651
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
579
652
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
580
653
        self.assertEqualDiff(
581
 
"""Lightweight checkout (format: dirstate or dirstate-tags)
 
654
"""Lightweight checkout (format: %s)
582
655
Location:
583
656
  light checkout root: tree/lightcheckout
584
657
   checkout of branch: repo/branch
586
659
 
587
660
Format:
588
661
       control: Meta directory format 1
589
 
  working tree: Working tree format 4
 
662
  working tree: Working tree format 6
590
663
        branch: %s
591
664
    repository: %s
592
665
 
 
666
Control directory:
 
667
         1 branches
 
668
 
593
669
In the working tree:
594
670
         1 unchanged
595
671
         0 modified
602
678
 
603
679
Branch history:
604
680
         1 revision
605
 
         1 committer
606
681
         0 days old
607
682
   first revision: %s
608
683
  latest revision: %s
609
684
 
610
685
Repository:
611
686
         1 revision
612
 
         %d KiB
613
 
""" % (format.get_branch_format().get_format_description(),
 
687
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
614
688
       format.repository_format.get_format_description(),
615
689
       datestring_first, datestring_first,
616
 
       # poking at _revision_store isn't all that clean, but neither is
617
 
       # having the ui test dependent on the exact overhead of a given store.
618
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
619
690
       ), out)
620
691
        self.assertEqual('', err)
621
692
 
622
693
        # Out of date checkout
623
694
        out, err = self.run_bzr('info -v tree/checkout')
624
695
        self.assertEqualDiff(
625
 
"""Checkout (format: dirstate)
 
696
"""Checkout (format: unnamed)
626
697
Location:
627
698
       checkout root: tree/checkout
628
699
  checkout of branch: repo/branch
629
700
 
630
701
Format:
631
702
       control: Meta directory format 1
632
 
  working tree: Working tree format 4
 
703
  working tree: Working tree format 6
633
704
        branch: %s
634
705
    repository: %s
635
706
 
 
707
Control directory:
 
708
         1 branches
 
709
 
636
710
Branch is out of date: missing 1 revision.
637
711
 
638
712
In the working tree:
647
721
 
648
722
Branch history:
649
723
         0 revisions
650
 
         0 committers
651
724
 
652
725
Repository:
653
726
         0 revisions
654
 
         0 KiB
655
727
""" % (format.get_branch_format().get_format_description(),
656
728
       format.repository_format.get_format_description(),
657
729
       ), out)
663
735
        tree3.add('b')
664
736
        out, err = self.run_bzr('info tree/checkout --verbose')
665
737
        self.assertEqualDiff(
666
 
"""Checkout (format: dirstate)
 
738
"""Checkout (format: unnamed)
667
739
Location:
668
740
       checkout root: tree/checkout
669
741
  checkout of branch: repo/branch
670
742
 
671
743
Format:
672
744
       control: Meta directory format 1
673
 
  working tree: Working tree format 4
 
745
  working tree: Working tree format 6
674
746
        branch: %s
675
747
    repository: %s
676
748
 
 
749
Control directory:
 
750
         1 branches
 
751
 
677
752
In the working tree:
678
753
         1 unchanged
679
754
         0 modified
686
761
 
687
762
Branch history:
688
763
         1 revision
689
 
         1 committer
690
764
         0 days old
691
765
   first revision: %s
692
766
  latest revision: %s
693
767
 
694
768
Repository:
695
769
         1 revision
696
 
         %d KiB
697
770
""" % (format.get_branch_format().get_format_description(),
698
771
       format.repository_format.get_format_description(),
699
772
       datestring_first, datestring_first,
700
 
       # poking at _revision_store isn't all that clean, but neither is
701
 
       # having the ui test dependent on the exact overhead of a given store.
702
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
703
773
       ), out)
704
774
        self.assertEqual('', err)
705
775
        tree3.commit('commit two')
706
776
 
707
777
        # Out of date lightweight checkout
708
 
        rev = repo.get_revision(branch1.revision_history()[-1])
709
 
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
778
        rev = repo.get_revision(branch1.last_revision())
 
779
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
710
780
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
711
781
        self.assertEqualDiff(
712
 
"""Lightweight checkout (format: dirstate or dirstate-tags)
 
782
"""Lightweight checkout (format: %s)
713
783
Location:
714
784
  light checkout root: tree/lightcheckout
715
785
   checkout of branch: repo/branch
717
787
 
718
788
Format:
719
789
       control: Meta directory format 1
720
 
  working tree: Working tree format 4
 
790
  working tree: Working tree format 6
721
791
        branch: %s
722
792
    repository: %s
723
793
 
 
794
Control directory:
 
795
         1 branches
 
796
 
724
797
Working tree is out of date: missing 1 revision.
725
798
 
726
799
In the working tree:
735
808
 
736
809
Branch history:
737
810
         2 revisions
738
 
         1 committer
739
811
         0 days old
740
812
   first revision: %s
741
813
  latest revision: %s
742
814
 
743
815
Repository:
744
816
         2 revisions
745
 
         %d KiB
746
 
""" % (format.get_branch_format().get_format_description(),
 
817
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
747
818
       format.repository_format.get_format_description(),
748
819
       datestring_first, datestring_last,
749
 
       # poking at _revision_store isn't all that clean, but neither is
750
 
       # having the ui test dependent on the exact overhead of a given store.
751
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
752
820
       ), out)
753
821
        self.assertEqual('', err)
754
822
 
765
833
        branch: %s
766
834
    repository: %s
767
835
 
 
836
Control directory:
 
837
         1 branches
 
838
 
768
839
Branch history:
769
840
         2 revisions
770
 
         1 committer
771
841
         0 days old
772
842
   first revision: %s
773
843
  latest revision: %s
774
844
 
775
845
Repository:
776
846
         2 revisions
777
 
         %d KiB
778
847
""" % (format.get_branch_format().get_format_description(),
779
848
       format.repository_format.get_format_description(),
780
849
       datestring_first, datestring_last,
781
 
       # poking at _revision_store isn't all that clean, but neither is
782
 
       # having the ui test dependent on the exact overhead of a given store.
783
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
784
850
       ), out)
785
851
        self.assertEqual('', err)
786
852
 
795
861
       control: Meta directory format 1
796
862
    repository: %s
797
863
 
 
864
Control directory:
 
865
         0 branches
 
866
 
798
867
Repository:
799
868
         2 revisions
800
 
         %d KiB
801
869
""" % (format.repository_format.get_format_description(),
802
 
       # poking at _revision_store isn't all that clean, but neither is
803
 
       # having the ui test dependent on the exact overhead of a given store.
804
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
805
870
       ), out)
806
871
        self.assertEqual('', err)
807
872
 
808
873
    def test_info_shared_repository_with_trees(self):
809
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
874
        format = controldir.format_registry.make_bzrdir('knit')
810
875
        transport = self.get_transport()
811
876
 
812
877
        # Create shared repository with working trees
822
887
       control: Meta directory format 1
823
888
    repository: %s
824
889
 
 
890
Control directory:
 
891
         0 branches
 
892
 
825
893
Create working tree for new branches inside the repository.
826
894
 
827
895
Repository:
828
896
         0 revisions
829
 
         0 KiB
830
897
""" % (format.repository_format.get_format_description(),
831
898
       ), out)
832
899
        self.assertEqual('', err)
833
900
 
834
901
        # Create two branches
835
902
        repo.bzrdir.root_transport.mkdir('branch1')
836
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
 
903
        branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
837
904
            format=format)
838
905
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
839
906
 
851
918
        branch: %s
852
919
    repository: %s
853
920
 
 
921
Control directory:
 
922
         1 branches
 
923
 
854
924
In the working tree:
855
925
         0 unchanged
856
926
         0 modified
863
933
 
864
934
Branch history:
865
935
         0 revisions
866
 
         0 committers
867
936
 
868
937
Repository:
869
938
         0 revisions
870
 
         0 KiB
871
939
""" % (format.get_branch_format().get_format_description(),
872
940
       format.repository_format.get_format_description(),
873
941
       ), out)
878
946
        tree1 = branch1.bzrdir.open_workingtree()
879
947
        tree1.add('a')
880
948
        tree1.commit('commit one')
881
 
        rev = repo.get_revision(branch1.revision_history()[0])
882
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
949
        rev = repo.get_revision(branch1.last_revision())
 
950
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
883
951
        out, err = self.run_bzr('info -v repo/branch1')
884
952
        self.assertEqualDiff(
885
953
"""Repository tree (format: knit)
893
961
        branch: %s
894
962
    repository: %s
895
963
 
 
964
Control directory:
 
965
         1 branches
 
966
 
896
967
In the working tree:
897
968
         1 unchanged
898
969
         0 modified
905
976
 
906
977
Branch history:
907
978
         1 revision
908
 
         1 committer
909
979
         0 days old
910
980
   first revision: %s
911
981
  latest revision: %s
912
982
 
913
983
Repository:
914
984
         1 revision
915
 
         %d KiB
916
985
""" % (format.get_branch_format().get_format_description(),
917
986
       format.repository_format.get_format_description(),
918
987
       datestring_first, datestring_first,
919
 
       # poking at _revision_store isn't all that clean, but neither is
920
 
       # having the ui test dependent on the exact overhead of a given store.
921
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
922
988
       ), out)
923
989
        self.assertEqual('', err)
924
990
 
939
1005
        branch: %s
940
1006
    repository: %s
941
1007
 
 
1008
Control directory:
 
1009
         1 branches
 
1010
 
942
1011
In the working tree:
943
1012
         0 unchanged
944
1013
         0 modified
951
1020
 
952
1021
Branch history:
953
1022
         0 revisions
954
 
         0 committers
955
1023
 
956
1024
Repository:
957
1025
         1 revision
958
 
         %d KiB
959
1026
""" % (format.get_branch_format().get_format_description(),
960
1027
       format.repository_format.get_format_description(),
961
 
       # poking at _revision_store isn't all that clean, but neither is
962
 
       # having the ui test dependent on the exact overhead of a given store.
963
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
964
1028
       ), out)
965
1029
        self.assertEqual('', err)
966
1030
 
983
1047
        branch: %s
984
1048
    repository: %s
985
1049
 
 
1050
Control directory:
 
1051
         1 branches
 
1052
 
986
1053
In the working tree:
987
1054
         1 unchanged
988
1055
         0 modified
995
1062
 
996
1063
Branch history:
997
1064
         1 revision
998
 
         1 committer
999
1065
         0 days old
1000
1066
   first revision: %s
1001
1067
  latest revision: %s
1002
1068
 
1003
1069
Repository:
1004
1070
         1 revision
1005
 
         %d KiB
1006
1071
""" % (format.get_branch_format().get_format_description(),
1007
1072
       format.repository_format.get_format_description(),
1008
1073
       datestring_first, datestring_first,
1009
 
       # poking at _revision_store isn't all that clean, but neither is
1010
 
       # having the ui test dependent on the exact overhead of a given store.
1011
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1012
1074
       ), out)
1013
1075
        self.assertEqual('', err)
1014
1076
 
1023
1085
       control: Meta directory format 1
1024
1086
    repository: %s
1025
1087
 
 
1088
Control directory:
 
1089
         0 branches
 
1090
 
1026
1091
Create working tree for new branches inside the repository.
1027
1092
 
1028
1093
Repository:
1029
1094
         1 revision
1030
 
         %d KiB
1031
1095
""" % (format.repository_format.get_format_description(),
1032
 
       # poking at _revision_store isn't all that clean, but neither is
1033
 
       # having the ui test dependent on the exact overhead of a given store.
1034
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1035
1096
       ),
1036
1097
       out)
1037
1098
        self.assertEqual('', err)
1038
 
    
 
1099
 
1039
1100
    def test_info_shared_repository_with_tree_in_root(self):
1040
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
1101
        format = controldir.format_registry.make_bzrdir('knit')
1041
1102
        transport = self.get_transport()
1042
1103
 
1043
1104
        # Create shared repository with working trees
1053
1114
       control: Meta directory format 1
1054
1115
    repository: %s
1055
1116
 
 
1117
Control directory:
 
1118
         0 branches
 
1119
 
1056
1120
Create working tree for new branches inside the repository.
1057
1121
 
1058
1122
Repository:
1059
1123
         0 revisions
1060
 
         0 KiB
1061
1124
""" % (format.repository_format.get_format_description(),
1062
1125
       ), out)
1063
1126
        self.assertEqual('', err)
1079
1142
        branch: %s
1080
1143
    repository: %s
1081
1144
 
 
1145
Control directory:
 
1146
         1 branches
 
1147
 
1082
1148
In the working tree:
1083
1149
         0 unchanged
1084
1150
         0 modified
1091
1157
 
1092
1158
Branch history:
1093
1159
         0 revisions
1094
 
         0 committers
1095
1160
 
1096
1161
Repository:
1097
1162
         0 revisions
1098
 
         0 KiB
1099
1163
""" % (format.get_branch_format().get_format_description(),
1100
1164
       format.repository_format.get_format_description(),
1101
1165
       ), out)
1102
1166
        self.assertEqual('', err)
1103
1167
 
1104
 
    def assertCheckoutStatusOutput(self, 
 
1168
    def test_info_repository_hook(self):
 
1169
        format = controldir.format_registry.make_bzrdir('knit')
 
1170
        def repo_info(repo, stats, outf):
 
1171
            outf.write("more info\n")
 
1172
        info.hooks.install_named_hook('repository', repo_info, None)
 
1173
        # Create shared repository with working trees
 
1174
        repo = self.make_repository('repo', shared=True, format=format)
 
1175
        out, err = self.run_bzr('info -v repo')
 
1176
        self.assertEqualDiff(
 
1177
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
1178
Location:
 
1179
  shared repository: repo
 
1180
 
 
1181
Format:
 
1182
       control: Meta directory format 1
 
1183
    repository: %s
 
1184
 
 
1185
Control directory:
 
1186
         0 branches
 
1187
 
 
1188
Create working tree for new branches inside the repository.
 
1189
 
 
1190
Repository:
 
1191
         0 revisions
 
1192
more info
 
1193
""" % (format.repository_format.get_format_description(),
 
1194
       ), out)
 
1195
        self.assertEqual('', err)
 
1196
 
 
1197
    def test_info_unshared_repository_with_colocated_branches(self):
 
1198
        format = controldir.format_registry.make_bzrdir('development-colo')
 
1199
        transport = self.get_transport()
 
1200
 
 
1201
        # Create unshared repository
 
1202
        repo = self.make_repository('repo', shared=False, format=format)
 
1203
        repo.set_make_working_trees(True)
 
1204
        repo.bzrdir.create_branch(name='foo')
 
1205
        out, err = self.run_bzr('info repo')
 
1206
        self.assertEqualDiff(
 
1207
"""Unshared repository with trees and colocated branches (format: development-colo)
 
1208
Location:
 
1209
  repository: repo
 
1210
""", out)
 
1211
        self.assertEqual('', err)
 
1212
 
 
1213
    def assertCheckoutStatusOutput(self,
1105
1214
        command_string, lco_tree, shared_repo=None,
1106
1215
        repo_branch=None,
1107
1216
        tree_locked=False,
1116
1225
        allow us, the test writers, to document what *should* be present in
1117
1226
        the output. Removing this separation would remove the value of the
1118
1227
        tests.
1119
 
        
 
1228
 
1120
1229
        :param path: the path to the light checkout.
1121
1230
        :param lco_tree: the tree object for the light checkout.
1122
1231
        :param shared_repo: A shared repository is in use, expect that in
1126
1235
        :param tree_locked: If true, expect the tree to be locked.
1127
1236
        :param branch_locked: If true, expect the branch to be locked.
1128
1237
        :param repo_locked: If true, expect the repository to be locked.
1129
 
        :param verbose: If true, expect verbose output
 
1238
            Note that the lco_tree.branch.repository is inspected, and if is not
 
1239
            actually locked then this parameter is overridden. This is because
 
1240
            pack repositories do not have any public API for obtaining an
 
1241
            exclusive repository wide lock.
 
1242
        :param verbose: verbosity level: 2 or higher to show committers
1130
1243
        """
1131
1244
        def friendly_location(url):
1132
1245
            path = urlutils.unescape_for_display(url, 'ascii')
1133
1246
            try:
1134
 
                return osutils.relpath(os.getcwd(), path)
 
1247
                return osutils.relpath(osutils.getcwd(), path)
1135
1248
            except errors.PathNotChild:
1136
1249
                return path
1137
1250
 
1138
 
        if tree_locked and sys.platform == 'win32':
1139
 
            # We expect this to fail because of locking errors. (A write-locked
1140
 
            # file cannot be read-locked in the same process).
 
1251
        if tree_locked:
 
1252
            # We expect this to fail because of locking errors.
 
1253
            # (A write-locked file cannot be read-locked
 
1254
            # in the different process -- either on win32 or on linux).
1141
1255
            # This should be removed when the locking errors are fixed.
1142
 
            args = command_string.split(' ')
1143
 
            self.run_bzr_error([], 'info', *args)
1144
 
            return
 
1256
            self.expectFailure('OS locks are exclusive '
 
1257
                'for different processes (Bug #174055)',
 
1258
                self.run_bzr_subprocess,
 
1259
                'info ' + command_string)
1145
1260
        out, err = self.run_bzr('info %s' % command_string)
1146
1261
        description = {
1147
1262
            (True, True): 'Lightweight checkout',
1149
1264
            (False, True): 'Lightweight checkout',
1150
1265
            (False, False): 'Checkout',
1151
1266
            }[(shared_repo is not None, light_checkout)]
1152
 
        format = {True: 'dirstate or dirstate-tags',
1153
 
                  False: 'dirstate'}[light_checkout]
 
1267
        format = {True: self._repo_strings,
 
1268
                  False: 'unnamed'}[light_checkout]
 
1269
        if repo_locked:
 
1270
            repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1154
1271
        if repo_locked or branch_locked or tree_locked:
1155
1272
            def locked_message(a_bool):
1156
1273
                if a_bool:
1191
1308
        else:
1192
1309
            branch_data = ("   checkout of branch: %s\n" %
1193
1310
                lco_tree.branch.bzrdir.root_transport.base)
1194
 
        
1195
 
        if verbose:
 
1311
 
 
1312
        if verbose >= 2:
1196
1313
            verbose_info = '         0 committers\n'
1197
1314
        else:
1198
1315
            verbose_info = ''
1199
 
            
 
1316
 
1200
1317
        self.assertEqualDiff(
1201
1318
"""%s (format: %s)
1202
1319
Location:
1207
1324
        branch: %s
1208
1325
    repository: %s
1209
1326
%s
 
1327
Control directory:
 
1328
         1 branches
 
1329
 
1210
1330
In the working tree:
1211
1331
         0 unchanged
1212
1332
         0 modified
1222
1342
%s
1223
1343
Repository:
1224
1344
         0 revisions
1225
 
         0 KiB
1226
1345
""" %  (description,
1227
1346
        format,
1228
1347
        tree_data,
1239
1358
        transport = self.get_transport()
1240
1359
        # Create shared repository with a branch
1241
1360
        repo = self.make_repository('repo', shared=True,
1242
 
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1361
                                    format=bzrdir.BzrDirMetaFormat1())
1243
1362
        repo.set_make_working_trees(False)
1244
1363
        repo.bzrdir.root_transport.mkdir('branch')
1245
 
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1246
 
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1364
        repo_branch = controldir.ControlDir.create_branch_convenience(
 
1365
            'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1247
1366
        # Do a heavy checkout
1248
1367
        transport.mkdir('tree')
1249
1368
        transport.mkdir('tree/checkout')
1250
 
        co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1251
 
            format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1369
        co_branch = controldir.ControlDir.create_branch_convenience(
 
1370
            'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1252
1371
        co_branch.bind(repo_branch)
1253
1372
        # Do a light checkout of the heavy one
1254
1373
        transport.mkdir('tree/lightcheckout')
1255
 
        lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1256
 
        bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
 
1374
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
 
1375
        lco_dir.set_branch_reference(co_branch)
1257
1376
        lco_dir.create_workingtree()
1258
1377
        lco_tree = lco_dir.open_workingtree()
1259
1378
 
1347
1466
            self.knownFailure('Win32 cannot run "bzr info"'
1348
1467
                              ' when the tree is locked.')
1349
1468
 
1350
 
    def test_info_locking_oslocks(self):
1351
 
        if sys.platform == "win32":
1352
 
            raise TestSkipped("don't use oslocks on win32 in unix manner")
1353
 
 
1354
 
        tree = self.make_branch_and_tree('branch',
1355
 
                                         format=bzrlib.bzrdir.BzrDirFormat6())
1356
 
 
1357
 
        # Test all permutations of locking the working tree, branch and repository
1358
 
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1359
 
        # implemented by raising NotImplementedError and get_physical_lock_status()
1360
 
        # always returns false. This makes bzr info hide the lock status.  (Olaf)
1361
 
        # W B R
1362
 
 
1363
 
        # U U U
1364
 
        out, err = self.run_bzr('info -v branch')
1365
 
        self.assertEqualDiff(
1366
 
"""Standalone tree (format: weave)
1367
 
Location:
1368
 
  branch root: %s
1369
 
 
1370
 
Format:
1371
 
       control: All-in-one format 6
1372
 
  working tree: Working tree format 2
1373
 
        branch: Branch format 4
1374
 
    repository: %s
1375
 
 
1376
 
In the working tree:
1377
 
         0 unchanged
1378
 
         0 modified
1379
 
         0 added
1380
 
         0 removed
1381
 
         0 renamed
1382
 
         0 unknown
1383
 
         0 ignored
1384
 
         0 versioned subdirectories
1385
 
 
1386
 
Branch history:
1387
 
         0 revisions
1388
 
         0 committers
1389
 
 
1390
 
Repository:
1391
 
         0 revisions
1392
 
         0 KiB
1393
 
""" % ('branch', tree.branch.repository._format.get_format_description(),
1394
 
       ), out)
1395
 
        self.assertEqual('', err)
1396
 
        # L L L
1397
 
        tree.lock_write()
1398
 
        out, err = self.run_bzr('info -v branch')
1399
 
        self.assertEqualDiff(
1400
 
"""Standalone tree (format: weave)
1401
 
Location:
1402
 
  branch root: %s
1403
 
 
1404
 
Format:
1405
 
       control: All-in-one format 6
1406
 
  working tree: Working tree format 2
1407
 
        branch: Branch format 4
1408
 
    repository: %s
1409
 
 
1410
 
In the working tree:
1411
 
         0 unchanged
1412
 
         0 modified
1413
 
         0 added
1414
 
         0 removed
1415
 
         0 renamed
1416
 
         0 unknown
1417
 
         0 ignored
1418
 
         0 versioned subdirectories
1419
 
 
1420
 
Branch history:
1421
 
         0 revisions
1422
 
         0 committers
1423
 
 
1424
 
Repository:
1425
 
         0 revisions
1426
 
         0 KiB
1427
 
""" % ('branch', tree.branch.repository._format.get_format_description(),
1428
 
       ), out)
1429
 
        self.assertEqual('', err)
1430
 
        tree.unlock()
 
1469
    def test_info_stacked(self):
 
1470
        # We have a mainline
 
1471
        trunk_tree = self.make_branch_and_tree('mainline',
 
1472
            format='1.6')
 
1473
        trunk_tree.commit('mainline')
 
1474
        # and a branch from it which is stacked
 
1475
        new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
 
1476
        out, err = self.run_bzr('info newbranch')
 
1477
        self.assertEqual(
 
1478
"""Standalone tree (format: 1.6)
 
1479
Location:
 
1480
  branch root: newbranch
 
1481
 
 
1482
Related branches:
 
1483
  parent branch: mainline
 
1484
     stacked on: mainline
 
1485
""", out)
 
1486
        self.assertEqual("", err)
 
1487
 
 
1488
    def test_info_revinfo_optional(self):
 
1489
        tree = self.make_branch_and_tree('.')
 
1490
        def last_revision_info(self):
 
1491
            raise errors.UnsupportedOperation(last_revision_info, self)
 
1492
        self.overrideAttr(
 
1493
            branch.Branch, "last_revision_info", last_revision_info)
 
1494
        out, err = self.run_bzr('info -v .')
 
1495
        self.assertEqual(
 
1496
"""Standalone tree (format: 2a)
 
1497
Location:
 
1498
  branch root: .
 
1499
 
 
1500
Format:
 
1501
       control: Meta directory format 1
 
1502
  working tree: Working tree format 6
 
1503
        branch: Branch format 7
 
1504
    repository: Repository format 2a - rich roots, group compression and chk inventories
 
1505
 
 
1506
Control directory:
 
1507
         1 branches
 
1508
 
 
1509
In the working tree:
 
1510
         0 unchanged
 
1511
         0 modified
 
1512
         0 added
 
1513
         0 removed
 
1514
         0 renamed
 
1515
         0 unknown
 
1516
         0 ignored
 
1517
         0 versioned subdirectories
 
1518
""", out)
 
1519
        self.assertEqual("", err)
 
1520
 
 
1521
    def test_info_shows_colocated_branches(self):
 
1522
        bzrdir = self.make_branch('.', format='development-colo').bzrdir
 
1523
        bzrdir.create_branch(name="colo1")
 
1524
        bzrdir.create_branch(name="colo2")
 
1525
        bzrdir.create_branch(name="colo3")
 
1526
        out, err = self.run_bzr('info -v .')
 
1527
        self.assertEqualDiff(
 
1528
"""Standalone branch (format: development-colo)
 
1529
Location:
 
1530
  branch root: .
 
1531
 
 
1532
Format:
 
1533
       control: Meta directory format 1 with support for colocated branches
 
1534
        branch: Branch format 7
 
1535
    repository: Repository format 2a - rich roots, group compression and chk inventories
 
1536
 
 
1537
Control directory:
 
1538
         4 branches
 
1539
 
 
1540
Branch history:
 
1541
         0 revisions
 
1542
 
 
1543
Repository:
 
1544
         0 revisions
 
1545
""", out)
 
1546
        self.assertEqual("", err)
 
1547
 
 
1548
 
 
1549
class TestSmartServerInfo(tests.TestCaseWithTransport):
 
1550
 
 
1551
    def test_simple_branch_info(self):
 
1552
        self.setup_smart_server_with_call_log()
 
1553
        t = self.make_branch_and_tree('branch')
 
1554
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
1555
        t.add("foo")
 
1556
        t.commit("message")
 
1557
        self.reset_smart_call_log()
 
1558
        out, err = self.run_bzr(['info', self.get_url('branch')])
 
1559
        # This figure represent the amount of work to perform this use case. It
 
1560
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
1561
        # being too low. If rpc_count increases, more network roundtrips have
 
1562
        # become necessary for this use case. Please do not adjust this number
 
1563
        # upwards without agreement from bzr's network support maintainers.
 
1564
        self.assertLength(10, self.hpss_calls)
 
1565
        self.assertLength(1, self.hpss_connections)
 
1566
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
1567
 
 
1568
    def test_verbose_branch_info(self):
 
1569
        self.setup_smart_server_with_call_log()
 
1570
        t = self.make_branch_and_tree('branch')
 
1571
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
1572
        t.add("foo")
 
1573
        t.commit("message")
 
1574
        self.reset_smart_call_log()
 
1575
        out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
 
1576
        # This figure represent the amount of work to perform this use case. It
 
1577
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
1578
        # being too low. If rpc_count increases, more network roundtrips have
 
1579
        # become necessary for this use case. Please do not adjust this number
 
1580
        # upwards without agreement from bzr's network support maintainers.
 
1581
        self.assertLength(14, self.hpss_calls)
 
1582
        self.assertLength(1, self.hpss_connections)
 
1583
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)