/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

Merge with set_parent_ids

Show diffs side-by-side

added added

removed removed

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