~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2005-11-04 01:46:31 UTC
  • mto: (1185.33.49 bzr.dev)
  • mto: This revision was merged to the branch mainline in revision 1512.
  • Revision ID: mbp@sourcefrog.net-20051104014631-750e0ad4172c952c
Make biobench directly executable

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