/brz/remove-bazaar

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

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2007-11-22 02:09:49 UTC
  • mto: This revision was merged to the branch mainline in revision 3014.
  • Revision ID: robertc@robertcollins.net-20071122020949-kpvph7srqw3h60p1
Handle packs in blackbox.test_reconcile.

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