/brz/remove-bazaar

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