~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2010-10-26 08:08:23 UTC
  • mfrom: (5514.1.1 665100-content-type)
  • mto: This revision was merged to the branch mainline in revision 5516.
  • Revision ID: v.ladeuil+lp@free.fr-20101026080823-3wggo03b7cpn9908
Correctly set the Content-Type header when POSTing http requests

Show diffs side-by-side

added added

removed removed

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