~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

  • Committer: Jonathan Riddell
  • Date: 2011-09-15 11:31:47 UTC
  • mto: This revision was merged to the branch mainline in revision 6143.
  • Revision ID: jriddell@canonical.com-20110915113147-bgleett47i4jjxya
add gettext() to uses of trace.note()

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    BzrDir,
28
28
    format_registry,
29
29
    )
 
30
from bzrlib.i18n import gettext
30
31
from bzrlib.remote import RemoteBzrDir
31
32
 
32
33
 
71
72
        try:
72
73
            branch = self.bzrdir.open_branch()
73
74
            if branch.user_url != self.bzrdir.user_url:
74
 
                ui.ui_factory.note(
 
75
                ui.ui_factory.note(gettext(
75
76
                    'This is a checkout. The branch (%s) needs to be upgraded'
76
 
                    ' separately.' % (urlutils.unescape_for_display(
 
77
                    ' separately.') % (urlutils.unescape_for_display(
77
78
                        branch.user_url, 'utf-8')))
78
79
            del branch
79
80
        except (errors.NotBranchError, errors.IncompatibleRepositories):
95
96
        if not self.bzrdir.needs_format_conversion(format):
96
97
            raise errors.UpToDateFormat(self.bzrdir._format)
97
98
        if not self.bzrdir.can_convert_format():
98
 
            raise errors.BzrError("cannot upgrade from bzrdir format %s" %
 
99
            raise errors.BzrError(gettext("cannot upgrade from bzrdir format %s") %
99
100
                           self.bzrdir._format)
100
101
        self.bzrdir.check_conversion_target(format)
101
 
        ui.ui_factory.note('starting upgrade of %s' % 
 
102
        ui.ui_factory.note(gettext('starting upgrade of %s') % 
102
103
            urlutils.unescape_for_display(self.transport.base, 'utf-8'))
103
104
 
104
105
        self.backup_oldpath, self.backup_newpath = self.bzrdir.backup_bzrdir()
105
106
        while self.bzrdir.needs_format_conversion(format):
106
107
            converter = self.bzrdir._format.get_converter(format)
107
108
            self.bzrdir = converter.convert(self.bzrdir, None)
108
 
        ui.ui_factory.note('finished')
 
109
        ui.ui_factory.note(gettext('finished'))
109
110
 
110
111
    def clean_up(self):
111
112
        """Clean-up after a conversion.
115
116
        transport = self.transport
116
117
        backup_relpath = transport.relpath(self.backup_newpath)
117
118
        child_pb = ui.ui_factory.nested_progress_bar()
118
 
        child_pb.update('Deleting backup.bzr')
 
119
        child_pb.update(gettext('Deleting backup.bzr'))
119
120
        try:
120
121
            transport.delete_tree(backup_relpath)
121
122
        finally:
146
147
        succeeded_count = len(succeeded)
147
148
        failed_count = attempted_count - succeeded_count
148
149
        ui.ui_factory.note(
149
 
            '\nSUMMARY: %d upgrades attempted, %d succeeded, %d failed'
150
 
            % (attempted_count, succeeded_count, failed_count))
 
150
            gettext('\nSUMMARY: {0} upgrades attempted, {1} succeeded,'\
 
151
                    ' {2} failed').format(
 
152
                     attempted_count, succeeded_count, failed_count))
151
153
    return exceptions
152
154
 
153
155
 
202
204
    succeeded, exceptions = _convert_items([control_dir], format, clean_up,
203
205
                                           dry_run)
204
206
    if succeeded and dependents:
205
 
        ui.ui_factory.note('Found %d dependent branches - upgrading ...'
 
207
        ui.ui_factory.note(gettext('Found %d dependent branches - upgrading ...')
206
208
                           % (len(dependents),))
207
209
        # Convert dependent branches
208
210
        branch_cdirs = [b.bzrdir for b in dependents]
270
272
    succeeded = []
271
273
    exceptions = []
272
274
    child_pb = ui.ui_factory.nested_progress_bar()
273
 
    child_pb.update('Upgrading bzrdirs', 0, len(items))
 
275
    child_pb.update(gettext('Upgrading bzrdirs'), 0, len(items))
274
276
    for i, control_dir in enumerate(items):
275
277
        # Do the conversion
276
278
        location = control_dir.root_transport.base
277
279
        bzr_object, bzr_label = _get_object_and_label(control_dir)
278
280
        type_label = label or bzr_label
279
 
        child_pb.update("Upgrading %s" % (type_label), i+1, len(items))
280
 
        ui.ui_factory.note('Upgrading %s %s ...' % (type_label, 
 
281
        child_pb.update(gettext("Upgrading %s") % (type_label), i+1, len(items))
 
282
        ui.ui_factory.note(gettext('Upgrading {0} {1} ...').format(type_label, 
281
283
            urlutils.unescape_for_display(location, 'utf-8'),))
282
284
        try:
283
285
            if not dry_run:
291
293
        succeeded.append(control_dir)
292
294
        if clean_up:
293
295
            try:
294
 
                ui.ui_factory.note('Removing backup ...')
 
296
                ui.ui_factory.note(gettext('Removing backup ...'))
295
297
                if not dry_run:
296
298
                    cv.clean_up()
297
299
            except Exception, ex:
298
 
                trace.warning('failed to clean-up %s: %s' % (location, ex))
 
300
                trace.warning(gettext('failed to clean-up {0}: {1}') % (location, ex))
299
301
                exceptions.append(ex)
300
302
 
301
303
    child_pb.finished()