/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: Aaron Bentley
  • Date: 2007-05-18 11:42:33 UTC
  • mto: This revision was merged to the branch mainline in revision 2528.
  • Revision ID: aaron.bentley@utoronto.ca-20070518114233-dhywq002d3fi9cti
Prevent repository.get_set_default_format from corrupting inventory

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