/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2011-11-24 15:48:29 UTC
  • mfrom: (6289 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6337.
  • Revision ID: v.ladeuil+lp@free.fr-20111124154829-avowjpsxdl8yp2vz
merge trunk resolving conflicts

Show diffs side-by-side

added added

removed removed

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