/brz/remove-bazaar

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

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2007-09-19 05:14:14 UTC
  • mto: (2835.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2836.
  • Revision ID: robertc@robertcollins.net-20070919051414-2tgjqteg7k3ps4h0
* ``pull``, ``merge`` and ``push`` will no longer silently correct some
  repository index errors that occured as a result of the Weave disk format.
  Instead the ``reconcile`` command needs to be run to correct those
  problems if they exist (and it has been able to fix most such problems
  since bzr 0.8). Some new problems have been identified during this release
  and you should run ``bzr check`` once on every repository to see if you
  need to reconcile. If you cannot ``pull`` or ``merge`` from a remote
  repository due to mismatched parent errors - a symptom of index errors -
  you should simply take a full copy of that remote repository to a clean
  directory outside any local repositories, then run reconcile on it, and
  finally pull from it locally. (And naturally email the repositories owner
  to ask them to upgrade and run reconcile).
  (Robert Collins)

* ``VersionedFile.fix_parents`` has been removed as a harmful API.
  ``VersionedFile.join`` will no longer accept different parents on either
  side of a join - it will either ignore them, or error, depending on the
  implementation. See notes when upgrading for more information.
  (Robert Collins)

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