/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 breezy/upgrade.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
            try:
87
87
                rich_root = self.controldir.find_repository()._format.rich_root_data
88
88
            except errors.NoRepositoryPresent:
89
 
                rich_root = False  # assume no rich roots
 
89
                rich_root = False # assume no rich roots
90
90
            if rich_root:
91
91
                format_name = "default-rich-root"
92
92
            else:
98
98
            raise errors.UpToDateFormat(self.controldir._format)
99
99
        if not self.controldir.can_convert_format():
100
100
            raise errors.BzrError(gettext("cannot upgrade from bzrdir format %s") %
101
 
                                  self.controldir._format)
 
101
                           self.controldir._format)
102
102
        self.controldir.check_conversion_target(format)
103
 
        ui.ui_factory.note(gettext('starting upgrade of %s') %
104
 
                           urlutils.unescape_for_display(self.transport.base, 'utf-8'))
 
103
        ui.ui_factory.note(gettext('starting upgrade of %s') % 
 
104
            urlutils.unescape_for_display(self.transport.base, 'utf-8'))
105
105
 
106
106
        self.backup_oldpath, self.backup_newpath = self.controldir.backup_bzrdir()
107
107
        while self.controldir.needs_format_conversion(format):
123
123
 
124
124
def upgrade(url, format=None, clean_up=False, dry_run=False):
125
125
    """Upgrade locations to format.
126
 
 
 
126
 
127
127
    This routine wraps the smart_upgrade() routine with a nicer UI.
128
128
    In particular, it ensures all URLs can be opened before starting
129
129
    and reports a summary at the end if more than one upgrade was attempted.
139
139
    """
140
140
    control_dirs = [ControlDir.open_unsupported(url)]
141
141
    attempted, succeeded, exceptions = smart_upgrade(control_dirs,
142
 
                                                     format, clean_up=clean_up, dry_run=dry_run)
 
142
        format, clean_up=clean_up, dry_run=dry_run)
143
143
    if len(attempted) > 1:
144
144
        attempted_count = len(attempted)
145
145
        succeeded_count = len(succeeded)
146
146
        failed_count = attempted_count - succeeded_count
147
147
        ui.ui_factory.note(
148
 
            gettext('\nSUMMARY: {0} upgrades attempted, {1} succeeded,'
 
148
            gettext('\nSUMMARY: {0} upgrades attempted, {1} succeeded,'\
149
149
                    ' {2} failed').format(
150
 
                attempted_count, succeeded_count, failed_count))
 
150
                     attempted_count, succeeded_count, failed_count))
151
151
    return exceptions
152
152
 
153
153
 
154
154
def smart_upgrade(control_dirs, format, clean_up=False,
155
 
                  dry_run=False):
 
155
    dry_run=False):
156
156
    """Convert control directories to a new format intelligently.
157
157
 
158
158
    If the control directory is a shared repository, dependent branches
171
171
    all_exceptions = []
172
172
    for control_dir in control_dirs:
173
173
        attempted, succeeded, exceptions = _smart_upgrade_one(control_dir,
174
 
                                                              format, clean_up=clean_up, dry_run=dry_run)
 
174
            format, clean_up=clean_up, dry_run=dry_run)
175
175
        all_attempted.extend(attempted)
176
176
        all_succeeded.extend(succeeded)
177
177
        all_exceptions.extend(exceptions)
179
179
 
180
180
 
181
181
def _smart_upgrade_one(control_dir, format, clean_up=False,
182
 
                       dry_run=False):
 
182
    dry_run=False):
183
183
    """Convert a control directory to a new format intelligently.
184
184
 
185
185
    See smart_upgrade for parameter details.
195
195
        # The URL is a repository. If it successfully upgrades,
196
196
        # then upgrade the dependent branches as well.
197
197
        if repo.is_shared():
198
 
            dependents = list(repo.find_branches(using=True))
 
198
            dependents = repo.find_branches(using=True)
199
199
 
200
200
    # Do the conversions
201
201
    attempted = [control_dir]
207
207
        # Convert dependent branches
208
208
        branch_cdirs = [b.controldir for b in dependents]
209
209
        successes, problems = _convert_items(branch_cdirs, format, clean_up,
210
 
                                             dry_run, label="branch")
 
210
            dry_run, label="branch")
211
211
        attempted.extend(branch_cdirs)
212
212
        succeeded.extend(successes)
213
213
        exceptions.extend(problems)
220
220
# - raising AssertionError is rude and may not be necessary
221
221
# - no tests
222
222
# - the only caller uses only the label
223
 
 
224
 
 
225
223
def _get_object_and_label(control_dir):
226
224
    """Return the primary object and type label for a control directory.
227
225
 
260
258
 
261
259
def _convert_items(items, format, clean_up, dry_run, label=None):
262
260
    """Convert a sequence of control directories to the given format.
263
 
 
 
261
 
264
262
    :param items: the control directories to upgrade
265
263
    :param format: the format to convert to or None for the best default
266
264
    :param clean-up: if True, the backup.bzr directory is removed if the
278
276
            location = control_dir.root_transport.base
279
277
            bzr_object, bzr_label = _get_object_and_label(control_dir)
280
278
            type_label = label or bzr_label
281
 
            child_pb.update(gettext("Upgrading %s") %
282
 
                            (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'),))
 
279
            child_pb.update(gettext("Upgrading %s") % (type_label), i+1, len(items))
 
280
            ui.ui_factory.note(gettext('Upgrading {0} {1} ...').format(type_label, 
 
281
                urlutils.unescape_for_display(location, 'utf-8'),))
285
282
            try:
286
283
                if not dry_run:
287
284
                    cv = Convert(control_dir=control_dir, format=format)
302
299
                    if not dry_run:
303
300
                        cv.clean_up()
304
301
                except Exception as ex:
305
 
                    trace.warning(
306
 
                        gettext('failed to clean-up {0}: {1}') % (location, ex))
 
302
                    trace.warning(gettext('failed to clean-up {0}: {1}') % (location, ex))
307
303
                    exceptions.append(ex)
308
304
 
309
305
    # Return the result