~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: mbp at sourcefrog
  • Date: 2005-04-11 02:53:57 UTC
  • Revision ID: mbp@sourcefrog.net-20050411025357-af577721308648ae
- remove profiler temporary file when done

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