~bzr-pqm/bzr/bzr.dev

5557.1.7 by John Arbash Meinel
Merge in the bzr.dev 5582
1
# Copyright (C) 2006-2011 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
1534.4.13 by Robert Collins
Give a reasonable warning on attempts to upgrade a readonly url.
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
7
#
1534.4.13 by Robert Collins
Give a reasonable warning on attempts to upgrade a readonly url.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
12
#
1534.4.13 by Robert Collins
Give a reasonable warning on attempts to upgrade a readonly url.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1534.4.13 by Robert Collins
Give a reasonable warning on attempts to upgrade a readonly url.
16
17
"""Black box tests for the upgrade ui."""
5036.3.8 by Parth Malwankar
closed review comments from vila
18
import os
19
import stat
1534.4.13 by Robert Collins
Give a reasonable warning on attempts to upgrade a readonly url.
20
2323.6.1 by Martin Pool
(broken) Give a message when opening old workingtree formats suggesting upgrade
21
from bzrlib import (
22
    bzrdir,
5363.2.7 by Jelmer Vernooij
Fix tests.
23
    controldir,
5582.10.72 by Jelmer Vernooij
Some test fixes.
24
    lockable_files,
5684.1.2 by Jelmer Vernooij
Fix tests.
25
    ui,
6072.3.1 by Jelmer Vernooij
Format URLs in ``bzr upgrade`` before display.
26
    urlutils,
2323.6.1 by Martin Pool
(broken) Give a message when opening old workingtree formats suggesting upgrade
27
    )
28
from bzrlib.tests import (
5036.3.8 by Parth Malwankar
closed review comments from vila
29
    features,
2323.6.1 by Martin Pool
(broken) Give a message when opening old workingtree formats suggesting upgrade
30
    TestCaseWithTransport,
31
    )
1666.1.3 by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP.
32
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
5757.1.2 by Jelmer Vernooij
Add separate file for knit pack repository formats.
33
from bzrlib.repofmt.knitpack_repo import RepositoryFormatKnitPack1
1534.5.9 by Robert Collins
Advise users running upgrade on a checkout to also run it on the branch.
34
35
5684.1.2 by Jelmer Vernooij
Fix tests.
36
class OldBzrDir(bzrdir.BzrDirMeta1):
37
    """An test bzr dir implementation"""
38
39
    def needs_format_conversion(self, format):
40
        return not isinstance(format, self.__class__)
41
42
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
43
class ConvertOldTestToMeta(controldir.Converter):
5684.1.2 by Jelmer Vernooij
Fix tests.
44
    """A trivial converter, used for testing."""
45
46
    def convert(self, to_convert, pb):
47
        ui.ui_factory.note('starting upgrade from old test format to 2a')
48
        to_convert.control_transport.put_bytes(
49
            'branch-format',
50
            bzrdir.BzrDirMetaFormat1().get_format_string(),
51
            mode=to_convert._get_file_mode())
6472.2.1 by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories.
52
        return controldir.ControlDir.open(to_convert.user_url)
5684.1.2 by Jelmer Vernooij
Fix tests.
53
54
55
class OldBzrDirFormat(bzrdir.BzrDirMetaFormat1):
56
57
    _lock_class = lockable_files.TransportLock
58
59
    def get_converter(self, format=None):
60
        return ConvertOldTestToMeta()
61
6213.1.19 by Jelmer Vernooij
Fix tests.
62
    @classmethod
63
    def get_format_string(cls):
5684.1.2 by Jelmer Vernooij
Fix tests.
64
        return "Ancient Test Format"
65
66
    def _open(self, transport):
67
        return OldBzrDir(transport, self)
68
69
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
70
class TestWithUpgradableBranches(TestCaseWithTransport):
1534.4.13 by Robert Collins
Give a reasonable warning on attempts to upgrade a readonly url.
71
72
    def setUp(self):
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
73
        super(TestWithUpgradableBranches, self).setUp()
4608.1.1 by Martin Pool
Refactor blackbox.test_upgrade to do less work from setUp()
74
75
    def make_current_format_branch_and_checkout(self):
76
        current_tree = self.make_branch_and_tree('current_format_branch',
77
                                                 format='default')
78
        current_tree.branch.create_checkout(
79
            self.get_url('current_format_checkout'), lightweight=True)
80
1534.4.13 by Robert Collins
Give a reasonable warning on attempts to upgrade a readonly url.
81
    def test_readonly_url_error(self):
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
82
        self.make_branch_and_tree("old_format_branch", format="knit")
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
83
        (out, err) = self.run_bzr(
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
84
            ['upgrade', self.get_readonly_url("old_format_branch")], retcode=3)
4360.10.46 by Vincent Ladeuil
Get rid of _verbose_warning and rework the messages overall display (revealing some incoherences) and fixing the tests accordingly.
85
        err_msg = 'Upgrade URL cannot work with readonly URLs.'
86
        self.assertEqualDiff('conversion error: %s\nbzr: ERROR: %s\n'
87
                             % (err_msg, err_msg),
88
                             err)
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
89
90
    def test_upgrade_up_to_date(self):
4608.1.1 by Martin Pool
Refactor blackbox.test_upgrade to do less work from setUp()
91
        self.make_current_format_branch_and_checkout()
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
92
        # when up to date we should get a message to that effect
6228.2.2 by Benoît Pierre
Update upgrade tests.
93
        burl = self.get_transport('current_format_branch').local_abspath(".")
94
        (out, err) = self.run_bzr('upgrade current_format_branch', retcode=0)
95
        self.assertEqual(
96
            'Upgrading branch %s/ ...\n'
97
            'The branch format %s is already at the most recent format.\n'
98
            % (burl, 'Meta directory format 1'),
99
            out)
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
100
101
    def test_upgrade_up_to_date_checkout_warns_branch_left_alone(self):
4608.1.1 by Martin Pool
Refactor blackbox.test_upgrade to do less work from setUp()
102
        self.make_current_format_branch_and_checkout()
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
103
        # when upgrading a checkout, the branch location and a suggestion
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
104
        # to upgrade it should be emitted even if the checkout is up to
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
105
        # date
6072.3.1 by Jelmer Vernooij
Format URLs in ``bzr upgrade`` before display.
106
        burl = self.get_transport('current_format_branch').local_abspath(".")
107
        curl = self.get_transport('current_format_checkout').local_abspath(".")
6228.2.2 by Benoît Pierre
Update upgrade tests.
108
        (out, err) = self.run_bzr('upgrade current_format_checkout', retcode=0)
4360.10.46 by Vincent Ladeuil
Get rid of _verbose_warning and rework the messages overall display (revealing some incoherences) and fixing the tests accordingly.
109
        self.assertEqual(
6072.3.1 by Jelmer Vernooij
Format URLs in ``bzr upgrade`` before display.
110
            'Upgrading branch %s/ ...\nThis is a checkout.'
111
            ' The branch (%s/) needs to be upgraded separately.\n'
6228.2.2 by Benoît Pierre
Update upgrade tests.
112
            'The branch format %s is already at the most recent format.\n'
113
            % (curl, burl, 'Meta directory format 1'),
4360.10.46 by Vincent Ladeuil
Get rid of _verbose_warning and rework the messages overall display (revealing some incoherences) and fixing the tests accordingly.
114
            out)
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
115
116
    def test_upgrade_checkout(self):
117
        # upgrading a checkout should work
118
        pass
119
120
    def test_upgrade_repository_scans_branches(self):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
121
        # we should get individual upgrade notes for each branch even the
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
122
        # anonymous branch
123
        pass
124
5582.9.11 by Jelmer Vernooij
Remove some more redundancy.
125
    def test_upgrade_branch_in_repo(self):
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
126
        # upgrading a branch in a repo should warn about not upgrading the repo
127
        pass
1534.5.13 by Robert Collins
Correct buggy test.
128
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
129
    def test_upgrade_control_dir(self):
130
        old_format = OldBzrDirFormat()
5712.3.17 by Jelmer Vernooij
more fixes.
131
        self.addCleanup(bzrdir.BzrProber.formats.remove,
132
            old_format.get_format_string())
133
        bzrdir.BzrProber.formats.register(old_format.get_format_string(),
134
            old_format)
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
135
        self.addCleanup(controldir.ControlDirFormat._set_default_format,
136
                        controldir.ControlDirFormat.get_default_format())
137
138
        # setup an old format branch we can upgrade from.
139
        path = 'old_format_branch'
140
        self.make_branch_and_tree(path, format=old_format)
6072.3.1 by Jelmer Vernooij
Format URLs in ``bzr upgrade`` before display.
141
        transport = self.get_transport(path)
142
        url = transport.base
143
        display_url = transport.local_abspath('.')
1857.1.20 by Aaron Bentley
Strip out all the EnumOption stuff
144
        # check --format takes effect
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
145
        controldir.ControlDirFormat._set_default_format(old_format)
5035.4.3 by Parth Malwankar
updated existing upgrade tests to work.
146
        backup_dir = 'backup.bzr.~1~'
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
147
        (out, err) = self.run_bzr(
5684.1.2 by Jelmer Vernooij
Fix tests.
148
            ['upgrade', '--format=2a', url])
6072.3.1 by Jelmer Vernooij
Format URLs in ``bzr upgrade`` before display.
149
        self.assertEqualDiff("""Upgrading branch %s/ ...
150
starting upgrade of %s/
151
making backup of %s/.bzr
152
  to %s/%s
5684.1.2 by Jelmer Vernooij
Fix tests.
153
starting upgrade from old test format to 2a
1534.5.13 by Robert Collins
Correct buggy test.
154
finished
6072.3.1 by Jelmer Vernooij
Format URLs in ``bzr upgrade`` before display.
155
""" % (display_url, display_url, display_url, display_url, backup_dir), out)
1534.5.13 by Robert Collins
Correct buggy test.
156
        self.assertEqualDiff("", err)
157
        self.assertTrue(isinstance(
6472.2.1 by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories.
158
            controldir.ControlDir.open(self.get_url(path))._format,
1534.5.13 by Robert Collins
Correct buggy test.
159
            bzrdir.BzrDirMetaFormat1))
1556.1.4 by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.
160
161
    def test_upgrade_explicit_knit(self):
5684.1.2 by Jelmer Vernooij
Fix tests.
162
        # users can force an upgrade to knit format from a metadir pack 0.92
163
        # branch to a 2a branch.
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
164
        self.make_branch_and_tree('branch', format='knit')
6072.3.1 by Jelmer Vernooij
Format URLs in ``bzr upgrade`` before display.
165
        transport = self.get_transport('branch')
166
        url = transport.base
167
        display_url = transport.local_abspath('.')
1857.1.20 by Aaron Bentley
Strip out all the EnumOption stuff
168
        # check --format takes effect
5035.4.3 by Parth Malwankar
updated existing upgrade tests to work.
169
        backup_dir = 'backup.bzr.~1~'
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
170
        (out, err) = self.run_bzr(
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
171
            ['upgrade', '--format=pack-0.92', url])
6072.3.1 by Jelmer Vernooij
Format URLs in ``bzr upgrade`` before display.
172
        self.assertEqualDiff("""Upgrading branch %s/ ...
173
starting upgrade of %s/
174
making backup of %s/.bzr
175
  to %s/%s
1556.1.4 by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.
176
starting repository conversion
177
repository converted
178
finished
6072.3.1 by Jelmer Vernooij
Format URLs in ``bzr upgrade`` before display.
179
""" % (display_url, display_url, display_url, display_url, backup_dir),
4360.10.46 by Vincent Ladeuil
Get rid of _verbose_warning and rework the messages overall display (revealing some incoherences) and fixing the tests accordingly.
180
                             out)
1556.1.4 by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.
181
        self.assertEqualDiff("", err)
6472.2.1 by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories.
182
        converted_dir = controldir.ControlDir.open(self.get_url('branch'))
1556.1.4 by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.
183
        self.assertTrue(isinstance(converted_dir._format,
184
                                   bzrdir.BzrDirMetaFormat1))
185
        self.assertTrue(isinstance(converted_dir.open_repository()._format,
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
186
                                   RepositoryFormatKnitPack1))
1558.7.2 by Aaron Bentley
Upgrade works in repositories
187
188
    def test_upgrade_repo(self):
5684.1.2 by Jelmer Vernooij
Fix tests.
189
        self.run_bzr('init-repository --format=pack-0.92 repo')
190
        self.run_bzr('upgrade --format=2a repo')
1666.1.3 by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP.
191
4360.10.38 by Vincent Ladeuil
Use assertXXX instead of _assert_xxx helpers.
192
    def assertLegalOption(self, option_str):
4360.10.8 by Ian Clatworthy
add blackbox tests
193
        # Confirm that an option is legal. (Lower level tests are
194
        # expected to validate the actual functionality.)
195
        self.run_bzr('init --format=pack-0.92 branch-foo')
196
        self.run_bzr('upgrade --format=2a branch-foo %s' % (option_str,))
197
4360.10.38 by Vincent Ladeuil
Use assertXXX instead of _assert_xxx helpers.
198
    def assertBranchFormat(self, dir, format):
6472.2.1 by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories.
199
        branch = controldir.ControlDir.open_tree_or_branch(self.get_url(dir))[1]
4360.10.18 by Ian Clatworthy
Add basic checks to blackbox tests (beyond legal usage) as requested by poolie
200
        branch_format = branch._format
6472.2.1 by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories.
201
        meta_format = controldir.format_registry.make_bzrdir(format)
4360.10.18 by Ian Clatworthy
Add basic checks to blackbox tests (beyond legal usage) as requested by poolie
202
        expected_format = meta_format.get_branch_format()
203
        self.assertEqual(expected_format, branch_format)
204
4360.10.8 by Ian Clatworthy
add blackbox tests
205
    def test_upgrade_clean_supported(self):
4360.10.38 by Vincent Ladeuil
Use assertXXX instead of _assert_xxx helpers.
206
        self.assertLegalOption('--clean')
207
        self.assertBranchFormat('branch-foo', '2a')
4360.10.26 by Matthew Fuller
Test the [non-]existence of the current backup dir name.
208
        backup_bzr_dir = os.path.join("branch-foo", "backup.bzr.~1~")
4360.10.18 by Ian Clatworthy
Add basic checks to blackbox tests (beyond legal usage) as requested by poolie
209
        self.assertFalse(os.path.exists(backup_bzr_dir))
4360.10.8 by Ian Clatworthy
add blackbox tests
210
211
    def test_upgrade_dry_run_supported(self):
4360.10.38 by Vincent Ladeuil
Use assertXXX instead of _assert_xxx helpers.
212
        self.assertLegalOption('--dry-run')
213
        self.assertBranchFormat('branch-foo', 'pack-0.92')
4360.10.8 by Ian Clatworthy
add blackbox tests
214
4634.148.1 by Martin Pool
Backport fix for permissions of backup.bzr
215
    def test_upgrade_permission_check(self):
216
        """'backup.bzr' should retain permissions of .bzr. Bug #262450"""
5094.3.2 by Martin Pool
Fix up feature name
217
        self.requireFeature(features.posix_permissions_feature)
4634.148.1 by Martin Pool
Backport fix for permissions of backup.bzr
218
        old_perms = stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
5036.3.10 by Parth Malwankar
merged in trunk. fixed blackbox.test_upgrade to use backup.bzr.~N~ convention.
219
        backup_dir = 'backup.bzr.~1~'
4634.148.1 by Martin Pool
Backport fix for permissions of backup.bzr
220
        self.run_bzr('init --format=1.6')
221
        os.chmod('.bzr', old_perms)
222
        self.run_bzr('upgrade')
223
        new_perms = os.stat(backup_dir).st_mode & 0777
224
        self.assertTrue(new_perms == old_perms)
225
5035.4.4 by Parth Malwankar
test updated to check for creation of backup.bzr.~2~ when backup.bzr.~1~ exists
226
    def test_upgrade_with_existing_backup_dir(self):
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
227
        self.make_branch_and_tree("old_format_branch", format="knit")
228
        t = self.get_transport("old_format_branch")
5273.1.7 by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through
229
        url = t.base
6072.3.1 by Jelmer Vernooij
Format URLs in ``bzr upgrade`` before display.
230
        display_url = t.local_abspath('.')
5035.4.4 by Parth Malwankar
test updated to check for creation of backup.bzr.~2~ when backup.bzr.~1~ exists
231
        backup_dir1 = 'backup.bzr.~1~'
232
        backup_dir2 = 'backup.bzr.~2~'
5035.4.6 by Parth Malwankar
added doc to test
233
        # explicitly create backup_dir1. bzr should create the .~2~ directory
234
        # as backup
5273.1.7 by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through
235
        t.mkdir(backup_dir1)
5035.4.4 by Parth Malwankar
test updated to check for creation of backup.bzr.~2~ when backup.bzr.~1~ exists
236
        (out, err) = self.run_bzr(
5684.1.2 by Jelmer Vernooij
Fix tests.
237
            ['upgrade', '--format=2a', url])
6072.3.1 by Jelmer Vernooij
Format URLs in ``bzr upgrade`` before display.
238
        self.assertEqualDiff("""Upgrading branch %s/ ...
239
starting upgrade of %s/
240
making backup of %s/.bzr
241
  to %s/%s
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
242
starting repository conversion
243
repository converted
5035.4.4 by Parth Malwankar
test updated to check for creation of backup.bzr.~2~ when backup.bzr.~1~ exists
244
finished
6072.3.1 by Jelmer Vernooij
Format URLs in ``bzr upgrade`` before display.
245
""" % (display_url, display_url, display_url, display_url, backup_dir2), out)
5035.4.4 by Parth Malwankar
test updated to check for creation of backup.bzr.~2~ when backup.bzr.~1~ exists
246
        self.assertEqualDiff("", err)
247
        self.assertTrue(isinstance(
6472.2.1 by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories.
248
            controldir.ControlDir.open(self.get_url("old_format_branch"))._format,
5035.4.4 by Parth Malwankar
test updated to check for creation of backup.bzr.~2~ when backup.bzr.~1~ exists
249
            bzrdir.BzrDirMetaFormat1))
5273.1.7 by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through
250
        self.assertTrue(t.has(backup_dir2))
5035.4.4 by Parth Malwankar
test updated to check for creation of backup.bzr.~2~ when backup.bzr.~1~ exists
251
5582.10.4 by Jelmer Vernooij
Fix a bunch of tests.
252
1666.1.3 by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP.
253
class SFTPTests(TestCaseWithSFTPServer):
254
    """Tests for upgrade over sftp."""
255
256
    def test_upgrade_url(self):
5684.1.2 by Jelmer Vernooij
Fix tests.
257
        self.run_bzr('init --format=pack-0.92')
5609.9.4 by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible.
258
        t = self.get_transport()
1666.1.3 by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP.
259
        url = t.base
6072.3.1 by Jelmer Vernooij
Format URLs in ``bzr upgrade`` before display.
260
        display_url = urlutils.unescape_for_display(url,
6072.3.2 by Jelmer Vernooij
Use utf8 as encoding for urls passed to note().
261
            'utf-8')
5684.1.2 by Jelmer Vernooij
Fix tests.
262
        out, err = self.run_bzr(['upgrade', '--format=2a', url])
6072.3.4 by Jelmer Vernooij
Merge ~ fixes.
263
        backup_dir = 'backup.bzr.~1~'
4360.10.46 by Vincent Ladeuil
Get rid of _verbose_warning and rework the messages overall display (revealing some incoherences) and fixing the tests accordingly.
264
        self.assertEqualDiff("""Upgrading branch %s ...
265
starting upgrade of %s
3943.2.4 by Martin Pool
Move backup progress indicators from upgrade.py into backup_bzrdir, and tweak text
266
making backup of %s.bzr
5035.4.3 by Parth Malwankar
updated existing upgrade tests to work.
267
  to %s%s
1666.1.3 by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP.
268
starting repository conversion
269
repository converted
270
finished
6072.3.3 by Jelmer Vernooij
Merge bzr.dev.
271
""" % (display_url, display_url, display_url, display_url, backup_dir), out)
1666.1.3 by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP.
272
        self.assertEqual('', err)
2323.6.1 by Martin Pool
(broken) Give a message when opening old workingtree formats suggesting upgrade
273
274
4634.2.1 by Robert Collins
Fix regression in upgrade introduced with the change to upgrade in rev 4622.
275
class UpgradeRecommendedTests(TestCaseWithTransport):
2323.6.1 by Martin Pool
(broken) Give a message when opening old workingtree formats suggesting upgrade
276
277
    def test_recommend_upgrade_wt4(self):
278
        # using a deprecated format gives a warning
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
279
        self.run_bzr('init --knit a')
280
        out, err = self.run_bzr('status a')
2323.6.1 by Martin Pool
(broken) Give a message when opening old workingtree formats suggesting upgrade
281
        self.assertContainsRe(err, 'bzr upgrade .*[/\\\\]a')
2323.5.19 by Martin Pool
No upgrade recommendation on source when cloning
282
283
    def test_no_upgrade_recommendation_from_bzrdir(self):
284
        # we should only get a recommendation to upgrade when we're accessing
285
        # the actual workingtree, not when we only open a bzrdir that contains
286
        # an old workngtree
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
287
        self.run_bzr('init --knit a')
3123.5.22 by Aaron Bentley
Change failing test to use another command, since checkout now uses trees
288
        out, err = self.run_bzr('revno a')
2323.5.19 by Martin Pool
No upgrade recommendation on source when cloning
289
        if err.find('upgrade') > -1:
290
            self.fail("message shouldn't suggest upgrade:\n%s" % err)
4634.2.1 by Robert Collins
Fix regression in upgrade introduced with the change to upgrade in rev 4622.
291
292
    def test_upgrade_shared_repo(self):
293
        repo = self.make_repository('repo', format='2a', shared=True)
294
        branch = self.make_branch_and_tree('repo/branch', format="pack-0.92")
295
        self.get_transport('repo/branch/.bzr/repository').delete_tree('.')
296
        out, err = self.run_bzr(['upgrade'], working_dir='repo/branch')