~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

  • Committer: Jelmer Vernooij
  • Date: 2016-04-03 16:32:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6617.
  • Revision ID: jelmer@jelmer.uk-20160403163231-h72bo0uyek2gikw0
Don't put French text in doc/en/user-reference when LANGUAGE=fr_CH.UTF_8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""bzr upgrade logic."""
18
18
 
 
19
from __future__ import absolute_import
19
20
 
20
21
from bzrlib import (
21
22
    errors,
22
23
    trace,
23
24
    ui,
 
25
    urlutils,
24
26
    )
25
 
from bzrlib.bzrdir import (
26
 
    BzrDir,
 
27
from bzrlib.controldir import (
 
28
    ControlDir,
27
29
    format_registry,
28
30
    )
 
31
from bzrlib.i18n import gettext
29
32
from bzrlib.remote import RemoteBzrDir
30
33
 
31
34
 
52
55
        if control_dir is not None:
53
56
            self.bzrdir = control_dir
54
57
        else:
55
 
            self.bzrdir = BzrDir.open_unsupported(url)
 
58
            self.bzrdir = ControlDir.open_unsupported(url)
56
59
        if isinstance(self.bzrdir, RemoteBzrDir):
57
60
            self.bzrdir._ensure_real()
58
61
            self.bzrdir = self.bzrdir._real_bzrdir
70
73
        try:
71
74
            branch = self.bzrdir.open_branch()
72
75
            if branch.user_url != self.bzrdir.user_url:
73
 
                ui.ui_factory.note(
 
76
                ui.ui_factory.note(gettext(
74
77
                    'This is a checkout. The branch (%s) needs to be upgraded'
75
 
                    ' separately.' % (branch.user_url,))
 
78
                    ' separately.') % (urlutils.unescape_for_display(
 
79
                        branch.user_url, 'utf-8')))
76
80
            del branch
77
81
        except (errors.NotBranchError, errors.IncompatibleRepositories):
78
82
            # might not be a format we can open without upgrading; see e.g.
93
97
        if not self.bzrdir.needs_format_conversion(format):
94
98
            raise errors.UpToDateFormat(self.bzrdir._format)
95
99
        if not self.bzrdir.can_convert_format():
96
 
            raise errors.BzrError("cannot upgrade from bzrdir format %s" %
 
100
            raise errors.BzrError(gettext("cannot upgrade from bzrdir format %s") %
97
101
                           self.bzrdir._format)
98
102
        self.bzrdir.check_conversion_target(format)
99
 
        ui.ui_factory.note('starting upgrade of %s' % self.transport.base)
 
103
        ui.ui_factory.note(gettext('starting upgrade of %s') % 
 
104
            urlutils.unescape_for_display(self.transport.base, 'utf-8'))
100
105
 
101
106
        self.backup_oldpath, self.backup_newpath = self.bzrdir.backup_bzrdir()
102
107
        while self.bzrdir.needs_format_conversion(format):
103
108
            converter = self.bzrdir._format.get_converter(format)
104
109
            self.bzrdir = converter.convert(self.bzrdir, None)
105
 
        ui.ui_factory.note('finished')
 
110
        ui.ui_factory.note(gettext('finished'))
106
111
 
107
112
    def clean_up(self):
108
113
        """Clean-up after a conversion.
112
117
        transport = self.transport
113
118
        backup_relpath = transport.relpath(self.backup_newpath)
114
119
        child_pb = ui.ui_factory.nested_progress_bar()
115
 
        child_pb.update('Deleting backup.bzr')
 
120
        child_pb.update(gettext('Deleting backup.bzr'))
116
121
        try:
117
122
            transport.delete_tree(backup_relpath)
118
123
        finally:
135
140
    :param dry_run: show what would happen but don't actually do any upgrades
136
141
    :return: the list of exceptions encountered
137
142
    """
138
 
    control_dirs = [BzrDir.open_unsupported(url)]
 
143
    control_dirs = [ControlDir.open_unsupported(url)]
139
144
    attempted, succeeded, exceptions = smart_upgrade(control_dirs,
140
145
        format, clean_up=clean_up, dry_run=dry_run)
141
146
    if len(attempted) > 1:
143
148
        succeeded_count = len(succeeded)
144
149
        failed_count = attempted_count - succeeded_count
145
150
        ui.ui_factory.note(
146
 
            '\nSUMMARY: %d upgrades attempted, %d succeeded, %d failed'
147
 
            % (attempted_count, succeeded_count, failed_count))
 
151
            gettext('\nSUMMARY: {0} upgrades attempted, {1} succeeded,'\
 
152
                    ' {2} failed').format(
 
153
                     attempted_count, succeeded_count, failed_count))
148
154
    return exceptions
149
155
 
150
156
 
199
205
    succeeded, exceptions = _convert_items([control_dir], format, clean_up,
200
206
                                           dry_run)
201
207
    if succeeded and dependents:
202
 
        ui.ui_factory.note('Found %d dependent branches - upgrading ...'
 
208
        ui.ui_factory.note(gettext('Found %d dependent branches - upgrading ...')
203
209
                           % (len(dependents),))
204
210
        # Convert dependent branches
205
211
        branch_cdirs = [b.bzrdir for b in dependents]
267
273
    succeeded = []
268
274
    exceptions = []
269
275
    child_pb = ui.ui_factory.nested_progress_bar()
270
 
    child_pb.update('Upgrading bzrdirs', 0, len(items))
 
276
    child_pb.update(gettext('Upgrading bzrdirs'), 0, len(items))
271
277
    for i, control_dir in enumerate(items):
272
278
        # Do the conversion
273
279
        location = control_dir.root_transport.base
274
280
        bzr_object, bzr_label = _get_object_and_label(control_dir)
275
281
        type_label = label or bzr_label
276
 
        child_pb.update("Upgrading %s" % (type_label), i+1, len(items))
277
 
        ui.ui_factory.note('Upgrading %s %s ...' % (type_label, location,))
 
282
        child_pb.update(gettext("Upgrading %s") % (type_label), i+1, len(items))
 
283
        ui.ui_factory.note(gettext('Upgrading {0} {1} ...').format(type_label, 
 
284
            urlutils.unescape_for_display(location, 'utf-8'),))
278
285
        try:
279
286
            if not dry_run:
280
287
                cv = Convert(control_dir=control_dir, format=format)
 
288
        except errors.UpToDateFormat, ex:
 
289
            ui.ui_factory.note(str(ex))
 
290
            succeeded.append(control_dir)
 
291
            continue
281
292
        except Exception, ex:
282
293
            trace.warning('conversion error: %s' % ex)
283
294
            exceptions.append(ex)
287
298
        succeeded.append(control_dir)
288
299
        if clean_up:
289
300
            try:
290
 
                ui.ui_factory.note('Removing backup ...')
 
301
                ui.ui_factory.note(gettext('Removing backup ...'))
291
302
                if not dry_run:
292
303
                    cv.clean_up()
293
304
            except Exception, ex:
294
 
                trace.warning('failed to clean-up %s: %s' % (location, ex))
 
305
                trace.warning(gettext('failed to clean-up {0}: {1}') % (location, ex))
295
306
                exceptions.append(ex)
296
307
 
297
308
    child_pb.finished()