~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2006-09-20 14:51:03 UTC
  • mfrom: (0.8.23 version_info)
  • mto: This revision was merged to the branch mainline in revision 2028.
  • Revision ID: john@arbash-meinel.com-20060920145103-02725c6d6c886040
[merge] version-info plugin, and cleanup for layout in bzr

Show diffs side-by-side

added added

removed removed

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