/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: v.ladeuil+lp at free
  • Date: 2006-10-12 14:29:32 UTC
  • mto: (2145.1.1 keepalive)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: v.ladeuil+lp@free.fr-20061012142932-7221fe16d2b48fa3
Shuffle http related test code. Hopefully it ends up at the right place :)

* bzrlib/tests/HttpServer.py: 
New file. bzrlib.tests.ChrootedTestCase use HttpServer. So the
class can't be defined in bzrlib.tests.HTTPUtils because it
creates a circular dependency (bzrlib.tests.HTTPUtils needs to
import bzrlib.tests).

* bzrlib/transport/http/_urllib.py: 
Transfer test server definition to bzrlib.tests.HttpServer. Clean
up imports.

* bzrlib/transport/http/_pycurl.py: 
Transfer test server definition to bzrlib.tests.HttpServer. Clean
up imports.

* bzrlib/transport/http/__init__.py: 
Transfer all test related code to either bzrlib.tests.HttpServer
and bzrlib.tests.HTTPUtils.
Fix all use of TransportNotPossible and InvalidURL by prefixing it
by 'errors.' (this seems to be the preferred way in the rest of
bzr).
Get rid of unused imports.

* bzrlib/tests/test_transport.py:
(ReadonlyDecoratorTransportTest.test_local_parameters,
FakeNFSDecoratorTests.test_http_parameters): Use HttpServer from
bzrlib.tests.HttpServer instead of bzrlib.transport.http.

* bzrlib/tests/test_sftp_transport.py:
(set_test_transport_to_sftp): Use HttpServer from
bzrlib.tests.HttpServer instead of bzrlib.transport.http.

* bzrlib/tests/test_selftest.py:
(TestTestCaseWithTransport.test_get_readonly_url_http): Use
HttpServer from bzrlib.tests.HttpServer instead of
bzrlib.transport.http.

* bzrlib/tests/test_repository.py: 
Does *not* use HttpServer.

* bzrlib/tests/test_http.py: 
Build on top of bzrlib.tests.HttpServer and bzrlib.tests.HTTPUtils
instead of bzrlib.transport.http.

* bzrlib/tests/test_bzrdir.py:
(ChrootedTests.setUp): Use HttpServer from bzrlib.tests.HttpServer
instead of bzrlib.transport.http.

* bzrlib/tests/branch_implementations/test_http.py:
(HTTPBranchTests.setUp): Use HttpServer from bzrlib.tests.HttpServer
instead of bzrlib.transport.http.

* bzrlib/tests/branch_implementations/test_branch.py:
(ChrootedTests.setUp): Use HttpServer from bzrlib.tests.HttpServer
instead of bzrlib.transport.http.

* bzrlib/tests/__init__.py:
(ChrootedTestCase.setUp): Use HttpServer from
bzrlib.tests.HttpServer instead of bzrlib.transport.http.

Show diffs side-by-side

added added

removed removed

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