~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2010-12-20 12:01:56 UTC
  • mfrom: (4360.10.50 smooth-upgrades)
  • mto: This revision was merged to the branch mainline in revision 5576.
  • Revision ID: v.ladeuil+lp@free.fr-20101220120156-0rje08csoeuszd93
Smoother upgrades

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
        self.make_format_5_branch()
59
59
        (out, err) = self.run_bzr(
60
60
            ['upgrade', self.get_readonly_url('format_5_branch')], retcode=3)
61
 
        self.assertEqual(out, "")
62
 
        self.assertEqual(err, "bzr: ERROR: Upgrade URL cannot work with readonly URLs.\n")
 
61
        err_msg = 'Upgrade URL cannot work with readonly URLs.'
 
62
        self.assertEqualDiff('conversion error: %s\nbzr: ERROR: %s\n'
 
63
                             % (err_msg, err_msg),
 
64
                             err)
63
65
 
64
66
    def test_upgrade_up_to_date(self):
65
67
        self.make_current_format_branch_and_checkout()
66
68
        # when up to date we should get a message to that effect
67
69
        (out, err) = self.run_bzr('upgrade current_format_branch', retcode=3)
68
 
        self.assertEqual("", out)
69
 
        self.assertEqualDiff("bzr: ERROR: The branch format Meta "
70
 
                             "directory format 1 is already at the most "
71
 
                             "recent format.\n", err)
 
70
        err_msg = ('The branch format %s is already at the most recent format.'
 
71
                   % ('Meta directory format 1'))
 
72
        self.assertEqualDiff('conversion error: %s\nbzr: ERROR: %s\n'
 
73
                             % (err_msg, err_msg),
 
74
                             err)
72
75
 
73
76
    def test_upgrade_up_to_date_checkout_warns_branch_left_alone(self):
74
77
        self.make_current_format_branch_and_checkout()
75
78
        # when upgrading a checkout, the branch location and a suggestion
76
79
        # to upgrade it should be emitted even if the checkout is up to
77
80
        # date
 
81
        burl = self.get_transport('current_format_branch').base
 
82
        curl = self.get_transport('current_format_checkout').base
78
83
        (out, err) = self.run_bzr('upgrade current_format_checkout', retcode=3)
79
 
        self.assertEqual("This is a checkout. The branch (%s) needs to be "
80
 
                         "upgraded separately.\n"
81
 
                         % transport.get_transport(
82
 
                self.get_url('current_format_branch')).base,
83
 
                         out)
84
 
        self.assertEqualDiff("bzr: ERROR: The branch format Meta "
85
 
                             "directory format 1 is already at the most "
86
 
                             "recent format.\n", err)
 
84
        self.assertEqual(
 
85
            'Upgrading branch %s ...\nThis is a checkout.'
 
86
            ' The branch (%s) needs to be upgraded separately.\n'
 
87
            % (curl, burl),
 
88
            out)
 
89
        msg = 'The branch format %s is already at the most recent format.' % (
 
90
            'Meta directory format 1')
 
91
        self.assertEqualDiff('conversion error: %s\nbzr: ERROR: %s\n'
 
92
                             % (msg, msg),
 
93
                             err)
87
94
 
88
95
    def test_upgrade_checkout(self):
89
96
        # upgrading a checkout should work
107
114
        backup_dir = 'backup.bzr.~1~'
108
115
        (out, err) = self.run_bzr(
109
116
            ['upgrade', '--format=metaweave', url])
110
 
        self.assertEqualDiff("""starting upgrade of %s
 
117
        self.assertEqualDiff("""Upgrading branch %s ...
 
118
starting upgrade of %s
111
119
making backup of %s.bzr
112
120
  to %s%s
113
121
starting upgrade from format 5 to 6
115
123
adding prefixes to revision-store
116
124
starting upgrade from format 6 to metadir
117
125
finished
118
 
""" % (url, url, url, backup_dir), out)
 
126
""" % (url, url, url, url, backup_dir), out)
119
127
        self.assertEqualDiff("", err)
120
128
        self.assertTrue(isinstance(
121
129
            bzrdir.BzrDir.open(self.get_url('format_5_branch'))._format,
131
139
        backup_dir = 'backup.bzr.~1~'
132
140
        (out, err) = self.run_bzr(
133
141
            ['upgrade', '--format=knit', url])
134
 
        self.assertEqualDiff("""starting upgrade of %s
 
142
        self.assertEqualDiff("""Upgrading branch %s ...
 
143
starting upgrade of %s
135
144
making backup of %s.bzr
136
145
  to %s%s
137
146
starting repository conversion
138
147
repository converted
139
148
finished
140
 
""" % (url, url, url, backup_dir), out)
 
149
""" % (url, url, url, url, backup_dir),
 
150
                             out)
141
151
        self.assertEqualDiff("", err)
142
152
        converted_dir = bzrdir.BzrDir.open(self.get_url('metadir_weave_branch'))
143
153
        self.assertTrue(isinstance(converted_dir._format,
149
159
        self.run_bzr('init-repository --format=metaweave repo')
150
160
        self.run_bzr('upgrade --format=knit repo')
151
161
 
 
162
    def assertLegalOption(self, option_str):
 
163
        # Confirm that an option is legal. (Lower level tests are
 
164
        # expected to validate the actual functionality.)
 
165
        self.run_bzr('init --format=pack-0.92 branch-foo')
 
166
        self.run_bzr('upgrade --format=2a branch-foo %s' % (option_str,))
 
167
 
 
168
    def assertBranchFormat(self, dir, format):
 
169
        branch = bzrdir.BzrDir.open_tree_or_branch(self.get_url(dir))[1]
 
170
        branch_format = branch._format
 
171
        meta_format = bzrdir.format_registry.make_bzrdir(format)
 
172
        expected_format = meta_format.get_branch_format()
 
173
        self.assertEqual(expected_format, branch_format)
 
174
 
 
175
    def test_upgrade_clean_supported(self):
 
176
        self.assertLegalOption('--clean')
 
177
        self.assertBranchFormat('branch-foo', '2a')
 
178
        backup_bzr_dir = os.path.join("branch-foo", "backup.bzr.~1~")
 
179
        self.assertFalse(os.path.exists(backup_bzr_dir))
 
180
 
 
181
    def test_upgrade_dry_run_supported(self):
 
182
        self.assertLegalOption('--dry-run')
 
183
        self.assertBranchFormat('branch-foo', 'pack-0.92')
 
184
 
152
185
    def test_upgrade_permission_check(self):
153
186
        """'backup.bzr' should retain permissions of .bzr. Bug #262450"""
154
187
        self.requireFeature(features.posix_permissions_feature)
173
206
        t.mkdir(backup_dir1)
174
207
        (out, err) = self.run_bzr(
175
208
            ['upgrade', '--format=metaweave', url])
176
 
        self.assertEqualDiff("""starting upgrade of %s
 
209
        self.assertEqualDiff("""Upgrading branch %s ...
 
210
starting upgrade of %s
177
211
making backup of %s.bzr
178
212
  to %s%s
179
213
starting upgrade from format 5 to 6
181
215
adding prefixes to revision-store
182
216
starting upgrade from format 6 to metadir
183
217
finished
184
 
""" % (url, url, url, backup_dir2), out)
 
218
""" % (url, url, url, url, backup_dir2), out)
185
219
        self.assertEqualDiff("", err)
186
220
        self.assertTrue(isinstance(
187
221
            bzrdir.BzrDir.open(self.get_url('format_5_branch'))._format,
197
231
        url = t.base
198
232
        out, err = self.run_bzr(['upgrade', '--format=knit', url])
199
233
        backup_dir = 'backup.bzr.~1~'
200
 
        self.assertEqualDiff("""starting upgrade of %s
 
234
        self.assertEqualDiff("""Upgrading branch %s ...
 
235
starting upgrade of %s
201
236
making backup of %s.bzr
202
237
  to %s%s
203
238
starting upgrade from format 6 to metadir
204
239
starting repository conversion
205
240
repository converted
206
241
finished
207
 
""" % (url, url, url,backup_dir), out)
 
242
""" % (url, url, url, url,backup_dir), out)
208
243
        self.assertEqual('', err)
209
244
 
210
245