~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,
2323.6.1 by Martin Pool
(broken) Give a message when opening old workingtree formats suggesting upgrade
26
    )
27
from bzrlib.tests import (
5036.3.8 by Parth Malwankar
closed review comments from vila
28
    features,
2323.6.1 by Martin Pool
(broken) Give a message when opening old workingtree formats suggesting upgrade
29
    TestCaseWithTransport,
30
    )
1666.1.3 by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP.
31
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
5757.1.2 by Jelmer Vernooij
Add separate file for knit pack repository formats.
32
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.
33
34
5684.1.2 by Jelmer Vernooij
Fix tests.
35
class OldBzrDir(bzrdir.BzrDirMeta1):
36
    """An test bzr dir implementation"""
37
38
    def needs_format_conversion(self, format):
39
        return not isinstance(format, self.__class__)
40
41
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
42
class ConvertOldTestToMeta(controldir.Converter):
5684.1.2 by Jelmer Vernooij
Fix tests.
43
    """A trivial converter, used for testing."""
44
45
    def convert(self, to_convert, pb):
46
        ui.ui_factory.note('starting upgrade from old test format to 2a')
47
        to_convert.control_transport.put_bytes(
48
            'branch-format',
49
            bzrdir.BzrDirMetaFormat1().get_format_string(),
50
            mode=to_convert._get_file_mode())
51
        return bzrdir.BzrDir.open(to_convert.user_url)
52
53
54
class OldBzrDirFormat(bzrdir.BzrDirMetaFormat1):
55
56
    _lock_class = lockable_files.TransportLock
57
58
    def get_converter(self, format=None):
59
        return ConvertOldTestToMeta()
60
61
    def get_format_string(self):
62
        return "Ancient Test Format"
63
64
    def _open(self, transport):
65
        return OldBzrDir(transport, self)
66
67
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
68
class TestWithUpgradableBranches(TestCaseWithTransport):
1534.4.13 by Robert Collins
Give a reasonable warning on attempts to upgrade a readonly url.
69
70
    def setUp(self):
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
71
        super(TestWithUpgradableBranches, self).setUp()
4608.1.1 by Martin Pool
Refactor blackbox.test_upgrade to do less work from setUp()
72
73
    def make_current_format_branch_and_checkout(self):
74
        current_tree = self.make_branch_and_tree('current_format_branch',
75
                                                 format='default')
76
        current_tree.branch.create_checkout(
77
            self.get_url('current_format_checkout'), lightweight=True)
78
1534.4.13 by Robert Collins
Give a reasonable warning on attempts to upgrade a readonly url.
79
    def test_readonly_url_error(self):
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
80
        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
81
        (out, err) = self.run_bzr(
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
82
            ['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.
83
        err_msg = 'Upgrade URL cannot work with readonly URLs.'
84
        self.assertEqualDiff('conversion error: %s\nbzr: ERROR: %s\n'
85
                             % (err_msg, err_msg),
86
                             err)
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
87
88
    def test_upgrade_up_to_date(self):
4608.1.1 by Martin Pool
Refactor blackbox.test_upgrade to do less work from setUp()
89
        self.make_current_format_branch_and_checkout()
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
90
        # when up to date we should get a message to that effect
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
91
        (out, err) = self.run_bzr('upgrade current_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.
92
        err_msg = ('The branch format %s is already at the most recent format.'
93
                   % ('Meta directory format 1'))
94
        self.assertEqualDiff('conversion error: %s\nbzr: ERROR: %s\n'
95
                             % (err_msg, err_msg),
96
                             err)
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
97
98
    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()
99
        self.make_current_format_branch_and_checkout()
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
100
        # when upgrading a checkout, the branch location and a suggestion
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
101
        # 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.
102
        # date
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.
103
        burl = self.get_transport('current_format_branch').base
104
        curl = self.get_transport('current_format_checkout').base
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
105
        (out, err) = self.run_bzr('upgrade current_format_checkout', 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.
106
        self.assertEqual(
107
            'Upgrading branch %s ...\nThis is a checkout.'
108
            ' The branch (%s) needs to be upgraded separately.\n'
109
            % (curl, burl),
110
            out)
111
        msg = 'The branch format %s is already at the most recent format.' % (
112
            'Meta directory format 1')
113
        self.assertEqualDiff('conversion error: %s\nbzr: ERROR: %s\n'
114
                             % (msg, msg),
115
                             err)
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
116
117
    def test_upgrade_checkout(self):
118
        # upgrading a checkout should work
119
        pass
120
121
    def test_upgrade_repository_scans_branches(self):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
122
        # 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.
123
        # anonymous branch
124
        pass
125
5582.9.11 by Jelmer Vernooij
Remove some more redundancy.
126
    def test_upgrade_branch_in_repo(self):
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
127
        # upgrading a branch in a repo should warn about not upgrading the repo
128
        pass
1534.5.13 by Robert Collins
Correct buggy test.
129
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
130
    def test_upgrade_control_dir(self):
131
        old_format = OldBzrDirFormat()
5712.3.17 by Jelmer Vernooij
more fixes.
132
        self.addCleanup(bzrdir.BzrProber.formats.remove,
133
            old_format.get_format_string())
134
        bzrdir.BzrProber.formats.register(old_format.get_format_string(),
135
            old_format)
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
136
        self.addCleanup(controldir.ControlDirFormat._set_default_format,
137
                        controldir.ControlDirFormat.get_default_format())
138
139
        # setup an old format branch we can upgrade from.
140
        path = 'old_format_branch'
141
        self.make_branch_and_tree(path, format=old_format)
5609.9.4 by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible.
142
        url = self.get_transport(path).base
1857.1.20 by Aaron Bentley
Strip out all the EnumOption stuff
143
        # check --format takes effect
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
144
        controldir.ControlDirFormat._set_default_format(old_format)
5035.4.3 by Parth Malwankar
updated existing upgrade tests to work.
145
        backup_dir = 'backup.bzr.~1~'
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
146
        (out, err) = self.run_bzr(
5684.1.2 by Jelmer Vernooij
Fix tests.
147
            ['upgrade', '--format=2a', url])
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.
148
        self.assertEqualDiff("""Upgrading branch %s ...
149
starting upgrade of %s
3943.2.4 by Martin Pool
Move backup progress indicators from upgrade.py into backup_bzrdir, and tweak text
150
making backup of %s.bzr
5035.4.3 by Parth Malwankar
updated existing upgrade tests to work.
151
  to %s%s
5684.1.2 by Jelmer Vernooij
Fix tests.
152
starting upgrade from old test format to 2a
1534.5.13 by Robert Collins
Correct buggy test.
153
finished
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.
154
""" % (url, url, url, url, backup_dir), out)
1534.5.13 by Robert Collins
Correct buggy test.
155
        self.assertEqualDiff("", err)
156
        self.assertTrue(isinstance(
5582.9.6 by Jelmer Vernooij
More cleanups, remove more dependencies on specific formats.
157
            bzrdir.BzrDir.open(self.get_url(path))._format,
1534.5.13 by Robert Collins
Correct buggy test.
158
            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.
159
160
    def test_upgrade_explicit_knit(self):
5684.1.2 by Jelmer Vernooij
Fix tests.
161
        # users can force an upgrade to knit format from a metadir pack 0.92
162
        # branch to a 2a branch.
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
163
        self.make_branch_and_tree('branch', format='knit')
5684.1.2 by Jelmer Vernooij
Fix tests.
164
        url = self.get_transport('branch').base
1857.1.20 by Aaron Bentley
Strip out all the EnumOption stuff
165
        # check --format takes effect
5035.4.3 by Parth Malwankar
updated existing upgrade tests to work.
166
        backup_dir = 'backup.bzr.~1~'
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
167
        (out, err) = self.run_bzr(
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
168
            ['upgrade', '--format=pack-0.92', url])
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.
169
        self.assertEqualDiff("""Upgrading branch %s ...
170
starting upgrade of %s
3943.2.4 by Martin Pool
Move backup progress indicators from upgrade.py into backup_bzrdir, and tweak text
171
making backup of %s.bzr
5035.4.3 by Parth Malwankar
updated existing upgrade tests to work.
172
  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.
173
starting repository conversion
174
repository converted
175
finished
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.
176
""" % (url, url, url, url, backup_dir),
177
                             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.
178
        self.assertEqualDiff("", err)
5684.1.2 by Jelmer Vernooij
Fix tests.
179
        converted_dir = bzrdir.BzrDir.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.
180
        self.assertTrue(isinstance(converted_dir._format,
181
                                   bzrdir.BzrDirMetaFormat1))
182
        self.assertTrue(isinstance(converted_dir.open_repository()._format,
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
183
                                   RepositoryFormatKnitPack1))
1558.7.2 by Aaron Bentley
Upgrade works in repositories
184
185
    def test_upgrade_repo(self):
5684.1.2 by Jelmer Vernooij
Fix tests.
186
        self.run_bzr('init-repository --format=pack-0.92 repo')
187
        self.run_bzr('upgrade --format=2a repo')
1666.1.3 by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP.
188
4360.10.38 by Vincent Ladeuil
Use assertXXX instead of _assert_xxx helpers.
189
    def assertLegalOption(self, option_str):
4360.10.8 by Ian Clatworthy
add blackbox tests
190
        # Confirm that an option is legal. (Lower level tests are
191
        # expected to validate the actual functionality.)
192
        self.run_bzr('init --format=pack-0.92 branch-foo')
193
        self.run_bzr('upgrade --format=2a branch-foo %s' % (option_str,))
194
4360.10.38 by Vincent Ladeuil
Use assertXXX instead of _assert_xxx helpers.
195
    def assertBranchFormat(self, dir, format):
4360.10.18 by Ian Clatworthy
Add basic checks to blackbox tests (beyond legal usage) as requested by poolie
196
        branch = bzrdir.BzrDir.open_tree_or_branch(self.get_url(dir))[1]
197
        branch_format = branch._format
198
        meta_format = bzrdir.format_registry.make_bzrdir(format)
199
        expected_format = meta_format.get_branch_format()
200
        self.assertEqual(expected_format, branch_format)
201
4360.10.8 by Ian Clatworthy
add blackbox tests
202
    def test_upgrade_clean_supported(self):
4360.10.38 by Vincent Ladeuil
Use assertXXX instead of _assert_xxx helpers.
203
        self.assertLegalOption('--clean')
204
        self.assertBranchFormat('branch-foo', '2a')
4360.10.26 by Matthew Fuller
Test the [non-]existence of the current backup dir name.
205
        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
206
        self.assertFalse(os.path.exists(backup_bzr_dir))
4360.10.8 by Ian Clatworthy
add blackbox tests
207
208
    def test_upgrade_dry_run_supported(self):
4360.10.38 by Vincent Ladeuil
Use assertXXX instead of _assert_xxx helpers.
209
        self.assertLegalOption('--dry-run')
210
        self.assertBranchFormat('branch-foo', 'pack-0.92')
4360.10.8 by Ian Clatworthy
add blackbox tests
211
4634.148.1 by Martin Pool
Backport fix for permissions of backup.bzr
212
    def test_upgrade_permission_check(self):
213
        """'backup.bzr' should retain permissions of .bzr. Bug #262450"""
5094.3.2 by Martin Pool
Fix up feature name
214
        self.requireFeature(features.posix_permissions_feature)
4634.148.1 by Martin Pool
Backport fix for permissions of backup.bzr
215
        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.
216
        backup_dir = 'backup.bzr.~1~'
4634.148.1 by Martin Pool
Backport fix for permissions of backup.bzr
217
        self.run_bzr('init --format=1.6')
218
        os.chmod('.bzr', old_perms)
219
        self.run_bzr('upgrade')
220
        new_perms = os.stat(backup_dir).st_mode & 0777
221
        self.assertTrue(new_perms == old_perms)
222
5035.4.4 by Parth Malwankar
test updated to check for creation of backup.bzr.~2~ when backup.bzr.~1~ exists
223
    def test_upgrade_with_existing_backup_dir(self):
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
224
        self.make_branch_and_tree("old_format_branch", format="knit")
225
        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
226
        url = t.base
5035.4.4 by Parth Malwankar
test updated to check for creation of backup.bzr.~2~ when backup.bzr.~1~ exists
227
        backup_dir1 = 'backup.bzr.~1~'
228
        backup_dir2 = 'backup.bzr.~2~'
5035.4.6 by Parth Malwankar
added doc to test
229
        # explicitly create backup_dir1. bzr should create the .~2~ directory
230
        # as backup
5273.1.7 by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through
231
        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
232
        (out, err) = self.run_bzr(
5684.1.2 by Jelmer Vernooij
Fix tests.
233
            ['upgrade', '--format=2a', url])
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.
234
        self.assertEqualDiff("""Upgrading branch %s ...
235
starting upgrade of %s
5035.4.4 by Parth Malwankar
test updated to check for creation of backup.bzr.~2~ when backup.bzr.~1~ exists
236
making backup of %s.bzr
237
  to %s%s
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
238
starting repository conversion
239
repository converted
5035.4.4 by Parth Malwankar
test updated to check for creation of backup.bzr.~2~ when backup.bzr.~1~ exists
240
finished
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.
241
""" % (url, url, url, 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
242
        self.assertEqualDiff("", err)
243
        self.assertTrue(isinstance(
5684.1.4 by Jelmer Vernooij
Use knits generally for testing
244
            bzrdir.BzrDir.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
245
            bzrdir.BzrDirMetaFormat1))
5273.1.7 by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through
246
        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
247
5582.10.4 by Jelmer Vernooij
Fix a bunch of tests.
248
1666.1.3 by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP.
249
class SFTPTests(TestCaseWithSFTPServer):
250
    """Tests for upgrade over sftp."""
251
252
    def test_upgrade_url(self):
5684.1.2 by Jelmer Vernooij
Fix tests.
253
        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.
254
        t = self.get_transport()
1666.1.3 by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP.
255
        url = t.base
5684.1.2 by Jelmer Vernooij
Fix tests.
256
        out, err = self.run_bzr(['upgrade', '--format=2a', url])
5035.4.3 by Parth Malwankar
updated existing upgrade tests to work.
257
        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.
258
        self.assertEqualDiff("""Upgrading branch %s ...
259
starting upgrade of %s
3943.2.4 by Martin Pool
Move backup progress indicators from upgrade.py into backup_bzrdir, and tweak text
260
making backup of %s.bzr
5035.4.3 by Parth Malwankar
updated existing upgrade tests to work.
261
  to %s%s
1666.1.3 by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP.
262
starting repository conversion
263
repository converted
264
finished
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.
265
""" % (url, url, url, url,backup_dir), out)
1666.1.3 by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP.
266
        self.assertEqual('', err)
2323.6.1 by Martin Pool
(broken) Give a message when opening old workingtree formats suggesting upgrade
267
268
4634.2.1 by Robert Collins
Fix regression in upgrade introduced with the change to upgrade in rev 4622.
269
class UpgradeRecommendedTests(TestCaseWithTransport):
2323.6.1 by Martin Pool
(broken) Give a message when opening old workingtree formats suggesting upgrade
270
271
    def test_recommend_upgrade_wt4(self):
272
        # using a deprecated format gives a warning
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
273
        self.run_bzr('init --knit a')
274
        out, err = self.run_bzr('status a')
2323.6.1 by Martin Pool
(broken) Give a message when opening old workingtree formats suggesting upgrade
275
        self.assertContainsRe(err, 'bzr upgrade .*[/\\\\]a')
2323.5.19 by Martin Pool
No upgrade recommendation on source when cloning
276
277
    def test_no_upgrade_recommendation_from_bzrdir(self):
278
        # we should only get a recommendation to upgrade when we're accessing
279
        # the actual workingtree, not when we only open a bzrdir that contains
280
        # an old workngtree
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
281
        self.run_bzr('init --knit a')
3123.5.22 by Aaron Bentley
Change failing test to use another command, since checkout now uses trees
282
        out, err = self.run_bzr('revno a')
2323.5.19 by Martin Pool
No upgrade recommendation on source when cloning
283
        if err.find('upgrade') > -1:
284
            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.
285
286
    def test_upgrade_shared_repo(self):
287
        repo = self.make_repository('repo', format='2a', shared=True)
288
        branch = self.make_branch_and_tree('repo/branch', format="pack-0.92")
289
        self.get_transport('repo/branch/.bzr/repository').delete_tree('.')
290
        out, err = self.run_bzr(['upgrade'], working_dir='repo/branch')