/brz/remove-bazaar

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

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2010-02-11 04:39:32 UTC
  • mto: This revision was merged to the branch mainline in revision 5029.
  • Revision ID: mbp@sourcefrog.net-20100211043932-532njgzc06f128zf
guarded_malloc(0) => NULL

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006-2010 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 sys
 
21
 
 
22
from bzrlib import (
 
23
    branch,
 
24
    bzrdir,
 
25
    errors,
 
26
    info,
 
27
    osutils,
 
28
    tests,
 
29
    upgrade,
 
30
    urlutils,
 
31
    )
 
32
from bzrlib.transport import memory
 
33
 
 
34
class TestInfo(tests.TestCaseWithTransport):
 
35
 
 
36
    def setUp(self):
 
37
        super(TestInfo, self).setUp()
 
38
        self._repo_strings = "2a"
 
39
 
 
40
    def test_info_non_existing(self):
 
41
        self.vfs_transport_factory = memory.MemoryServer
 
42
        location = self.get_url()
 
43
        out, err = self.run_bzr('info '+location, retcode=3)
 
44
        self.assertEqual(out, '')
 
45
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
 
46
 
 
47
    def test_info_standalone(self):
 
48
        transport = self.get_transport()
 
49
 
 
50
        # Create initial standalone branch
 
51
        tree1 = self.make_branch_and_tree('standalone', 'weave')
 
52
        self.build_tree(['standalone/a'])
 
53
        tree1.add('a')
 
54
        branch1 = tree1.branch
 
55
 
 
56
        out, err = self.run_bzr('info standalone')
 
57
        self.assertEqualDiff(
 
58
"""Standalone tree (format: weave)
 
59
Location:
 
60
  branch root: standalone
 
61
""", out)
 
62
        self.assertEqual('', err)
 
63
 
 
64
        # Standalone branch - verbose mode
 
65
        out, err = self.run_bzr('info standalone -v')
 
66
        self.assertEqualDiff(
 
67
"""Standalone tree (format: weave)
 
68
Location:
 
69
  branch root: standalone
 
70
 
 
71
Format:
 
72
       control: All-in-one format 6
 
73
  working tree: Working tree format 2
 
74
        branch: Branch format 4
 
75
    repository: Weave repository format 6
 
76
 
 
77
In the working tree:
 
78
         0 unchanged
 
79
         0 modified
 
80
         1 added
 
81
         0 removed
 
82
         0 renamed
 
83
         0 unknown
 
84
         0 ignored
 
85
         0 versioned subdirectories
 
86
 
 
87
Branch history:
 
88
         0 revisions
 
89
 
 
90
Repository:
 
91
         0 revisions
 
92
""", out)
 
93
        self.assertEqual('', err)
 
94
 
 
95
        # Standalone branch - really verbose mode
 
96
        out, err = self.run_bzr('info standalone -vv')
 
97
        self.assertEqualDiff(
 
98
"""Standalone tree (format: weave)
 
99
Location:
 
100
  branch root: standalone
 
101
 
 
102
Format:
 
103
       control: All-in-one format 6
 
104
  working tree: Working tree format 2
 
105
        branch: Branch format 4
 
106
    repository: Weave repository format 6
 
107
 
 
108
In the working tree:
 
109
         0 unchanged
 
110
         0 modified
 
111
         1 added
 
112
         0 removed
 
113
         0 renamed
 
114
         0 unknown
 
115
         0 ignored
 
116
         0 versioned subdirectories
 
117
 
 
118
Branch history:
 
119
         0 revisions
 
120
         0 committers
 
121
 
 
122
Repository:
 
123
         0 revisions
 
124
""", out)
 
125
        self.assertEqual('', err)
 
126
        tree1.commit('commit one')
 
127
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
 
128
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
129
 
 
130
        # Branch standalone with push location
 
131
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
 
132
        branch2.set_push_location(branch1.bzrdir.root_transport.base)
 
133
 
 
134
        out, err = self.run_bzr('info branch')
 
135
        self.assertEqualDiff(
 
136
"""Standalone tree (format: weave)
 
137
Location:
 
138
  branch root: branch
 
139
 
 
140
Related branches:
 
141
    push branch: standalone
 
142
  parent branch: standalone
 
143
""", out)
 
144
        self.assertEqual('', err)
 
145
 
 
146
        out, err = self.run_bzr('info branch --verbose')
 
147
        self.assertEqualDiff(
 
148
"""Standalone tree (format: weave)
 
149
Location:
 
150
  branch root: branch
 
151
 
 
152
Related branches:
 
153
    push branch: standalone
 
154
  parent branch: standalone
 
155
 
 
156
Format:
 
157
       control: All-in-one format 6
 
158
  working tree: Working tree format 2
 
159
        branch: Branch format 4
 
160
    repository: Weave repository format 6
 
161
 
 
162
In the working tree:
 
163
         1 unchanged
 
164
         0 modified
 
165
         0 added
 
166
         0 removed
 
167
         0 renamed
 
168
         0 unknown
 
169
         0 ignored
 
170
         0 versioned subdirectories
 
171
 
 
172
Branch history:
 
173
         1 revision
 
174
         0 days old
 
175
   first revision: %s
 
176
  latest revision: %s
 
177
 
 
178
Repository:
 
179
         1 revision
 
180
""" % (datestring_first, datestring_first,
 
181
       ), out)
 
182
        self.assertEqual('', err)
 
183
 
 
184
        # Branch and bind to standalone, needs upgrade to metadir
 
185
        # (creates backup as unknown)
 
186
        branch1.bzrdir.sprout('bound')
 
187
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
 
188
        upgrade.upgrade('bound', knit1_format)
 
189
        branch3 = bzrdir.BzrDir.open('bound').open_branch()
 
190
        branch3.bind(branch1)
 
191
        bound_tree = branch3.bzrdir.open_workingtree()
 
192
        out, err = self.run_bzr('info -v bound')
 
193
        self.assertEqualDiff(
 
194
"""Checkout (format: knit)
 
195
Location:
 
196
       checkout root: bound
 
197
  checkout of branch: standalone
 
198
 
 
199
Related branches:
 
200
  parent branch: standalone
 
201
 
 
202
Format:
 
203
       control: Meta directory format 1
 
204
  working tree: %s
 
205
        branch: %s
 
206
    repository: %s
 
207
 
 
208
In the working tree:
 
209
         1 unchanged
 
210
         0 modified
 
211
         0 added
 
212
         0 removed
 
213
         0 renamed
 
214
         1 unknown
 
215
         0 ignored
 
216
         0 versioned subdirectories
 
217
 
 
218
Branch history:
 
219
         1 revision
 
220
         0 days old
 
221
   first revision: %s
 
222
  latest revision: %s
 
223
 
 
224
Repository:
 
225
         1 revision
 
226
""" % (bound_tree._format.get_format_description(),
 
227
       branch3._format.get_format_description(),
 
228
       branch3.repository._format.get_format_description(),
 
229
       datestring_first, datestring_first,
 
230
       ), out)
 
231
        self.assertEqual('', err)
 
232
 
 
233
        # Checkout standalone (same as above, but does not have parent set)
 
234
        branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
 
235
            format=knit1_format)
 
236
        branch4.bind(branch1)
 
237
        branch4.bzrdir.open_workingtree().update()
 
238
        out, err = self.run_bzr('info checkout --verbose')
 
239
        self.assertEqualDiff(
 
240
"""Checkout (format: knit)
 
241
Location:
 
242
       checkout root: checkout
 
243
  checkout of branch: standalone
 
244
 
 
245
Format:
 
246
       control: Meta directory format 1
 
247
  working tree: Working tree format 3
 
248
        branch: Branch format 5
 
249
    repository: %s
 
250
 
 
251
In the working tree:
 
252
         1 unchanged
 
253
         0 modified
 
254
         0 added
 
255
         0 removed
 
256
         0 renamed
 
257
         0 unknown
 
258
         0 ignored
 
259
         0 versioned subdirectories
 
260
 
 
261
Branch history:
 
262
         1 revision
 
263
         0 days old
 
264
   first revision: %s
 
265
  latest revision: %s
 
266
 
 
267
Repository:
 
268
         1 revision
 
269
""" % (branch4.repository._format.get_format_description(),
 
270
       datestring_first, datestring_first,
 
271
       ), out)
 
272
        self.assertEqual('', err)
 
273
 
 
274
        # Lightweight checkout (same as above, different branch and repository)
 
275
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
 
276
        branch5 = tree5.branch
 
277
        out, err = self.run_bzr('info -v lightcheckout')
 
278
        self.assertEqualDiff(
 
279
"""Lightweight checkout (format: %s)
 
280
Location:
 
281
  light checkout root: lightcheckout
 
282
   checkout of branch: standalone
 
283
 
 
284
Format:
 
285
       control: Meta directory format 1
 
286
  working tree: Working tree format 6
 
287
        branch: Branch format 4
 
288
    repository: Weave repository format 6
 
289
 
 
290
In the working tree:
 
291
         1 unchanged
 
292
         0 modified
 
293
         0 added
 
294
         0 removed
 
295
         0 renamed
 
296
         0 unknown
 
297
         0 ignored
 
298
         0 versioned subdirectories
 
299
 
 
300
Branch history:
 
301
         1 revision
 
302
         0 days old
 
303
   first revision: %s
 
304
  latest revision: %s
 
305
 
 
306
Repository:
 
307
         1 revision
 
308
""" % (self._repo_strings, datestring_first, datestring_first,), out)
 
309
        self.assertEqual('', err)
 
310
 
 
311
        # Update initial standalone branch
 
312
        self.build_tree(['standalone/b'])
 
313
        tree1.add('b')
 
314
        tree1.commit('commit two')
 
315
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
 
316
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
 
317
 
 
318
        # Out of date branched standalone branch will not be detected
 
319
        out, err = self.run_bzr('info -v branch')
 
320
        self.assertEqualDiff(
 
321
"""Standalone tree (format: weave)
 
322
Location:
 
323
  branch root: branch
 
324
 
 
325
Related branches:
 
326
    push branch: standalone
 
327
  parent branch: standalone
 
328
 
 
329
Format:
 
330
       control: All-in-one format 6
 
331
  working tree: Working tree format 2
 
332
        branch: Branch format 4
 
333
    repository: Weave repository format 6
 
334
 
 
335
In the working tree:
 
336
         1 unchanged
 
337
         0 modified
 
338
         0 added
 
339
         0 removed
 
340
         0 renamed
 
341
         0 unknown
 
342
         0 ignored
 
343
         0 versioned subdirectories
 
344
 
 
345
Branch history:
 
346
         1 revision
 
347
         0 days old
 
348
   first revision: %s
 
349
  latest revision: %s
 
350
 
 
351
Repository:
 
352
         1 revision
 
353
""" % (datestring_first, datestring_first,
 
354
       ), out)
 
355
        self.assertEqual('', err)
 
356
 
 
357
        # Out of date bound branch
 
358
        out, err = self.run_bzr('info -v bound')
 
359
        self.assertEqualDiff(
 
360
"""Checkout (format: knit)
 
361
Location:
 
362
       checkout root: bound
 
363
  checkout of branch: standalone
 
364
 
 
365
Related branches:
 
366
  parent branch: standalone
 
367
 
 
368
Format:
 
369
       control: Meta directory format 1
 
370
  working tree: Working tree format 3
 
371
        branch: Branch format 5
 
372
    repository: %s
 
373
 
 
374
Branch is out of date: missing 1 revision.
 
375
 
 
376
In the working tree:
 
377
         1 unchanged
 
378
         0 modified
 
379
         0 added
 
380
         0 removed
 
381
         0 renamed
 
382
         1 unknown
 
383
         0 ignored
 
384
         0 versioned subdirectories
 
385
 
 
386
Branch history:
 
387
         1 revision
 
388
         0 days old
 
389
   first revision: %s
 
390
  latest revision: %s
 
391
 
 
392
Repository:
 
393
         1 revision
 
394
""" % (branch3.repository._format.get_format_description(),
 
395
       datestring_first, datestring_first,
 
396
       ), out)
 
397
        self.assertEqual('', err)
 
398
 
 
399
        # Out of date checkout
 
400
        out, err = self.run_bzr('info -v checkout')
 
401
        self.assertEqualDiff(
 
402
"""Checkout (format: knit)
 
403
Location:
 
404
       checkout root: checkout
 
405
  checkout of branch: standalone
 
406
 
 
407
Format:
 
408
       control: Meta directory format 1
 
409
  working tree: Working tree format 3
 
410
        branch: Branch format 5
 
411
    repository: %s
 
412
 
 
413
Branch is out of date: missing 1 revision.
 
414
 
 
415
In the working tree:
 
416
         1 unchanged
 
417
         0 modified
 
418
         0 added
 
419
         0 removed
 
420
         0 renamed
 
421
         0 unknown
 
422
         0 ignored
 
423
         0 versioned subdirectories
 
424
 
 
425
Branch history:
 
426
         1 revision
 
427
         0 days old
 
428
   first revision: %s
 
429
  latest revision: %s
 
430
 
 
431
Repository:
 
432
         1 revision
 
433
""" % (branch4.repository._format.get_format_description(),
 
434
       datestring_first, datestring_first,
 
435
       ), out)
 
436
        self.assertEqual('', err)
 
437
 
 
438
        # Out of date lightweight checkout
 
439
        out, err = self.run_bzr('info lightcheckout --verbose')
 
440
        self.assertEqualDiff(
 
441
"""Lightweight checkout (format: %s)
 
442
Location:
 
443
  light checkout root: lightcheckout
 
444
   checkout of branch: standalone
 
445
 
 
446
Format:
 
447
       control: Meta directory format 1
 
448
  working tree: Working tree format 6
 
449
        branch: Branch format 4
 
450
    repository: Weave repository format 6
 
451
 
 
452
Working tree is out of date: missing 1 revision.
 
453
 
 
454
In the working tree:
 
455
         1 unchanged
 
456
         0 modified
 
457
         0 added
 
458
         0 removed
 
459
         0 renamed
 
460
         0 unknown
 
461
         0 ignored
 
462
         0 versioned subdirectories
 
463
 
 
464
Branch history:
 
465
         2 revisions
 
466
         0 days old
 
467
   first revision: %s
 
468
  latest revision: %s
 
469
 
 
470
Repository:
 
471
         2 revisions
 
472
""" % (self._repo_strings, datestring_first, datestring_last,), out)
 
473
        self.assertEqual('', err)
 
474
 
 
475
    def test_info_standalone_no_tree(self):
 
476
        # create standalone branch without a working tree
 
477
        format = bzrdir.format_registry.make_bzrdir('default')
 
478
        branch = self.make_branch('branch')
 
479
        repo = branch.repository
 
480
        out, err = self.run_bzr('info branch -v')
 
481
        self.assertEqualDiff(
 
482
"""Standalone branch (format: %s)
 
483
Location:
 
484
  branch root: branch
 
485
 
 
486
Format:
 
487
       control: Meta directory format 1
 
488
        branch: %s
 
489
    repository: %s
 
490
 
 
491
Branch history:
 
492
         0 revisions
 
493
 
 
494
Repository:
 
495
         0 revisions
 
496
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
 
497
       format.get_branch_format().get_format_description(),
 
498
       format.repository_format.get_format_description(),
 
499
       ), out)
 
500
        self.assertEqual('', err)
 
501
 
 
502
    def test_info_shared_repository(self):
 
503
        format = bzrdir.format_registry.make_bzrdir('knit')
 
504
        transport = self.get_transport()
 
505
 
 
506
        # Create shared repository
 
507
        repo = self.make_repository('repo', shared=True, format=format)
 
508
        repo.set_make_working_trees(False)
 
509
        out, err = self.run_bzr('info -v repo')
 
510
        self.assertEqualDiff(
 
511
"""Shared repository (format: dirstate or dirstate-tags or knit)
 
512
Location:
 
513
  shared repository: %s
 
514
 
 
515
Format:
 
516
       control: Meta directory format 1
 
517
    repository: %s
 
518
 
 
519
Repository:
 
520
         0 revisions
 
521
""" % ('repo', format.repository_format.get_format_description(),
 
522
       ), out)
 
523
        self.assertEqual('', err)
 
524
 
 
525
        # Create branch inside shared repository
 
526
        repo.bzrdir.root_transport.mkdir('branch')
 
527
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
 
528
            format=format)
 
529
        out, err = self.run_bzr('info -v repo/branch')
 
530
        self.assertEqualDiff(
 
531
"""Repository branch (format: dirstate or knit)
 
532
Location:
 
533
  shared repository: repo
 
534
  repository branch: repo/branch
 
535
 
 
536
Format:
 
537
       control: Meta directory format 1
 
538
        branch: %s
 
539
    repository: %s
 
540
 
 
541
Branch history:
 
542
         0 revisions
 
543
 
 
544
Repository:
 
545
         0 revisions
 
546
""" % (format.get_branch_format().get_format_description(),
 
547
       format.repository_format.get_format_description(),
 
548
       ), out)
 
549
        self.assertEqual('', err)
 
550
 
 
551
        # Create lightweight checkout
 
552
        transport.mkdir('tree')
 
553
        transport.mkdir('tree/lightcheckout')
 
554
        tree2 = branch1.create_checkout('tree/lightcheckout',
 
555
            lightweight=True)
 
556
        branch2 = tree2.branch
 
557
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
 
558
                   shared_repo=repo, repo_branch=branch1, verbose=True)
 
559
 
 
560
        # Create normal checkout
 
561
        tree3 = branch1.create_checkout('tree/checkout')
 
562
        self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
 
563
            verbose=True,
 
564
            light_checkout=False, repo_branch=branch1)
 
565
        # Update lightweight checkout
 
566
        self.build_tree(['tree/lightcheckout/a'])
 
567
        tree2.add('a')
 
568
        tree2.commit('commit one')
 
569
        rev = repo.get_revision(branch2.revision_history()[0])
 
570
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
571
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
 
572
        self.assertEqualDiff(
 
573
"""Lightweight checkout (format: %s)
 
574
Location:
 
575
  light checkout root: tree/lightcheckout
 
576
   checkout of branch: repo/branch
 
577
    shared repository: repo
 
578
 
 
579
Format:
 
580
       control: Meta directory format 1
 
581
  working tree: Working tree format 6
 
582
        branch: %s
 
583
    repository: %s
 
584
 
 
585
In the working tree:
 
586
         1 unchanged
 
587
         0 modified
 
588
         0 added
 
589
         0 removed
 
590
         0 renamed
 
591
         0 unknown
 
592
         0 ignored
 
593
         0 versioned subdirectories
 
594
 
 
595
Branch history:
 
596
         1 revision
 
597
         0 days old
 
598
   first revision: %s
 
599
  latest revision: %s
 
600
 
 
601
Repository:
 
602
         1 revision
 
603
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
 
604
       format.repository_format.get_format_description(),
 
605
       datestring_first, datestring_first,
 
606
       ), out)
 
607
        self.assertEqual('', err)
 
608
 
 
609
        # Out of date checkout
 
610
        out, err = self.run_bzr('info -v tree/checkout')
 
611
        self.assertEqualDiff(
 
612
"""Checkout (format: unnamed)
 
613
Location:
 
614
       checkout root: tree/checkout
 
615
  checkout of branch: repo/branch
 
616
 
 
617
Format:
 
618
       control: Meta directory format 1
 
619
  working tree: Working tree format 6
 
620
        branch: %s
 
621
    repository: %s
 
622
 
 
623
Branch is out of date: missing 1 revision.
 
624
 
 
625
In the working tree:
 
626
         0 unchanged
 
627
         0 modified
 
628
         0 added
 
629
         0 removed
 
630
         0 renamed
 
631
         0 unknown
 
632
         0 ignored
 
633
         0 versioned subdirectories
 
634
 
 
635
Branch history:
 
636
         0 revisions
 
637
 
 
638
Repository:
 
639
         0 revisions
 
640
""" % (format.get_branch_format().get_format_description(),
 
641
       format.repository_format.get_format_description(),
 
642
       ), out)
 
643
        self.assertEqual('', err)
 
644
 
 
645
        # Update checkout
 
646
        tree3.update()
 
647
        self.build_tree(['tree/checkout/b'])
 
648
        tree3.add('b')
 
649
        out, err = self.run_bzr('info tree/checkout --verbose')
 
650
        self.assertEqualDiff(
 
651
"""Checkout (format: unnamed)
 
652
Location:
 
653
       checkout root: tree/checkout
 
654
  checkout of branch: repo/branch
 
655
 
 
656
Format:
 
657
       control: Meta directory format 1
 
658
  working tree: Working tree format 6
 
659
        branch: %s
 
660
    repository: %s
 
661
 
 
662
In the working tree:
 
663
         1 unchanged
 
664
         0 modified
 
665
         1 added
 
666
         0 removed
 
667
         0 renamed
 
668
         0 unknown
 
669
         0 ignored
 
670
         0 versioned subdirectories
 
671
 
 
672
Branch history:
 
673
         1 revision
 
674
         0 days old
 
675
   first revision: %s
 
676
  latest revision: %s
 
677
 
 
678
Repository:
 
679
         1 revision
 
680
""" % (format.get_branch_format().get_format_description(),
 
681
       format.repository_format.get_format_description(),
 
682
       datestring_first, datestring_first,
 
683
       ), out)
 
684
        self.assertEqual('', err)
 
685
        tree3.commit('commit two')
 
686
 
 
687
        # Out of date lightweight checkout
 
688
        rev = repo.get_revision(branch1.revision_history()[-1])
 
689
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
 
690
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
 
691
        self.assertEqualDiff(
 
692
"""Lightweight checkout (format: %s)
 
693
Location:
 
694
  light checkout root: tree/lightcheckout
 
695
   checkout of branch: repo/branch
 
696
    shared repository: repo
 
697
 
 
698
Format:
 
699
       control: Meta directory format 1
 
700
  working tree: Working tree format 6
 
701
        branch: %s
 
702
    repository: %s
 
703
 
 
704
Working tree is out of date: missing 1 revision.
 
705
 
 
706
In the working tree:
 
707
         1 unchanged
 
708
         0 modified
 
709
         0 added
 
710
         0 removed
 
711
         0 renamed
 
712
         0 unknown
 
713
         0 ignored
 
714
         0 versioned subdirectories
 
715
 
 
716
Branch history:
 
717
         2 revisions
 
718
         0 days old
 
719
   first revision: %s
 
720
  latest revision: %s
 
721
 
 
722
Repository:
 
723
         2 revisions
 
724
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
 
725
       format.repository_format.get_format_description(),
 
726
       datestring_first, datestring_last,
 
727
       ), out)
 
728
        self.assertEqual('', err)
 
729
 
 
730
        # Show info about shared branch
 
731
        out, err = self.run_bzr('info repo/branch --verbose')
 
732
        self.assertEqualDiff(
 
733
"""Repository branch (format: dirstate or knit)
 
734
Location:
 
735
  shared repository: repo
 
736
  repository branch: repo/branch
 
737
 
 
738
Format:
 
739
       control: Meta directory format 1
 
740
        branch: %s
 
741
    repository: %s
 
742
 
 
743
Branch history:
 
744
         2 revisions
 
745
         0 days old
 
746
   first revision: %s
 
747
  latest revision: %s
 
748
 
 
749
Repository:
 
750
         2 revisions
 
751
""" % (format.get_branch_format().get_format_description(),
 
752
       format.repository_format.get_format_description(),
 
753
       datestring_first, datestring_last,
 
754
       ), out)
 
755
        self.assertEqual('', err)
 
756
 
 
757
        # Show info about repository with revisions
 
758
        out, err = self.run_bzr('info -v repo')
 
759
        self.assertEqualDiff(
 
760
"""Shared repository (format: dirstate or dirstate-tags or knit)
 
761
Location:
 
762
  shared repository: repo
 
763
 
 
764
Format:
 
765
       control: Meta directory format 1
 
766
    repository: %s
 
767
 
 
768
Repository:
 
769
         2 revisions
 
770
""" % (format.repository_format.get_format_description(),
 
771
       ), out)
 
772
        self.assertEqual('', err)
 
773
 
 
774
    def test_info_shared_repository_with_trees(self):
 
775
        format = bzrdir.format_registry.make_bzrdir('knit')
 
776
        transport = self.get_transport()
 
777
 
 
778
        # Create shared repository with working trees
 
779
        repo = self.make_repository('repo', shared=True, format=format)
 
780
        repo.set_make_working_trees(True)
 
781
        out, err = self.run_bzr('info -v repo')
 
782
        self.assertEqualDiff(
 
783
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
784
Location:
 
785
  shared repository: repo
 
786
 
 
787
Format:
 
788
       control: Meta directory format 1
 
789
    repository: %s
 
790
 
 
791
Create working tree for new branches inside the repository.
 
792
 
 
793
Repository:
 
794
         0 revisions
 
795
""" % (format.repository_format.get_format_description(),
 
796
       ), out)
 
797
        self.assertEqual('', err)
 
798
 
 
799
        # Create two branches
 
800
        repo.bzrdir.root_transport.mkdir('branch1')
 
801
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
 
802
            format=format)
 
803
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
 
804
 
 
805
        # Empty first branch
 
806
        out, err = self.run_bzr('info repo/branch1 --verbose')
 
807
        self.assertEqualDiff(
 
808
"""Repository tree (format: knit)
 
809
Location:
 
810
  shared repository: repo
 
811
  repository branch: repo/branch1
 
812
 
 
813
Format:
 
814
       control: Meta directory format 1
 
815
  working tree: Working tree format 3
 
816
        branch: %s
 
817
    repository: %s
 
818
 
 
819
In the working tree:
 
820
         0 unchanged
 
821
         0 modified
 
822
         0 added
 
823
         0 removed
 
824
         0 renamed
 
825
         0 unknown
 
826
         0 ignored
 
827
         0 versioned subdirectories
 
828
 
 
829
Branch history:
 
830
         0 revisions
 
831
 
 
832
Repository:
 
833
         0 revisions
 
834
""" % (format.get_branch_format().get_format_description(),
 
835
       format.repository_format.get_format_description(),
 
836
       ), out)
 
837
        self.assertEqual('', err)
 
838
 
 
839
        # Update first branch
 
840
        self.build_tree(['repo/branch1/a'])
 
841
        tree1 = branch1.bzrdir.open_workingtree()
 
842
        tree1.add('a')
 
843
        tree1.commit('commit one')
 
844
        rev = repo.get_revision(branch1.revision_history()[0])
 
845
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
846
        out, err = self.run_bzr('info -v repo/branch1')
 
847
        self.assertEqualDiff(
 
848
"""Repository tree (format: knit)
 
849
Location:
 
850
  shared repository: repo
 
851
  repository branch: repo/branch1
 
852
 
 
853
Format:
 
854
       control: Meta directory format 1
 
855
  working tree: Working tree format 3
 
856
        branch: %s
 
857
    repository: %s
 
858
 
 
859
In the working tree:
 
860
         1 unchanged
 
861
         0 modified
 
862
         0 added
 
863
         0 removed
 
864
         0 renamed
 
865
         0 unknown
 
866
         0 ignored
 
867
         0 versioned subdirectories
 
868
 
 
869
Branch history:
 
870
         1 revision
 
871
         0 days old
 
872
   first revision: %s
 
873
  latest revision: %s
 
874
 
 
875
Repository:
 
876
         1 revision
 
877
""" % (format.get_branch_format().get_format_description(),
 
878
       format.repository_format.get_format_description(),
 
879
       datestring_first, datestring_first,
 
880
       ), out)
 
881
        self.assertEqual('', err)
 
882
 
 
883
        # Out of date second branch
 
884
        out, err = self.run_bzr('info repo/branch2 --verbose')
 
885
        self.assertEqualDiff(
 
886
"""Repository tree (format: knit)
 
887
Location:
 
888
  shared repository: repo
 
889
  repository branch: repo/branch2
 
890
 
 
891
Related branches:
 
892
  parent branch: repo/branch1
 
893
 
 
894
Format:
 
895
       control: Meta directory format 1
 
896
  working tree: Working tree format 3
 
897
        branch: %s
 
898
    repository: %s
 
899
 
 
900
In the working tree:
 
901
         0 unchanged
 
902
         0 modified
 
903
         0 added
 
904
         0 removed
 
905
         0 renamed
 
906
         0 unknown
 
907
         0 ignored
 
908
         0 versioned subdirectories
 
909
 
 
910
Branch history:
 
911
         0 revisions
 
912
 
 
913
Repository:
 
914
         1 revision
 
915
""" % (format.get_branch_format().get_format_description(),
 
916
       format.repository_format.get_format_description(),
 
917
       ), out)
 
918
        self.assertEqual('', err)
 
919
 
 
920
        # Update second branch
 
921
        tree2 = branch2.bzrdir.open_workingtree()
 
922
        tree2.pull(branch1)
 
923
        out, err = self.run_bzr('info -v repo/branch2')
 
924
        self.assertEqualDiff(
 
925
"""Repository tree (format: knit)
 
926
Location:
 
927
  shared repository: repo
 
928
  repository branch: repo/branch2
 
929
 
 
930
Related branches:
 
931
  parent branch: repo/branch1
 
932
 
 
933
Format:
 
934
       control: Meta directory format 1
 
935
  working tree: Working tree format 3
 
936
        branch: %s
 
937
    repository: %s
 
938
 
 
939
In the working tree:
 
940
         1 unchanged
 
941
         0 modified
 
942
         0 added
 
943
         0 removed
 
944
         0 renamed
 
945
         0 unknown
 
946
         0 ignored
 
947
         0 versioned subdirectories
 
948
 
 
949
Branch history:
 
950
         1 revision
 
951
         0 days old
 
952
   first revision: %s
 
953
  latest revision: %s
 
954
 
 
955
Repository:
 
956
         1 revision
 
957
""" % (format.get_branch_format().get_format_description(),
 
958
       format.repository_format.get_format_description(),
 
959
       datestring_first, datestring_first,
 
960
       ), out)
 
961
        self.assertEqual('', err)
 
962
 
 
963
        # Show info about repository with revisions
 
964
        out, err = self.run_bzr('info -v repo')
 
965
        self.assertEqualDiff(
 
966
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
967
Location:
 
968
  shared repository: repo
 
969
 
 
970
Format:
 
971
       control: Meta directory format 1
 
972
    repository: %s
 
973
 
 
974
Create working tree for new branches inside the repository.
 
975
 
 
976
Repository:
 
977
         1 revision
 
978
""" % (format.repository_format.get_format_description(),
 
979
       ),
 
980
       out)
 
981
        self.assertEqual('', err)
 
982
 
 
983
    def test_info_shared_repository_with_tree_in_root(self):
 
984
        format = bzrdir.format_registry.make_bzrdir('knit')
 
985
        transport = self.get_transport()
 
986
 
 
987
        # Create shared repository with working trees
 
988
        repo = self.make_repository('repo', shared=True, format=format)
 
989
        repo.set_make_working_trees(True)
 
990
        out, err = self.run_bzr('info -v repo')
 
991
        self.assertEqualDiff(
 
992
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
993
Location:
 
994
  shared repository: repo
 
995
 
 
996
Format:
 
997
       control: Meta directory format 1
 
998
    repository: %s
 
999
 
 
1000
Create working tree for new branches inside the repository.
 
1001
 
 
1002
Repository:
 
1003
         0 revisions
 
1004
""" % (format.repository_format.get_format_description(),
 
1005
       ), out)
 
1006
        self.assertEqual('', err)
 
1007
 
 
1008
        # Create branch in root of repository
 
1009
        control = repo.bzrdir
 
1010
        branch = control.create_branch()
 
1011
        control.create_workingtree()
 
1012
        out, err = self.run_bzr('info -v repo')
 
1013
        self.assertEqualDiff(
 
1014
"""Repository tree (format: knit)
 
1015
Location:
 
1016
  shared repository: repo
 
1017
  repository branch: repo
 
1018
 
 
1019
Format:
 
1020
       control: Meta directory format 1
 
1021
  working tree: Working tree format 3
 
1022
        branch: %s
 
1023
    repository: %s
 
1024
 
 
1025
In the working tree:
 
1026
         0 unchanged
 
1027
         0 modified
 
1028
         0 added
 
1029
         0 removed
 
1030
         0 renamed
 
1031
         0 unknown
 
1032
         0 ignored
 
1033
         0 versioned subdirectories
 
1034
 
 
1035
Branch history:
 
1036
         0 revisions
 
1037
 
 
1038
Repository:
 
1039
         0 revisions
 
1040
""" % (format.get_branch_format().get_format_description(),
 
1041
       format.repository_format.get_format_description(),
 
1042
       ), out)
 
1043
        self.assertEqual('', err)
 
1044
 
 
1045
    def test_info_repository_hook(self):
 
1046
        format = bzrdir.format_registry.make_bzrdir('knit')
 
1047
        def repo_info(repo, stats, outf):
 
1048
            outf.write("more info\n")
 
1049
        info.hooks.install_named_hook('repository', repo_info, None)
 
1050
        # Create shared repository with working trees
 
1051
        repo = self.make_repository('repo', shared=True, format=format)
 
1052
        out, err = self.run_bzr('info -v repo')
 
1053
        self.assertEqualDiff(
 
1054
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
1055
Location:
 
1056
  shared repository: repo
 
1057
 
 
1058
Format:
 
1059
       control: Meta directory format 1
 
1060
    repository: %s
 
1061
 
 
1062
Create working tree for new branches inside the repository.
 
1063
 
 
1064
Repository:
 
1065
         0 revisions
 
1066
more info
 
1067
""" % (format.repository_format.get_format_description(),
 
1068
       ), out)
 
1069
        self.assertEqual('', err)
 
1070
 
 
1071
    def assertCheckoutStatusOutput(self,
 
1072
        command_string, lco_tree, shared_repo=None,
 
1073
        repo_branch=None,
 
1074
        tree_locked=False,
 
1075
        branch_locked=False, repo_locked=False,
 
1076
        verbose=False,
 
1077
        light_checkout=True,
 
1078
        checkout_root=None):
 
1079
        """Check the output of info in a checkout.
 
1080
 
 
1081
        This is not quite a mirror of the info code: rather than using the
 
1082
        tree being examined to predict output, it uses a bunch of flags which
 
1083
        allow us, the test writers, to document what *should* be present in
 
1084
        the output. Removing this separation would remove the value of the
 
1085
        tests.
 
1086
 
 
1087
        :param path: the path to the light checkout.
 
1088
        :param lco_tree: the tree object for the light checkout.
 
1089
        :param shared_repo: A shared repository is in use, expect that in
 
1090
            the output.
 
1091
        :param repo_branch: A branch in a shared repository for non light
 
1092
            checkouts.
 
1093
        :param tree_locked: If true, expect the tree to be locked.
 
1094
        :param branch_locked: If true, expect the branch to be locked.
 
1095
        :param repo_locked: If true, expect the repository to be locked.
 
1096
            Note that the lco_tree.branch.repository is inspected, and if is not
 
1097
            actually locked then this parameter is overridden. This is because
 
1098
            pack repositories do not have any public API for obtaining an
 
1099
            exclusive repository wide lock.
 
1100
        :param verbose: verbosity level: 2 or higher to show committers
 
1101
        """
 
1102
        def friendly_location(url):
 
1103
            path = urlutils.unescape_for_display(url, 'ascii')
 
1104
            try:
 
1105
                return osutils.relpath(osutils.getcwd(), path)
 
1106
            except errors.PathNotChild:
 
1107
                return path
 
1108
 
 
1109
        if tree_locked:
 
1110
            # We expect this to fail because of locking errors.
 
1111
            # (A write-locked file cannot be read-locked
 
1112
            # in the different process -- either on win32 or on linux).
 
1113
            # This should be removed when the locking errors are fixed.
 
1114
            self.expectFailure('OS locks are exclusive '
 
1115
                'for different processes (Bug #174055)',
 
1116
                self.run_bzr_subprocess,
 
1117
                'info ' + command_string)
 
1118
        out, err = self.run_bzr('info %s' % command_string)
 
1119
        description = {
 
1120
            (True, True): 'Lightweight checkout',
 
1121
            (True, False): 'Repository checkout',
 
1122
            (False, True): 'Lightweight checkout',
 
1123
            (False, False): 'Checkout',
 
1124
            }[(shared_repo is not None, light_checkout)]
 
1125
        format = {True: self._repo_strings,
 
1126
                  False: 'unnamed'}[light_checkout]
 
1127
        if repo_locked:
 
1128
            repo_locked = lco_tree.branch.repository.get_physical_lock_status()
 
1129
        if repo_locked or branch_locked or tree_locked:
 
1130
            def locked_message(a_bool):
 
1131
                if a_bool:
 
1132
                    return 'locked'
 
1133
                else:
 
1134
                    return 'unlocked'
 
1135
            expected_lock_output = (
 
1136
                "\n"
 
1137
                "Lock status:\n"
 
1138
                "  working tree: %s\n"
 
1139
                "        branch: %s\n"
 
1140
                "    repository: %s\n" % (
 
1141
                    locked_message(tree_locked),
 
1142
                    locked_message(branch_locked),
 
1143
                    locked_message(repo_locked)))
 
1144
        else:
 
1145
            expected_lock_output = ''
 
1146
        tree_data = ''
 
1147
        extra_space = ''
 
1148
        if light_checkout:
 
1149
            tree_data = ("  light checkout root: %s\n" %
 
1150
                friendly_location(lco_tree.bzrdir.root_transport.base))
 
1151
            extra_space = ' '
 
1152
        if lco_tree.branch.get_bound_location() is not None:
 
1153
            tree_data += ("%s       checkout root: %s\n" % (extra_space,
 
1154
                friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
 
1155
        if shared_repo is not None:
 
1156
            branch_data = (
 
1157
                "   checkout of branch: %s\n"
 
1158
                "    shared repository: %s\n" %
 
1159
                (friendly_location(repo_branch.bzrdir.root_transport.base),
 
1160
                 friendly_location(shared_repo.bzrdir.root_transport.base)))
 
1161
        elif repo_branch is not None:
 
1162
            branch_data = (
 
1163
                "%s  checkout of branch: %s\n" %
 
1164
                (extra_space,
 
1165
                 friendly_location(repo_branch.bzrdir.root_transport.base)))
 
1166
        else:
 
1167
            branch_data = ("   checkout of branch: %s\n" %
 
1168
                lco_tree.branch.bzrdir.root_transport.base)
 
1169
 
 
1170
        if verbose >= 2:
 
1171
            verbose_info = '         0 committers\n'
 
1172
        else:
 
1173
            verbose_info = ''
 
1174
 
 
1175
        self.assertEqualDiff(
 
1176
"""%s (format: %s)
 
1177
Location:
 
1178
%s%s
 
1179
Format:
 
1180
       control: Meta directory format 1
 
1181
  working tree: %s
 
1182
        branch: %s
 
1183
    repository: %s
 
1184
%s
 
1185
In the working tree:
 
1186
         0 unchanged
 
1187
         0 modified
 
1188
         0 added
 
1189
         0 removed
 
1190
         0 renamed
 
1191
         0 unknown
 
1192
         0 ignored
 
1193
         0 versioned subdirectories
 
1194
 
 
1195
Branch history:
 
1196
         0 revisions
 
1197
%s
 
1198
Repository:
 
1199
         0 revisions
 
1200
""" %  (description,
 
1201
        format,
 
1202
        tree_data,
 
1203
        branch_data,
 
1204
        lco_tree._format.get_format_description(),
 
1205
        lco_tree.branch._format.get_format_description(),
 
1206
        lco_tree.branch.repository._format.get_format_description(),
 
1207
        expected_lock_output,
 
1208
        verbose_info,
 
1209
        ), out)
 
1210
        self.assertEqual('', err)
 
1211
 
 
1212
    def test_info_locking(self):
 
1213
        transport = self.get_transport()
 
1214
        # Create shared repository with a branch
 
1215
        repo = self.make_repository('repo', shared=True,
 
1216
                                    format=bzrdir.BzrDirMetaFormat1())
 
1217
        repo.set_make_working_trees(False)
 
1218
        repo.bzrdir.root_transport.mkdir('branch')
 
1219
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
 
1220
                                    format=bzrdir.BzrDirMetaFormat1())
 
1221
        # Do a heavy checkout
 
1222
        transport.mkdir('tree')
 
1223
        transport.mkdir('tree/checkout')
 
1224
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
 
1225
            format=bzrdir.BzrDirMetaFormat1())
 
1226
        co_branch.bind(repo_branch)
 
1227
        # Do a light checkout of the heavy one
 
1228
        transport.mkdir('tree/lightcheckout')
 
1229
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
 
1230
        branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
 
1231
        lco_dir.create_workingtree()
 
1232
        lco_tree = lco_dir.open_workingtree()
 
1233
 
 
1234
        # Test all permutations of locking the working tree, branch and repository
 
1235
        # W B R
 
1236
 
 
1237
        # U U U
 
1238
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
 
1239
                                        repo_branch=repo_branch,
 
1240
                                        verbose=True, light_checkout=True)
 
1241
        # U U L
 
1242
        lco_tree.branch.repository.lock_write()
 
1243
        try:
 
1244
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1245
            lco_tree, repo_branch=repo_branch,
 
1246
            repo_locked=True, verbose=True, light_checkout=True)
 
1247
        finally:
 
1248
            lco_tree.branch.repository.unlock()
 
1249
        # U L L
 
1250
        lco_tree.branch.lock_write()
 
1251
        try:
 
1252
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1253
            lco_tree,
 
1254
            branch_locked=True,
 
1255
            repo_locked=True,
 
1256
            repo_branch=repo_branch,
 
1257
            verbose=True)
 
1258
        finally:
 
1259
            lco_tree.branch.unlock()
 
1260
        # L L L
 
1261
        lco_tree.lock_write()
 
1262
        try:
 
1263
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1264
            lco_tree, repo_branch=repo_branch,
 
1265
            tree_locked=True,
 
1266
            branch_locked=True,
 
1267
            repo_locked=True,
 
1268
            verbose=True)
 
1269
        finally:
 
1270
            lco_tree.unlock()
 
1271
        # L L U
 
1272
        lco_tree.lock_write()
 
1273
        lco_tree.branch.repository.unlock()
 
1274
        try:
 
1275
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1276
            lco_tree, repo_branch=repo_branch,
 
1277
            tree_locked=True,
 
1278
            branch_locked=True,
 
1279
            verbose=True)
 
1280
        finally:
 
1281
            lco_tree.branch.repository.lock_write()
 
1282
            lco_tree.unlock()
 
1283
        # L U U
 
1284
        lco_tree.lock_write()
 
1285
        lco_tree.branch.unlock()
 
1286
        try:
 
1287
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1288
            lco_tree, repo_branch=repo_branch,
 
1289
            tree_locked=True,
 
1290
            verbose=True)
 
1291
        finally:
 
1292
            lco_tree.branch.lock_write()
 
1293
            lco_tree.unlock()
 
1294
        # L U L
 
1295
        lco_tree.lock_write()
 
1296
        lco_tree.branch.unlock()
 
1297
        lco_tree.branch.repository.lock_write()
 
1298
        try:
 
1299
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1300
            lco_tree, repo_branch=repo_branch,
 
1301
            tree_locked=True,
 
1302
            repo_locked=True,
 
1303
            verbose=True)
 
1304
        finally:
 
1305
            lco_tree.branch.repository.unlock()
 
1306
            lco_tree.branch.lock_write()
 
1307
            lco_tree.unlock()
 
1308
        # U L U
 
1309
        lco_tree.branch.lock_write()
 
1310
        lco_tree.branch.repository.unlock()
 
1311
        try:
 
1312
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1313
            lco_tree, repo_branch=repo_branch,
 
1314
            branch_locked=True,
 
1315
            verbose=True)
 
1316
        finally:
 
1317
            lco_tree.branch.repository.lock_write()
 
1318
            lco_tree.branch.unlock()
 
1319
 
 
1320
        if sys.platform == 'win32':
 
1321
            self.knownFailure('Win32 cannot run "bzr info"'
 
1322
                              ' when the tree is locked.')
 
1323
 
 
1324
    def test_info_locking_oslocks(self):
 
1325
        if sys.platform == "win32":
 
1326
            raise TestSkipped("don't use oslocks on win32 in unix manner")
 
1327
        # This test tests old (all-in-one, OS lock using) behaviour which
 
1328
        # simply cannot work on windows (and is indeed why we changed our
 
1329
        # design. As such, don't try to remove the thisFailsStrictLockCheck
 
1330
        # call here.
 
1331
        self.thisFailsStrictLockCheck()
 
1332
 
 
1333
        tree = self.make_branch_and_tree('branch',
 
1334
                                         format=bzrdir.BzrDirFormat6())
 
1335
 
 
1336
        # Test all permutations of locking the working tree, branch and repository
 
1337
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
 
1338
        # implemented by raising NotImplementedError and get_physical_lock_status()
 
1339
        # always returns false. This makes bzr info hide the lock status.  (Olaf)
 
1340
        # W B R
 
1341
 
 
1342
        # U U U
 
1343
        out, err = self.run_bzr('info -v branch')
 
1344
        self.assertEqualDiff(
 
1345
"""Standalone tree (format: weave)
 
1346
Location:
 
1347
  branch root: %s
 
1348
 
 
1349
Format:
 
1350
       control: All-in-one format 6
 
1351
  working tree: Working tree format 2
 
1352
        branch: Branch format 4
 
1353
    repository: %s
 
1354
 
 
1355
In the working tree:
 
1356
         0 unchanged
 
1357
         0 modified
 
1358
         0 added
 
1359
         0 removed
 
1360
         0 renamed
 
1361
         0 unknown
 
1362
         0 ignored
 
1363
         0 versioned subdirectories
 
1364
 
 
1365
Branch history:
 
1366
         0 revisions
 
1367
 
 
1368
Repository:
 
1369
         0 revisions
 
1370
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1371
       ), out)
 
1372
        self.assertEqual('', err)
 
1373
        # L L L
 
1374
        tree.lock_write()
 
1375
        out, err = self.run_bzr('info -v branch')
 
1376
        self.assertEqualDiff(
 
1377
"""Standalone tree (format: weave)
 
1378
Location:
 
1379
  branch root: %s
 
1380
 
 
1381
Format:
 
1382
       control: All-in-one format 6
 
1383
  working tree: Working tree format 2
 
1384
        branch: Branch format 4
 
1385
    repository: %s
 
1386
 
 
1387
In the working tree:
 
1388
         0 unchanged
 
1389
         0 modified
 
1390
         0 added
 
1391
         0 removed
 
1392
         0 renamed
 
1393
         0 unknown
 
1394
         0 ignored
 
1395
         0 versioned subdirectories
 
1396
 
 
1397
Branch history:
 
1398
         0 revisions
 
1399
 
 
1400
Repository:
 
1401
         0 revisions
 
1402
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1403
       ), out)
 
1404
        self.assertEqual('', err)
 
1405
        tree.unlock()
 
1406
 
 
1407
    def test_info_stacked(self):
 
1408
        # We have a mainline
 
1409
        trunk_tree = self.make_branch_and_tree('mainline',
 
1410
            format='1.6')
 
1411
        trunk_tree.commit('mainline')
 
1412
        # and a branch from it which is stacked
 
1413
        new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
 
1414
        out, err = self.run_bzr('info newbranch')
 
1415
        self.assertEqual(
 
1416
"""Standalone tree (format: 1.6)
 
1417
Location:
 
1418
  branch root: newbranch
 
1419
 
 
1420
Related branches:
 
1421
  parent branch: mainline
 
1422
     stacked on: mainline
 
1423
""", out)
 
1424
        self.assertEqual("", err)