/brz/remove-bazaar

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

« back to all changes in this revision

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

[merge] robertc's integration, updated tests to check for retcode=3

Show diffs side-by-side

added added

removed removed

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