/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: Canonical.com Patch Queue Manager
  • Date: 2007-11-22 20:17:22 UTC
  • mfrom: (3004.1.10 84043)
  • Revision ID: pqm@pqm.ubuntu.com-20071122201722-4l5bgljqn7qdux7f
commit now can invoke an external editor in a non-ascii directory.  (Watkins)

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 \
 
267
knitpack-experimental or rich-root)
 
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 \
 
446
knitpack-experimental or rich-root)
 
447
Location:
 
448
  light checkout root: lightcheckout
 
449
   checkout of branch: standalone
 
450
 
 
451
Format:
 
452
       control: Meta directory format 1
 
453
  working tree: Working tree format 4
 
454
        branch: Branch format 4
 
455
    repository: Weave repository format 6
 
456
 
 
457
Working tree is out of date: missing 1 revision.
 
458
 
 
459
In the working tree:
 
460
         1 unchanged
 
461
         0 modified
 
462
         0 added
 
463
         0 removed
 
464
         0 renamed
 
465
         0 unknown
 
466
         0 ignored
 
467
         0 versioned subdirectories
 
468
 
 
469
Branch history:
 
470
         2 revisions
 
471
         1 committer
 
472
         0 days old
 
473
   first revision: %s
 
474
  latest revision: %s
 
475
 
 
476
Repository:
 
477
         2 revisions
 
478
         0 KiB
 
479
""" % (datestring_first, datestring_last,), out)
 
480
        self.assertEqual('', err)
 
481
 
 
482
    def test_info_standalone_no_tree(self):
 
483
        # create standalone branch without a working tree
 
484
        format = bzrdir.format_registry.make_bzrdir('default')
 
485
        branch = self.make_branch('branch')
 
486
        repo = branch.repository
 
487
        out, err = self.run_bzr('info branch -v')
 
488
        self.assertEqualDiff(
 
489
"""Standalone branch (format: dirstate-tags)
 
490
Location:
 
491
  branch root: branch
 
492
 
 
493
Format:
 
494
       control: Meta directory format 1
 
495
        branch: %s
 
496
    repository: %s
 
497
 
 
498
Branch history:
 
499
         0 revisions
 
500
         0 committers
 
501
 
 
502
Repository:
 
503
         0 revisions
 
504
         0 KiB
 
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 \
 
585
knitpack-experimental or rich-root)
 
586
Location:
 
587
  light checkout root: tree/lightcheckout
 
588
   checkout of branch: repo/branch
 
589
    shared repository: repo
 
590
 
 
591
Format:
 
592
       control: Meta directory format 1
 
593
  working tree: Working tree format 4
 
594
        branch: %s
 
595
    repository: %s
 
596
 
 
597
In the working tree:
 
598
         1 unchanged
 
599
         0 modified
 
600
         0 added
 
601
         0 removed
 
602
         0 renamed
 
603
         0 unknown
 
604
         0 ignored
 
605
         0 versioned subdirectories
 
606
 
 
607
Branch history:
 
608
         1 revision
 
609
         1 committer
 
610
         0 days old
 
611
   first revision: %s
 
612
  latest revision: %s
 
613
 
 
614
Repository:
 
615
         1 revision
 
616
         %d KiB
 
617
""" % (format.get_branch_format().get_format_description(),
 
618
       format.repository_format.get_format_description(),
 
619
       datestring_first, datestring_first,
 
620
       # poking at _revision_store isn't all that clean, but neither is
 
621
       # having the ui test dependent on the exact overhead of a given store.
 
622
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
623
       ), out)
 
624
        self.assertEqual('', err)
 
625
 
 
626
        # Out of date checkout
 
627
        out, err = self.run_bzr('info -v tree/checkout')
 
628
        self.assertEqualDiff(
 
629
"""Checkout (format: dirstate)
 
630
Location:
 
631
       checkout root: tree/checkout
 
632
  checkout of branch: repo/branch
 
633
 
 
634
Format:
 
635
       control: Meta directory format 1
 
636
  working tree: Working tree format 4
 
637
        branch: %s
 
638
    repository: %s
 
639
 
 
640
Branch is out of date: missing 1 revision.
 
641
 
 
642
In the working tree:
 
643
         0 unchanged
 
644
         0 modified
 
645
         0 added
 
646
         0 removed
 
647
         0 renamed
 
648
         0 unknown
 
649
         0 ignored
 
650
         0 versioned subdirectories
 
651
 
 
652
Branch history:
 
653
         0 revisions
 
654
         0 committers
 
655
 
 
656
Repository:
 
657
         0 revisions
 
658
         0 KiB
 
659
""" % (format.get_branch_format().get_format_description(),
 
660
       format.repository_format.get_format_description(),
 
661
       ), out)
 
662
        self.assertEqual('', err)
 
663
 
 
664
        # Update checkout
 
665
        tree3.update()
 
666
        self.build_tree(['tree/checkout/b'])
 
667
        tree3.add('b')
 
668
        out, err = self.run_bzr('info tree/checkout --verbose')
 
669
        self.assertEqualDiff(
 
670
"""Checkout (format: dirstate)
 
671
Location:
 
672
       checkout root: tree/checkout
 
673
  checkout of branch: repo/branch
 
674
 
 
675
Format:
 
676
       control: Meta directory format 1
 
677
  working tree: Working tree format 4
 
678
        branch: %s
 
679
    repository: %s
 
680
 
 
681
In the working tree:
 
682
         1 unchanged
 
683
         0 modified
 
684
         1 added
 
685
         0 removed
 
686
         0 renamed
 
687
         0 unknown
 
688
         0 ignored
 
689
         0 versioned subdirectories
 
690
 
 
691
Branch history:
 
692
         1 revision
 
693
         1 committer
 
694
         0 days old
 
695
   first revision: %s
 
696
  latest revision: %s
 
697
 
 
698
Repository:
 
699
         1 revision
 
700
         %d KiB
 
701
""" % (format.get_branch_format().get_format_description(),
 
702
       format.repository_format.get_format_description(),
 
703
       datestring_first, datestring_first,
 
704
       # poking at _revision_store isn't all that clean, but neither is
 
705
       # having the ui test dependent on the exact overhead of a given store.
 
706
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
707
       ), out)
 
708
        self.assertEqual('', err)
 
709
        tree3.commit('commit two')
 
710
 
 
711
        # Out of date lightweight checkout
 
712
        rev = repo.get_revision(branch1.revision_history()[-1])
 
713
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
714
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
 
715
        self.assertEqualDiff(
 
716
"""Lightweight checkout (format: dirstate or dirstate-tags or \
 
717
knitpack-experimental or rich-root)
 
718
Location:
 
719
  light checkout root: tree/lightcheckout
 
720
   checkout of branch: repo/branch
 
721
    shared repository: repo
 
722
 
 
723
Format:
 
724
       control: Meta directory format 1
 
725
  working tree: Working tree format 4
 
726
        branch: %s
 
727
    repository: %s
 
728
 
 
729
Working tree is out of date: missing 1 revision.
 
730
 
 
731
In the working tree:
 
732
         1 unchanged
 
733
         0 modified
 
734
         0 added
 
735
         0 removed
 
736
         0 renamed
 
737
         0 unknown
 
738
         0 ignored
 
739
         0 versioned subdirectories
 
740
 
 
741
Branch history:
 
742
         2 revisions
 
743
         1 committer
 
744
         0 days old
 
745
   first revision: %s
 
746
  latest revision: %s
 
747
 
 
748
Repository:
 
749
         2 revisions
 
750
         %d KiB
 
751
""" % (format.get_branch_format().get_format_description(),
 
752
       format.repository_format.get_format_description(),
 
753
       datestring_first, datestring_last,
 
754
       # poking at _revision_store isn't all that clean, but neither is
 
755
       # having the ui test dependent on the exact overhead of a given store.
 
756
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
757
       ), out)
 
758
        self.assertEqual('', err)
 
759
 
 
760
        # Show info about shared branch
 
761
        out, err = self.run_bzr('info repo/branch --verbose')
 
762
        self.assertEqualDiff(
 
763
"""Repository branch (format: dirstate or knit)
 
764
Location:
 
765
  shared repository: repo
 
766
  repository branch: repo/branch
 
767
 
 
768
Format:
 
769
       control: Meta directory format 1
 
770
        branch: %s
 
771
    repository: %s
 
772
 
 
773
Branch history:
 
774
         2 revisions
 
775
         1 committer
 
776
         0 days old
 
777
   first revision: %s
 
778
  latest revision: %s
 
779
 
 
780
Repository:
 
781
         2 revisions
 
782
         %d KiB
 
783
""" % (format.get_branch_format().get_format_description(),
 
784
       format.repository_format.get_format_description(),
 
785
       datestring_first, datestring_last,
 
786
       # poking at _revision_store isn't all that clean, but neither is
 
787
       # having the ui test dependent on the exact overhead of a given store.
 
788
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
789
       ), out)
 
790
        self.assertEqual('', err)
 
791
 
 
792
        # Show info about repository with revisions
 
793
        out, err = self.run_bzr('info -v repo')
 
794
        self.assertEqualDiff(
 
795
"""Shared repository (format: dirstate or dirstate-tags or knit)
 
796
Location:
 
797
  shared repository: repo
 
798
 
 
799
Format:
 
800
       control: Meta directory format 1
 
801
    repository: %s
 
802
 
 
803
Repository:
 
804
         2 revisions
 
805
         %d KiB
 
806
""" % (format.repository_format.get_format_description(),
 
807
       # poking at _revision_store isn't all that clean, but neither is
 
808
       # having the ui test dependent on the exact overhead of a given store.
 
809
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
810
       ), out)
 
811
        self.assertEqual('', err)
 
812
 
 
813
    def test_info_shared_repository_with_trees(self):
 
814
        format = bzrdir.format_registry.make_bzrdir('knit')
 
815
        transport = self.get_transport()
 
816
 
 
817
        # Create shared repository with working trees
 
818
        repo = self.make_repository('repo', shared=True, format=format)
 
819
        repo.set_make_working_trees(True)
 
820
        out, err = self.run_bzr('info -v repo')
 
821
        self.assertEqualDiff(
 
822
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
823
Location:
 
824
  shared repository: repo
 
825
 
 
826
Format:
 
827
       control: Meta directory format 1
 
828
    repository: %s
 
829
 
 
830
Create working tree for new branches inside the repository.
 
831
 
 
832
Repository:
 
833
         0 revisions
 
834
         0 KiB
 
835
""" % (format.repository_format.get_format_description(),
 
836
       ), out)
 
837
        self.assertEqual('', err)
 
838
 
 
839
        # Create two branches
 
840
        repo.bzrdir.root_transport.mkdir('branch1')
 
841
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
 
842
            format=format)
 
843
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
 
844
 
 
845
        # Empty first branch
 
846
        out, err = self.run_bzr('info repo/branch1 --verbose')
 
847
        self.assertEqualDiff(
 
848
"""Repository tree (format: knit)
 
849
Location:
 
850
  shared repository: repo
 
851
  repository branch: repo/branch1
 
852
 
 
853
Format:
 
854
       control: Meta directory format 1
 
855
  working tree: Working tree format 3
 
856
        branch: %s
 
857
    repository: %s
 
858
 
 
859
In the working tree:
 
860
         0 unchanged
 
861
         0 modified
 
862
         0 added
 
863
         0 removed
 
864
         0 renamed
 
865
         0 unknown
 
866
         0 ignored
 
867
         0 versioned subdirectories
 
868
 
 
869
Branch history:
 
870
         0 revisions
 
871
         0 committers
 
872
 
 
873
Repository:
 
874
         0 revisions
 
875
         0 KiB
 
876
""" % (format.get_branch_format().get_format_description(),
 
877
       format.repository_format.get_format_description(),
 
878
       ), out)
 
879
        self.assertEqual('', err)
 
880
 
 
881
        # Update first branch
 
882
        self.build_tree(['repo/branch1/a'])
 
883
        tree1 = branch1.bzrdir.open_workingtree()
 
884
        tree1.add('a')
 
885
        tree1.commit('commit one')
 
886
        rev = repo.get_revision(branch1.revision_history()[0])
 
887
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
888
        out, err = self.run_bzr('info -v repo/branch1')
 
889
        self.assertEqualDiff(
 
890
"""Repository tree (format: knit)
 
891
Location:
 
892
  shared repository: repo
 
893
  repository branch: repo/branch1
 
894
 
 
895
Format:
 
896
       control: Meta directory format 1
 
897
  working tree: Working tree format 3
 
898
        branch: %s
 
899
    repository: %s
 
900
 
 
901
In the working tree:
 
902
         1 unchanged
 
903
         0 modified
 
904
         0 added
 
905
         0 removed
 
906
         0 renamed
 
907
         0 unknown
 
908
         0 ignored
 
909
         0 versioned subdirectories
 
910
 
 
911
Branch history:
 
912
         1 revision
 
913
         1 committer
 
914
         0 days old
 
915
   first revision: %s
 
916
  latest revision: %s
 
917
 
 
918
Repository:
 
919
         1 revision
 
920
         %d KiB
 
921
""" % (format.get_branch_format().get_format_description(),
 
922
       format.repository_format.get_format_description(),
 
923
       datestring_first, datestring_first,
 
924
       # poking at _revision_store isn't all that clean, but neither is
 
925
       # having the ui test dependent on the exact overhead of a given store.
 
926
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
927
       ), out)
 
928
        self.assertEqual('', err)
 
929
 
 
930
        # Out of date second branch
 
931
        out, err = self.run_bzr('info repo/branch2 --verbose')
 
932
        self.assertEqualDiff(
 
933
"""Repository tree (format: knit)
 
934
Location:
 
935
  shared repository: repo
 
936
  repository branch: repo/branch2
 
937
 
 
938
Related branches:
 
939
  parent branch: repo/branch1
 
940
 
 
941
Format:
 
942
       control: Meta directory format 1
 
943
  working tree: Working tree format 3
 
944
        branch: %s
 
945
    repository: %s
 
946
 
 
947
In the working tree:
 
948
         0 unchanged
 
949
         0 modified
 
950
         0 added
 
951
         0 removed
 
952
         0 renamed
 
953
         0 unknown
 
954
         0 ignored
 
955
         0 versioned subdirectories
 
956
 
 
957
Branch history:
 
958
         0 revisions
 
959
         0 committers
 
960
 
 
961
Repository:
 
962
         1 revision
 
963
         %d KiB
 
964
""" % (format.get_branch_format().get_format_description(),
 
965
       format.repository_format.get_format_description(),
 
966
       # poking at _revision_store isn't all that clean, but neither is
 
967
       # having the ui test dependent on the exact overhead of a given store.
 
968
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
969
       ), out)
 
970
        self.assertEqual('', err)
 
971
 
 
972
        # Update second branch
 
973
        tree2 = branch2.bzrdir.open_workingtree()
 
974
        tree2.pull(branch1)
 
975
        out, err = self.run_bzr('info -v repo/branch2')
 
976
        self.assertEqualDiff(
 
977
"""Repository tree (format: knit)
 
978
Location:
 
979
  shared repository: repo
 
980
  repository branch: repo/branch2
 
981
 
 
982
Related branches:
 
983
  parent branch: repo/branch1
 
984
 
 
985
Format:
 
986
       control: Meta directory format 1
 
987
  working tree: Working tree format 3
 
988
        branch: %s
 
989
    repository: %s
 
990
 
 
991
In the working tree:
 
992
         1 unchanged
 
993
         0 modified
 
994
         0 added
 
995
         0 removed
 
996
         0 renamed
 
997
         0 unknown
 
998
         0 ignored
 
999
         0 versioned subdirectories
 
1000
 
 
1001
Branch history:
 
1002
         1 revision
 
1003
         1 committer
 
1004
         0 days old
 
1005
   first revision: %s
 
1006
  latest revision: %s
 
1007
 
 
1008
Repository:
 
1009
         1 revision
 
1010
         %d KiB
 
1011
""" % (format.get_branch_format().get_format_description(),
 
1012
       format.repository_format.get_format_description(),
 
1013
       datestring_first, datestring_first,
 
1014
       # poking at _revision_store isn't all that clean, but neither is
 
1015
       # having the ui test dependent on the exact overhead of a given store.
 
1016
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
1017
       ), out)
 
1018
        self.assertEqual('', err)
 
1019
 
 
1020
        # Show info about repository with revisions
 
1021
        out, err = self.run_bzr('info -v repo')
 
1022
        self.assertEqualDiff(
 
1023
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
1024
Location:
 
1025
  shared repository: repo
 
1026
 
 
1027
Format:
 
1028
       control: Meta directory format 1
 
1029
    repository: %s
 
1030
 
 
1031
Create working tree for new branches inside the repository.
 
1032
 
 
1033
Repository:
 
1034
         1 revision
 
1035
         %d KiB
 
1036
""" % (format.repository_format.get_format_description(),
 
1037
       # poking at _revision_store isn't all that clean, but neither is
 
1038
       # having the ui test dependent on the exact overhead of a given store.
 
1039
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
1040
       ),
 
1041
       out)
 
1042
        self.assertEqual('', err)
 
1043
    
 
1044
    def test_info_shared_repository_with_tree_in_root(self):
 
1045
        format = bzrdir.format_registry.make_bzrdir('knit')
 
1046
        transport = self.get_transport()
 
1047
 
 
1048
        # Create shared repository with working trees
 
1049
        repo = self.make_repository('repo', shared=True, format=format)
 
1050
        repo.set_make_working_trees(True)
 
1051
        out, err = self.run_bzr('info -v repo')
 
1052
        self.assertEqualDiff(
 
1053
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
1054
Location:
 
1055
  shared repository: repo
 
1056
 
 
1057
Format:
 
1058
       control: Meta directory format 1
 
1059
    repository: %s
 
1060
 
 
1061
Create working tree for new branches inside the repository.
 
1062
 
 
1063
Repository:
 
1064
         0 revisions
 
1065
         0 KiB
 
1066
""" % (format.repository_format.get_format_description(),
 
1067
       ), out)
 
1068
        self.assertEqual('', err)
 
1069
 
 
1070
        # Create branch in root of repository
 
1071
        control = repo.bzrdir
 
1072
        branch = control.create_branch()
 
1073
        control.create_workingtree()
 
1074
        out, err = self.run_bzr('info -v repo')
 
1075
        self.assertEqualDiff(
 
1076
"""Repository tree (format: knit)
 
1077
Location:
 
1078
  shared repository: repo
 
1079
  repository branch: repo
 
1080
 
 
1081
Format:
 
1082
       control: Meta directory format 1
 
1083
  working tree: Working tree format 3
 
1084
        branch: %s
 
1085
    repository: %s
 
1086
 
 
1087
In the working tree:
 
1088
         0 unchanged
 
1089
         0 modified
 
1090
         0 added
 
1091
         0 removed
 
1092
         0 renamed
 
1093
         0 unknown
 
1094
         0 ignored
 
1095
         0 versioned subdirectories
 
1096
 
 
1097
Branch history:
 
1098
         0 revisions
 
1099
         0 committers
 
1100
 
 
1101
Repository:
 
1102
         0 revisions
 
1103
         0 KiB
 
1104
""" % (format.get_branch_format().get_format_description(),
 
1105
       format.repository_format.get_format_description(),
 
1106
       ), out)
 
1107
        self.assertEqual('', err)
 
1108
 
 
1109
    def assertCheckoutStatusOutput(self, 
 
1110
        command_string, lco_tree, shared_repo=None,
 
1111
        repo_branch=None,
 
1112
        tree_locked=False,
 
1113
        branch_locked=False, repo_locked=False,
 
1114
        verbose=False,
 
1115
        light_checkout=True,
 
1116
        checkout_root=None):
 
1117
        """Check the output of info in a checkout.
 
1118
 
 
1119
        This is not quite a mirror of the info code: rather than using the
 
1120
        tree being examined to predict output, it uses a bunch of flags which
 
1121
        allow us, the test writers, to document what *should* be present in
 
1122
        the output. Removing this separation would remove the value of the
 
1123
        tests.
 
1124
        
 
1125
        :param path: the path to the light checkout.
 
1126
        :param lco_tree: the tree object for the light checkout.
 
1127
        :param shared_repo: A shared repository is in use, expect that in
 
1128
            the output.
 
1129
        :param repo_branch: A branch in a shared repository for non light
 
1130
            checkouts.
 
1131
        :param tree_locked: If true, expect the tree to be locked.
 
1132
        :param branch_locked: If true, expect the branch to be locked.
 
1133
        :param repo_locked: If true, expect the repository to be locked.
 
1134
        :param verbose: If true, expect verbose output
 
1135
        """
 
1136
        def friendly_location(url):
 
1137
            path = urlutils.unescape_for_display(url, 'ascii')
 
1138
            try:
 
1139
                return osutils.relpath(osutils.getcwd(), path)
 
1140
            except errors.PathNotChild:
 
1141
                return path
 
1142
 
 
1143
        if tree_locked and sys.platform == 'win32':
 
1144
            # We expect this to fail because of locking errors. (A write-locked
 
1145
            # file cannot be read-locked in the same process).
 
1146
            # This should be removed when the locking errors are fixed.
 
1147
            self.run_bzr_error([], 'info ' + command_string)
 
1148
            return
 
1149
        out, err = self.run_bzr('info %s' % command_string)
 
1150
        description = {
 
1151
            (True, True): 'Lightweight checkout',
 
1152
            (True, False): 'Repository checkout',
 
1153
            (False, True): 'Lightweight checkout',
 
1154
            (False, False): 'Checkout',
 
1155
            }[(shared_repo is not None, light_checkout)]
 
1156
        format = {True: 'dirstate or dirstate-tags or knitpack-experimental'
 
1157
                        ' or rich-root',
 
1158
                  False: 'dirstate'}[light_checkout]
 
1159
        if repo_locked or branch_locked or tree_locked:
 
1160
            def locked_message(a_bool):
 
1161
                if a_bool:
 
1162
                    return 'locked'
 
1163
                else:
 
1164
                    return 'unlocked'
 
1165
            expected_lock_output = (
 
1166
                "\n"
 
1167
                "Lock status:\n"
 
1168
                "  working tree: %s\n"
 
1169
                "        branch: %s\n"
 
1170
                "    repository: %s\n" % (
 
1171
                    locked_message(tree_locked),
 
1172
                    locked_message(branch_locked),
 
1173
                    locked_message(repo_locked)))
 
1174
        else:
 
1175
            expected_lock_output = ''
 
1176
        tree_data = ''
 
1177
        extra_space = ''
 
1178
        if light_checkout:
 
1179
            tree_data = ("  light checkout root: %s\n" %
 
1180
                friendly_location(lco_tree.bzrdir.root_transport.base))
 
1181
            extra_space = ' '
 
1182
        if lco_tree.branch.get_bound_location() is not None:
 
1183
            tree_data += ("%s       checkout root: %s\n" % (extra_space,
 
1184
                friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
 
1185
        if shared_repo is not None:
 
1186
            branch_data = (
 
1187
                "   checkout of branch: %s\n"
 
1188
                "    shared repository: %s\n" %
 
1189
                (friendly_location(repo_branch.bzrdir.root_transport.base),
 
1190
                 friendly_location(shared_repo.bzrdir.root_transport.base)))
 
1191
        elif repo_branch is not None:
 
1192
            branch_data = (
 
1193
                "%s  checkout of branch: %s\n" %
 
1194
                (extra_space,
 
1195
                 friendly_location(repo_branch.bzrdir.root_transport.base)))
 
1196
        else:
 
1197
            branch_data = ("   checkout of branch: %s\n" %
 
1198
                lco_tree.branch.bzrdir.root_transport.base)
 
1199
        
 
1200
        if verbose:
 
1201
            verbose_info = '         0 committers\n'
 
1202
        else:
 
1203
            verbose_info = ''
 
1204
            
 
1205
        self.assertEqualDiff(
 
1206
"""%s (format: %s)
 
1207
Location:
 
1208
%s%s
 
1209
Format:
 
1210
       control: Meta directory format 1
 
1211
  working tree: %s
 
1212
        branch: %s
 
1213
    repository: %s
 
1214
%s
 
1215
In the working tree:
 
1216
         0 unchanged
 
1217
         0 modified
 
1218
         0 added
 
1219
         0 removed
 
1220
         0 renamed
 
1221
         0 unknown
 
1222
         0 ignored
 
1223
         0 versioned subdirectories
 
1224
 
 
1225
Branch history:
 
1226
         0 revisions
 
1227
%s
 
1228
Repository:
 
1229
         0 revisions
 
1230
         0 KiB
 
1231
""" %  (description,
 
1232
        format,
 
1233
        tree_data,
 
1234
        branch_data,
 
1235
        lco_tree._format.get_format_description(),
 
1236
        lco_tree.branch._format.get_format_description(),
 
1237
        lco_tree.branch.repository._format.get_format_description(),
 
1238
        expected_lock_output,
 
1239
        verbose_info,
 
1240
        ), out)
 
1241
        self.assertEqual('', err)
 
1242
 
 
1243
    def test_info_locking(self):
 
1244
        transport = self.get_transport()
 
1245
        # Create shared repository with a branch
 
1246
        repo = self.make_repository('repo', shared=True,
 
1247
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1248
        repo.set_make_working_trees(False)
 
1249
        repo.bzrdir.root_transport.mkdir('branch')
 
1250
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
 
1251
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1252
        # Do a heavy checkout
 
1253
        transport.mkdir('tree')
 
1254
        transport.mkdir('tree/checkout')
 
1255
        co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
 
1256
            format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1257
        co_branch.bind(repo_branch)
 
1258
        # Do a light checkout of the heavy one
 
1259
        transport.mkdir('tree/lightcheckout')
 
1260
        lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
 
1261
        bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
 
1262
        lco_dir.create_workingtree()
 
1263
        lco_tree = lco_dir.open_workingtree()
 
1264
 
 
1265
        # Test all permutations of locking the working tree, branch and repository
 
1266
        # W B R
 
1267
 
 
1268
        # U U U
 
1269
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
 
1270
                                        repo_branch=repo_branch,
 
1271
                                        verbose=True, light_checkout=True)
 
1272
        # U U L
 
1273
        lco_tree.branch.repository.lock_write()
 
1274
        try:
 
1275
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1276
            lco_tree, repo_branch=repo_branch,
 
1277
            repo_locked=True, verbose=True, light_checkout=True)
 
1278
        finally:
 
1279
            lco_tree.branch.repository.unlock()
 
1280
        # U L L
 
1281
        lco_tree.branch.lock_write()
 
1282
        try:
 
1283
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1284
            lco_tree,
 
1285
            branch_locked=True,
 
1286
            repo_locked=True,
 
1287
            repo_branch=repo_branch,
 
1288
            verbose=True)
 
1289
        finally:
 
1290
            lco_tree.branch.unlock()
 
1291
        # L L L
 
1292
        lco_tree.lock_write()
 
1293
        try:
 
1294
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1295
            lco_tree, repo_branch=repo_branch,
 
1296
            tree_locked=True,
 
1297
            branch_locked=True,
 
1298
            repo_locked=True,
 
1299
            verbose=True)
 
1300
        finally:
 
1301
            lco_tree.unlock()
 
1302
        # L L U
 
1303
        lco_tree.lock_write()
 
1304
        lco_tree.branch.repository.unlock()
 
1305
        try:
 
1306
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1307
            lco_tree, repo_branch=repo_branch,
 
1308
            tree_locked=True,
 
1309
            branch_locked=True,
 
1310
            verbose=True)
 
1311
        finally:
 
1312
            lco_tree.branch.repository.lock_write()
 
1313
            lco_tree.unlock()
 
1314
        # L U U
 
1315
        lco_tree.lock_write()
 
1316
        lco_tree.branch.unlock()
 
1317
        try:
 
1318
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1319
            lco_tree, repo_branch=repo_branch,
 
1320
            tree_locked=True,
 
1321
            verbose=True)
 
1322
        finally:
 
1323
            lco_tree.branch.lock_write()
 
1324
            lco_tree.unlock()
 
1325
        # L U L
 
1326
        lco_tree.lock_write()
 
1327
        lco_tree.branch.unlock()
 
1328
        lco_tree.branch.repository.lock_write()
 
1329
        try:
 
1330
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1331
            lco_tree, repo_branch=repo_branch,
 
1332
            tree_locked=True,
 
1333
            repo_locked=True,
 
1334
            verbose=True)
 
1335
        finally:
 
1336
            lco_tree.branch.repository.unlock()
 
1337
            lco_tree.branch.lock_write()
 
1338
            lco_tree.unlock()
 
1339
        # U L U
 
1340
        lco_tree.branch.lock_write()
 
1341
        lco_tree.branch.repository.unlock()
 
1342
        try:
 
1343
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
 
1344
            lco_tree, repo_branch=repo_branch,
 
1345
            branch_locked=True,
 
1346
            verbose=True)
 
1347
        finally:
 
1348
            lco_tree.branch.repository.lock_write()
 
1349
            lco_tree.branch.unlock()
 
1350
 
 
1351
        if sys.platform == 'win32':
 
1352
            self.knownFailure('Win32 cannot run "bzr info"'
 
1353
                              ' when the tree is locked.')
 
1354
 
 
1355
    def test_info_locking_oslocks(self):
 
1356
        if sys.platform == "win32":
 
1357
            raise TestSkipped("don't use oslocks on win32 in unix manner")
 
1358
 
 
1359
        tree = self.make_branch_and_tree('branch',
 
1360
                                         format=bzrlib.bzrdir.BzrDirFormat6())
 
1361
 
 
1362
        # Test all permutations of locking the working tree, branch and repository
 
1363
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
 
1364
        # implemented by raising NotImplementedError and get_physical_lock_status()
 
1365
        # always returns false. This makes bzr info hide the lock status.  (Olaf)
 
1366
        # W B R
 
1367
 
 
1368
        # U U U
 
1369
        out, err = self.run_bzr('info -v branch')
 
1370
        self.assertEqualDiff(
 
1371
"""Standalone tree (format: weave)
 
1372
Location:
 
1373
  branch root: %s
 
1374
 
 
1375
Format:
 
1376
       control: All-in-one format 6
 
1377
  working tree: Working tree format 2
 
1378
        branch: Branch format 4
 
1379
    repository: %s
 
1380
 
 
1381
In the working tree:
 
1382
         0 unchanged
 
1383
         0 modified
 
1384
         0 added
 
1385
         0 removed
 
1386
         0 renamed
 
1387
         0 unknown
 
1388
         0 ignored
 
1389
         0 versioned subdirectories
 
1390
 
 
1391
Branch history:
 
1392
         0 revisions
 
1393
         0 committers
 
1394
 
 
1395
Repository:
 
1396
         0 revisions
 
1397
         0 KiB
 
1398
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1399
       ), out)
 
1400
        self.assertEqual('', err)
 
1401
        # L L L
 
1402
        tree.lock_write()
 
1403
        out, err = self.run_bzr('info -v branch')
 
1404
        self.assertEqualDiff(
 
1405
"""Standalone tree (format: weave)
 
1406
Location:
 
1407
  branch root: %s
 
1408
 
 
1409
Format:
 
1410
       control: All-in-one format 6
 
1411
  working tree: Working tree format 2
 
1412
        branch: Branch format 4
 
1413
    repository: %s
 
1414
 
 
1415
In the working tree:
 
1416
         0 unchanged
 
1417
         0 modified
 
1418
         0 added
 
1419
         0 removed
 
1420
         0 renamed
 
1421
         0 unknown
 
1422
         0 ignored
 
1423
         0 versioned subdirectories
 
1424
 
 
1425
Branch history:
 
1426
         0 revisions
 
1427
         0 committers
 
1428
 
 
1429
Repository:
 
1430
         0 revisions
 
1431
         0 KiB
 
1432
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1433
       ), out)
 
1434
        self.assertEqual('', err)
 
1435
        tree.unlock()