~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2006-04-19 23:32:08 UTC
  • mto: (1711.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1674.
  • Revision ID: robertc@robertcollins.net-20060419233208-2ed6906796994316
Make knit the default format.
Adjust affect tests to either have knit specific values or to be more generic,
as appropriate.
Disable all SFTP prefetching for known paramikos - direct readv support is now
a TODO.

Show diffs side-by-side

added added

removed removed

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