~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

Abbreviate pack_stat struct format to '>6L'

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    errors,
22
22
    trace,
23
23
    ui,
 
24
    urlutils,
24
25
    )
25
26
from bzrlib.bzrdir import (
26
27
    BzrDir,
27
28
    format_registry,
28
29
    )
 
30
from bzrlib.i18n import gettext
29
31
from bzrlib.remote import RemoteBzrDir
30
32
 
31
33
 
70
72
        try:
71
73
            branch = self.bzrdir.open_branch()
72
74
            if branch.user_url != self.bzrdir.user_url:
73
 
                ui.ui_factory.note(
 
75
                ui.ui_factory.note(gettext(
74
76
                    'This is a checkout. The branch (%s) needs to be upgraded'
75
 
                    ' separately.' % (branch.user_url,))
 
77
                    ' separately.') % (urlutils.unescape_for_display(
 
78
                        branch.user_url, 'utf-8')))
76
79
            del branch
77
80
        except (errors.NotBranchError, errors.IncompatibleRepositories):
78
81
            # might not be a format we can open without upgrading; see e.g.
93
96
        if not self.bzrdir.needs_format_conversion(format):
94
97
            raise errors.UpToDateFormat(self.bzrdir._format)
95
98
        if not self.bzrdir.can_convert_format():
96
 
            raise errors.BzrError("cannot upgrade from bzrdir format %s" %
 
99
            raise errors.BzrError(gettext("cannot upgrade from bzrdir format %s") %
97
100
                           self.bzrdir._format)
98
101
        self.bzrdir.check_conversion_target(format)
99
 
        ui.ui_factory.note('starting upgrade of %s' % self.transport.base)
 
102
        ui.ui_factory.note(gettext('starting upgrade of %s') % 
 
103
            urlutils.unescape_for_display(self.transport.base, 'utf-8'))
100
104
 
101
105
        self.backup_oldpath, self.backup_newpath = self.bzrdir.backup_bzrdir()
102
106
        while self.bzrdir.needs_format_conversion(format):
103
107
            converter = self.bzrdir._format.get_converter(format)
104
108
            self.bzrdir = converter.convert(self.bzrdir, None)
105
 
        ui.ui_factory.note('finished')
 
109
        ui.ui_factory.note(gettext('finished'))
106
110
 
107
111
    def clean_up(self):
108
112
        """Clean-up after a conversion.
112
116
        transport = self.transport
113
117
        backup_relpath = transport.relpath(self.backup_newpath)
114
118
        child_pb = ui.ui_factory.nested_progress_bar()
115
 
        child_pb.update('Deleting backup.bzr')
 
119
        child_pb.update(gettext('Deleting backup.bzr'))
116
120
        try:
117
121
            transport.delete_tree(backup_relpath)
118
122
        finally:
143
147
        succeeded_count = len(succeeded)
144
148
        failed_count = attempted_count - succeeded_count
145
149
        ui.ui_factory.note(
146
 
            '\nSUMMARY: %d upgrades attempted, %d succeeded, %d failed'
147
 
            % (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))
148
153
    return exceptions
149
154
 
150
155
 
199
204
    succeeded, exceptions = _convert_items([control_dir], format, clean_up,
200
205
                                           dry_run)
201
206
    if succeeded and dependents:
202
 
        ui.ui_factory.note('Found %d dependent branches - upgrading ...'
 
207
        ui.ui_factory.note(gettext('Found %d dependent branches - upgrading ...')
203
208
                           % (len(dependents),))
204
209
        # Convert dependent branches
205
210
        branch_cdirs = [b.bzrdir for b in dependents]
220
225
def _get_object_and_label(control_dir):
221
226
    """Return the primary object and type label for a control directory.
222
227
 
223
 
    :return: object, label where
224
 
      object is a Branch, Repository or WorkingTree and
225
 
      label is one of:
226
 
        branch            - a branch
227
 
        repository        - a repository
228
 
        tree              - a lightweight checkout
 
228
    :return: object, label where:
 
229
      * object is a Branch, Repository or WorkingTree and
 
230
      * label is one of:
 
231
        * branch            - a branch
 
232
        * repository        - a repository
 
233
        * tree              - a lightweight checkout
229
234
    """
230
235
    try:
231
236
        try:
267
272
    succeeded = []
268
273
    exceptions = []
269
274
    child_pb = ui.ui_factory.nested_progress_bar()
270
 
    child_pb.update('Upgrading bzrdirs', 0, len(items))
 
275
    child_pb.update(gettext('Upgrading bzrdirs'), 0, len(items))
271
276
    for i, control_dir in enumerate(items):
272
277
        # Do the conversion
273
278
        location = control_dir.root_transport.base
274
279
        bzr_object, bzr_label = _get_object_and_label(control_dir)
275
280
        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,))
 
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, 
 
283
            urlutils.unescape_for_display(location, 'utf-8'),))
278
284
        try:
279
285
            if not dry_run:
280
286
                cv = Convert(control_dir=control_dir, format=format)
287
293
        succeeded.append(control_dir)
288
294
        if clean_up:
289
295
            try:
290
 
                ui.ui_factory.note('Removing backup ...')
 
296
                ui.ui_factory.note(gettext('Removing backup ...'))
291
297
                if not dry_run:
292
298
                    cv.clean_up()
293
299
            except Exception, ex:
294
 
                trace.warning('failed to clean-up %s: %s' % (location, ex))
 
300
                trace.warning(gettext('failed to clean-up {0}: {1}') % (location, ex))
295
301
                exceptions.append(ex)
296
302
 
297
303
    child_pb.finished()