/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: 2008-08-20 02:07:36 UTC
  • mfrom: (3640 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3682.
  • Revision ID: robertc@robertcollins.net-20080820020736-g2xe4921zzxtymle
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

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