~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Samuel Bronson
  • Date: 2012-08-30 20:36:18 UTC
  • mto: (6015.57.3 2.4)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: naesten@gmail.com-20120830203618-y2dzw91nqpvpgxvx
Update INSTALL for switch to Python 2.6 and up.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    controldir,
24
24
    lockable_files,
25
25
    ui,
26
 
    urlutils,
27
26
    )
28
27
from bzrlib.tests import (
29
28
    features,
59
58
    def get_converter(self, format=None):
60
59
        return ConvertOldTestToMeta()
61
60
 
62
 
    @classmethod
63
 
    def get_format_string(cls):
 
61
    def get_format_string(self):
64
62
        return "Ancient Test Format"
65
63
 
66
64
    def _open(self, transport):
90
88
    def test_upgrade_up_to_date(self):
91
89
        self.make_current_format_branch_and_checkout()
92
90
        # when up to date we should get a message to that effect
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)
 
91
        (out, err) = self.run_bzr('upgrade current_format_branch', retcode=3)
 
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)
100
97
 
101
98
    def test_upgrade_up_to_date_checkout_warns_branch_left_alone(self):
102
99
        self.make_current_format_branch_and_checkout()
103
100
        # when upgrading a checkout, the branch location and a suggestion
104
101
        # to upgrade it should be emitted even if the checkout is up to
105
102
        # date
106
 
        burl = self.get_transport('current_format_branch').local_abspath(".")
107
 
        curl = self.get_transport('current_format_checkout').local_abspath(".")
108
 
        (out, err) = self.run_bzr('upgrade current_format_checkout', retcode=0)
 
103
        burl = self.get_transport('current_format_branch').base
 
104
        curl = self.get_transport('current_format_checkout').base
 
105
        (out, err) = self.run_bzr('upgrade current_format_checkout', retcode=3)
109
106
        self.assertEqual(
110
 
            'Upgrading branch %s/ ...\nThis is a checkout.'
111
 
            ' The branch (%s/) needs to be upgraded separately.\n'
112
 
            'The branch format %s is already at the most recent format.\n'
113
 
            % (curl, burl, 'Meta directory format 1'),
 
107
            'Upgrading branch %s ...\nThis is a checkout.'
 
108
            ' The branch (%s) needs to be upgraded separately.\n'
 
109
            % (curl, burl),
114
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)
115
116
 
116
117
    def test_upgrade_checkout(self):
117
118
        # upgrading a checkout should work
138
139
        # setup an old format branch we can upgrade from.
139
140
        path = 'old_format_branch'
140
141
        self.make_branch_and_tree(path, format=old_format)
141
 
        transport = self.get_transport(path)
142
 
        url = transport.base
143
 
        display_url = transport.local_abspath('.')
 
142
        url = self.get_transport(path).base
144
143
        # check --format takes effect
145
144
        controldir.ControlDirFormat._set_default_format(old_format)
146
145
        backup_dir = 'backup.bzr.~1~'
147
146
        (out, err) = self.run_bzr(
148
147
            ['upgrade', '--format=2a', url])
149
 
        self.assertEqualDiff("""Upgrading branch %s/ ...
150
 
starting upgrade of %s/
151
 
making backup of %s/.bzr
152
 
  to %s/%s
 
148
        self.assertEqualDiff("""Upgrading branch %s ...
 
149
starting upgrade of %s
 
150
making backup of %s.bzr
 
151
  to %s%s
153
152
starting upgrade from old test format to 2a
154
153
finished
155
 
""" % (display_url, display_url, display_url, display_url, backup_dir), out)
 
154
""" % (url, url, url, url, backup_dir), out)
156
155
        self.assertEqualDiff("", err)
157
156
        self.assertTrue(isinstance(
158
157
            bzrdir.BzrDir.open(self.get_url(path))._format,
162
161
        # users can force an upgrade to knit format from a metadir pack 0.92
163
162
        # branch to a 2a branch.
164
163
        self.make_branch_and_tree('branch', format='knit')
165
 
        transport = self.get_transport('branch')
166
 
        url = transport.base
167
 
        display_url = transport.local_abspath('.')
 
164
        url = self.get_transport('branch').base
168
165
        # check --format takes effect
169
166
        backup_dir = 'backup.bzr.~1~'
170
167
        (out, err) = self.run_bzr(
171
168
            ['upgrade', '--format=pack-0.92', url])
172
 
        self.assertEqualDiff("""Upgrading branch %s/ ...
173
 
starting upgrade of %s/
174
 
making backup of %s/.bzr
175
 
  to %s/%s
 
169
        self.assertEqualDiff("""Upgrading branch %s ...
 
170
starting upgrade of %s
 
171
making backup of %s.bzr
 
172
  to %s%s
176
173
starting repository conversion
177
174
repository converted
178
175
finished
179
 
""" % (display_url, display_url, display_url, display_url, backup_dir),
 
176
""" % (url, url, url, url, backup_dir),
180
177
                             out)
181
178
        self.assertEqualDiff("", err)
182
179
        converted_dir = bzrdir.BzrDir.open(self.get_url('branch'))
227
224
        self.make_branch_and_tree("old_format_branch", format="knit")
228
225
        t = self.get_transport("old_format_branch")
229
226
        url = t.base
230
 
        display_url = t.local_abspath('.')
231
227
        backup_dir1 = 'backup.bzr.~1~'
232
228
        backup_dir2 = 'backup.bzr.~2~'
233
229
        # explicitly create backup_dir1. bzr should create the .~2~ directory
235
231
        t.mkdir(backup_dir1)
236
232
        (out, err) = self.run_bzr(
237
233
            ['upgrade', '--format=2a', url])
238
 
        self.assertEqualDiff("""Upgrading branch %s/ ...
239
 
starting upgrade of %s/
240
 
making backup of %s/.bzr
241
 
  to %s/%s
 
234
        self.assertEqualDiff("""Upgrading branch %s ...
 
235
starting upgrade of %s
 
236
making backup of %s.bzr
 
237
  to %s%s
242
238
starting repository conversion
243
239
repository converted
244
240
finished
245
 
""" % (display_url, display_url, display_url, display_url, backup_dir2), out)
 
241
""" % (url, url, url, url, backup_dir2), out)
246
242
        self.assertEqualDiff("", err)
247
243
        self.assertTrue(isinstance(
248
244
            bzrdir.BzrDir.open(self.get_url("old_format_branch"))._format,
257
253
        self.run_bzr('init --format=pack-0.92')
258
254
        t = self.get_transport()
259
255
        url = t.base
260
 
        display_url = urlutils.unescape_for_display(url,
261
 
            'utf-8')
262
256
        out, err = self.run_bzr(['upgrade', '--format=2a', url])
263
257
        backup_dir = 'backup.bzr.~1~'
264
258
        self.assertEqualDiff("""Upgrading branch %s ...
268
262
starting repository conversion
269
263
repository converted
270
264
finished
271
 
""" % (display_url, display_url, display_url, display_url, backup_dir), out)
 
265
""" % (url, url, url, url,backup_dir), out)
272
266
        self.assertEqual('', err)
273
267
 
274
268