/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5557.1.7 by John Arbash Meinel
Merge in the bzr.dev 5582
1
# Copyright (C) 2005, 2006, 2008-2011 Canonical Ltd
1267 by Martin Pool
- notes on conversion of existing history to weaves
2
#
1080 by Martin Pool
- test tool for converting history to weave files
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
1267 by Martin Pool
- notes on conversion of existing history to weaves
7
#
1080 by Martin Pool
- test tool for converting history to weave files
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
1267 by Martin Pool
- notes on conversion of existing history to weaves
12
#
1080 by Martin Pool
- test tool for converting history to weave files
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1080 by Martin Pool
- test tool for converting history to weave files
16
6622.1.30 by Jelmer Vernooij
Some more test fixes.
17
"""brz upgrade logic."""
6379.6.7 by Jelmer Vernooij
Move importing from future until after doc string, otherwise the doc string will disappear.
18
6379.6.1 by Jelmer Vernooij
Import absolute_import in a few places.
19
from __future__ import absolute_import
20
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
21
from . import (
4360.10.40 by Vincent Ladeuil
Fix imports ;)
22
    errors,
4360.10.46 by Vincent Ladeuil
Get rid of _verbose_warning and rework the messages overall display (revealing some incoherences) and fixing the tests accordingly.
23
    trace,
4360.10.40 by Vincent Ladeuil
Fix imports ;)
24
    ui,
6072.3.1 by Jelmer Vernooij
Format URLs in ``bzr upgrade`` before display.
25
    urlutils,
4360.10.40 by Vincent Ladeuil
Fix imports ;)
26
    )
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
27
from .controldir import (
6207.3.3 by jelmer at samba
Fix tests and the like.
28
    ControlDir,
5582.10.8 by Jelmer Vernooij
More fixes.
29
    format_registry,
30
    )
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
31
from .i18n import gettext
6670.4.14 by Jelmer Vernooij
Move remote to breezy.bzr.
32
from .bzr.remote import RemoteBzrDir
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
33
34
35
class Convert(object):
36
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
37
    def __init__(self, url=None, format=None, control_dir=None):
38
        """Convert a Bazaar control directory to a given format.
39
40
        Either the url or control_dir parameter must be given.
41
42
        :param url: the URL of the control directory or None if the
43
          control_dir is explicitly given instead
44
        :param format: the format to convert to or None for the default
4360.10.10 by Ian Clatworthy
minor clean-ups
45
        :param control_dir: the control directory or None if it is
46
          specified via the URL parameter instead
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
47
        """
1534.5.13 by Robert Collins
Correct buggy test.
48
        self.format = format
4634.144.9 by Martin Pool
Suppress user warnings about cross-format fetch during upgrade
49
        # XXX: Change to cleanup
50
        warning_id = 'cross_format_fetch'
4634.144.11 by Martin Pool
Rename squelched to suppressed
51
        saved_warning = warning_id in ui.ui_factory.suppressed_warnings
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
52
        if url is None and control_dir is None:
53
            raise AssertionError(
54
                "either the url or control_dir parameter must be set.")
55
        if control_dir is not None:
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
56
            self.controldir = control_dir
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
57
        else:
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
58
            self.controldir = ControlDir.open_unsupported(url)
59
        if isinstance(self.controldir, RemoteBzrDir):
60
            self.controldir._ensure_real()
61
            self.controldir = self.controldir._real_bzrdir
62
        if self.controldir.root_transport.is_readonly():
1534.5.7 by Robert Collins
Start factoring out the upgrade policy logic.
63
            raise errors.UpgradeReadonly
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
64
        self.transport = self.controldir.root_transport
4634.144.11 by Martin Pool
Rename squelched to suppressed
65
        ui.ui_factory.suppressed_warnings.add(warning_id)
1594.1.3 by Robert Collins
Fixup pb usage to use nested_progress_bar.
66
        try:
67
            self.convert()
68
        finally:
4634.144.9 by Martin Pool
Suppress user warnings about cross-format fetch during upgrade
69
            if not saved_warning:
4634.144.11 by Martin Pool
Rename squelched to suppressed
70
                ui.ui_factory.suppressed_warnings.remove(warning_id)
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
71
72
    def convert(self):
1558.7.2 by Aaron Bentley
Upgrade works in repositories
73
        try:
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
74
            branch = self.controldir.open_branch()
75
            if branch.user_url != self.controldir.user_url:
6138.3.4 by Jonathan Riddell
add gettext() to uses of trace.note()
76
                ui.ui_factory.note(gettext(
4360.10.46 by Vincent Ladeuil
Get rid of _verbose_warning and rework the messages overall display (revealing some incoherences) and fixing the tests accordingly.
77
                    'This is a checkout. The branch (%s) needs to be upgraded'
6138.3.4 by Jonathan Riddell
add gettext() to uses of trace.note()
78
                    ' separately.') % (urlutils.unescape_for_display(
6072.3.2 by Jelmer Vernooij
Use utf8 as encoding for urls passed to note().
79
                        branch.user_url, 'utf-8')))
3602.2.1 by Martin Pool
Fix and test for problem upgrading stacked branches
80
            del branch
81
        except (errors.NotBranchError, errors.IncompatibleRepositories):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
82
            # might not be a format we can open without upgrading; see e.g.
3602.2.1 by Martin Pool
Fix and test for problem upgrading stacked branches
83
            # https://bugs.launchpad.net/bzr/+bug/253891
1558.7.2 by Aaron Bentley
Upgrade works in repositories
84
            pass
4119.7.1 by Jelmer Vernooij
Make upgrade default to a rich-root-capable format if the source format uses rich roots.
85
        if self.format is None:
4170.3.5 by Jelmer Vernooij
Fix upgrade if there is no local repository present.
86
            try:
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
87
                rich_root = self.controldir.find_repository()._format.rich_root_data
4170.3.5 by Jelmer Vernooij
Fix upgrade if there is no local repository present.
88
            except errors.NoRepositoryPresent:
7143.15.2 by Jelmer Vernooij
Run autopep8.
89
                rich_root = False  # assume no rich roots
4170.3.5 by Jelmer Vernooij
Fix upgrade if there is no local repository present.
90
            if rich_root:
4119.7.1 by Jelmer Vernooij
Make upgrade default to a rich-root-capable format if the source format uses rich roots.
91
                format_name = "default-rich-root"
92
            else:
93
                format_name = "default"
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
94
            format = format_registry.make_controldir(format_name)
4119.7.1 by Jelmer Vernooij
Make upgrade default to a rich-root-capable format if the source format uses rich roots.
95
        else:
96
            format = self.format
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
97
        if not self.controldir.needs_format_conversion(format):
98
            raise errors.UpToDateFormat(self.controldir._format)
99
        if not self.controldir.can_convert_format():
6138.3.4 by Jonathan Riddell
add gettext() to uses of trace.note()
100
            raise errors.BzrError(gettext("cannot upgrade from bzrdir format %s") %
7143.15.2 by Jelmer Vernooij
Run autopep8.
101
                                  self.controldir._format)
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
102
        self.controldir.check_conversion_target(format)
7143.15.2 by Jelmer Vernooij
Run autopep8.
103
        ui.ui_factory.note(gettext('starting upgrade of %s') %
104
                           urlutils.unescape_for_display(self.transport.base, 'utf-8'))
4471.2.2 by Martin Pool
Deprecate ProgressTask.note
105
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
106
        self.backup_oldpath, self.backup_newpath = self.controldir.backup_bzrdir()
107
        while self.controldir.needs_format_conversion(format):
108
            converter = self.controldir._format.get_converter(format)
109
            self.controldir = converter.convert(self.controldir, None)
6138.3.4 by Jonathan Riddell
add gettext() to uses of trace.note()
110
        ui.ui_factory.note(gettext('finished'))
1534.5.6 by Robert Collins
split out converter logic into per-format objects.
111
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
112
    def clean_up(self):
113
        """Clean-up after a conversion.
114
115
        This removes the backup.bzr directory.
116
        """
4360.10.12 by Ian Clatworthy
use transport.delete_tree() instead of osutils.rmtree() for clean-up
117
        transport = self.transport
118
        backup_relpath = transport.relpath(self.backup_newpath)
6861.4.1 by Jelmer Vernooij
Make progress bars context managers.
119
        with ui.ui_factory.nested_progress_bar() as child_pb:
120
            child_pb.update(gettext('Deleting backup.bzr'))
4360.10.27 by Matthew Fuller
Wrap a progress bar around removing the backup dir; it may take a
121
            transport.delete_tree(backup_relpath)
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
122
123
4360.10.30 by Matthew Fuller
The various repository formats that do packing, pack themselves as
124
def upgrade(url, format=None, clean_up=False, dry_run=False):
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
125
    """Upgrade locations to format.
7143.15.2 by Jelmer Vernooij
Run autopep8.
126
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
127
    This routine wraps the smart_upgrade() routine with a nicer UI.
128
    In particular, it ensures all URLs can be opened before starting
129
    and reports a summary at the end if more than one upgrade was attempted.
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
130
    This routine is useful for command line tools. Other breezy clients
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
131
    probably ought to use smart_upgrade() instead.
132
4360.10.28 by Matthew Fuller
Revert upgrade() to taking only a single URL. Other code attempting
133
    :param url: a URL of the locations to upgrade.
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
134
    :param format: the format to convert to or None for the best default
135
    :param clean-up: if True, the backup.bzr directory is removed if the
136
      upgrade succeeded for a given repo/branch/tree
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
137
    :param dry_run: show what would happen but don't actually do any upgrades
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
138
    :return: the list of exceptions encountered
139
    """
6207.3.3 by jelmer at samba
Fix tests and the like.
140
    control_dirs = [ControlDir.open_unsupported(url)]
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
141
    attempted, succeeded, exceptions = smart_upgrade(control_dirs,
7143.15.2 by Jelmer Vernooij
Run autopep8.
142
                                                     format, clean_up=clean_up, dry_run=dry_run)
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
143
    if len(attempted) > 1:
144
        attempted_count = len(attempted)
145
        succeeded_count = len(succeeded)
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
146
        failed_count = attempted_count - succeeded_count
4360.10.46 by Vincent Ladeuil
Get rid of _verbose_warning and rework the messages overall display (revealing some incoherences) and fixing the tests accordingly.
147
        ui.ui_factory.note(
7143.15.2 by Jelmer Vernooij
Run autopep8.
148
            gettext('\nSUMMARY: {0} upgrades attempted, {1} succeeded,'
6138.3.4 by Jonathan Riddell
add gettext() to uses of trace.note()
149
                    ' {2} failed').format(
7143.15.2 by Jelmer Vernooij
Run autopep8.
150
                attempted_count, succeeded_count, failed_count))
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
151
    return exceptions
152
153
4360.10.30 by Matthew Fuller
The various repository formats that do packing, pack themselves as
154
def smart_upgrade(control_dirs, format, clean_up=False,
7143.15.2 by Jelmer Vernooij
Run autopep8.
155
                  dry_run=False):
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
156
    """Convert control directories to a new format intelligently.
157
158
    If the control directory is a shared repository, dependent branches
159
    are also converted provided the repository converted successfully.
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
160
    If the conversion of a branch fails, remaining branches are still tried.
161
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
162
    :param control_dirs: the BzrDirs to upgrade
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
163
    :param format: the format to convert to or None for the best default
4360.10.29 by Matthew Fuller
The param is clean_up, not clean-up.
164
    :param clean_up: if True, the backup.bzr directory is removed if the
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
165
      upgrade succeeded for a given repo/branch/tree
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
166
    :param dry_run: show what would happen but don't actually do any upgrades
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
167
    :return: attempted-control-dirs, succeeded-control-dirs, exceptions
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
168
    """
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
169
    all_attempted = []
170
    all_succeeded = []
171
    all_exceptions = []
172
    for control_dir in control_dirs:
173
        attempted, succeeded, exceptions = _smart_upgrade_one(control_dir,
7143.15.2 by Jelmer Vernooij
Run autopep8.
174
                                                              format, clean_up=clean_up, dry_run=dry_run)
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
175
        all_attempted.extend(attempted)
176
        all_succeeded.extend(succeeded)
177
        all_exceptions.extend(exceptions)
178
    return all_attempted, all_succeeded, all_exceptions
179
180
4360.10.30 by Matthew Fuller
The various repository formats that do packing, pack themselves as
181
def _smart_upgrade_one(control_dir, format, clean_up=False,
7143.15.2 by Jelmer Vernooij
Run autopep8.
182
                       dry_run=False):
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
183
    """Convert a control directory to a new format intelligently.
184
4360.10.10 by Ian Clatworthy
minor clean-ups
185
    See smart_upgrade for parameter details.
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
186
    """
4360.10.11 by Ian Clatworthy
for a repo, just do dependent branches (not lw checkouts) for now
187
    # If the URL is a shared repository, find the dependent branches
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
188
    dependents = None
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
189
    try:
190
        repo = control_dir.open_repository()
191
    except errors.NoRepositoryPresent:
192
        # A branch or checkout using a shared repository higher up
193
        pass
194
    else:
195
        # The URL is a repository. If it successfully upgrades,
4360.10.11 by Ian Clatworthy
for a repo, just do dependent branches (not lw checkouts) for now
196
        # then upgrade the dependent branches as well.
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
197
        if repo.is_shared():
7358.5.3 by Jelmer Vernooij
Fix tests.
198
            dependents = list(repo.find_branches(using=True))
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
199
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
200
    # Do the conversions
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
201
    attempted = [control_dir]
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
202
    succeeded, exceptions = _convert_items([control_dir], format, clean_up,
4360.10.46 by Vincent Ladeuil
Get rid of _verbose_warning and rework the messages overall display (revealing some incoherences) and fixing the tests accordingly.
203
                                           dry_run)
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
204
    if succeeded and dependents:
6138.3.4 by Jonathan Riddell
add gettext() to uses of trace.note()
205
        ui.ui_factory.note(gettext('Found %d dependent branches - upgrading ...')
4360.10.46 by Vincent Ladeuil
Get rid of _verbose_warning and rework the messages overall display (revealing some incoherences) and fixing the tests accordingly.
206
                           % (len(dependents),))
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
207
        # Convert dependent branches
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
208
        branch_cdirs = [b.controldir for b in dependents]
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
209
        successes, problems = _convert_items(branch_cdirs, format, clean_up,
7143.15.2 by Jelmer Vernooij
Run autopep8.
210
                                             dry_run, label="branch")
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
211
        attempted.extend(branch_cdirs)
4360.10.3 by Ian Clatworthy
fix tests
212
        succeeded.extend(successes)
213
        exceptions.extend(problems)
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
214
215
    # Return the result
216
    return attempted, succeeded, exceptions
217
4360.10.49 by Vincent Ladeuil
Make _get_object_and_label() private to upgrade.py, its inmplementation is both incomplete and returning info that are not used.
218
# FIXME: There are several problems below:
219
# - RemoteRepository doesn't support _unsupported (really ?)
220
# - raising AssertionError is rude and may not be necessary
221
# - no tests
222
# - the only caller uses only the label
7143.15.2 by Jelmer Vernooij
Run autopep8.
223
224
4360.10.49 by Vincent Ladeuil
Make _get_object_and_label() private to upgrade.py, its inmplementation is both incomplete and returning info that are not used.
225
def _get_object_and_label(control_dir):
226
    """Return the primary object and type label for a control directory.
227
5891.1.2 by Andrew Bennetts
Fix a bunch of docstring formatting nits, making pydoctor a bit happier.
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
4360.10.49 by Vincent Ladeuil
Make _get_object_and_label() private to upgrade.py, its inmplementation is both incomplete and returning info that are not used.
234
    """
235
    try:
236
        try:
237
            br = control_dir.open_branch(unsupported=True,
238
                                         ignore_fallbacks=True)
239
        except NotImplementedError:
240
            # RemoteRepository doesn't support the unsupported parameter
241
            br = control_dir.open_branch(ignore_fallbacks=True)
242
    except errors.NotBranchError:
243
        pass
244
    else:
245
        return br, "branch"
246
    try:
247
        repo = control_dir.open_repository()
248
    except errors.NoRepositoryPresent:
249
        pass
250
    else:
251
        return repo, "repository"
252
    try:
253
        wt = control_dir.open_workingtree()
254
    except (errors.NoWorkingTree, errors.NotLocalUrl):
255
        pass
256
    else:
257
        return wt, "tree"
258
    raise AssertionError("unknown type of control directory %s", control_dir)
259
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
260
4360.10.46 by Vincent Ladeuil
Get rid of _verbose_warning and rework the messages overall display (revealing some incoherences) and fixing the tests accordingly.
261
def _convert_items(items, format, clean_up, dry_run, label=None):
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
262
    """Convert a sequence of control directories to the given format.
7143.15.2 by Jelmer Vernooij
Run autopep8.
263
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
264
    :param items: the control directories to upgrade
265
    :param format: the format to convert to or None for the best default
266
    :param clean-up: if True, the backup.bzr directory is removed if the
267
      upgrade succeeded for a given repo/branch/tree
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
268
    :param dry_run: show what would happen but don't actually do any upgrades
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
269
    :param label: the label for these items or None to calculate one
270
    :return: items successfully upgraded, exceptions
271
    """
272
    succeeded = []
273
    exceptions = []
6861.4.1 by Jelmer Vernooij
Make progress bars context managers.
274
    with ui.ui_factory.nested_progress_bar() as child_pb:
275
        child_pb.update(gettext('Upgrading bzrdirs'), 0, len(items))
276
        for i, control_dir in enumerate(items):
277
            # Do the conversion
278
            location = control_dir.root_transport.base
279
            bzr_object, bzr_label = _get_object_and_label(control_dir)
280
            type_label = label or bzr_label
7143.15.2 by Jelmer Vernooij
Run autopep8.
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'),))
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
285
            try:
286
                if not dry_run:
6861.4.1 by Jelmer Vernooij
Make progress bars context managers.
287
                    cv = Convert(control_dir=control_dir, format=format)
288
            except errors.UpToDateFormat as ex:
289
                ui.ui_factory.note(str(ex))
290
                succeeded.append(control_dir)
291
                continue
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
292
            except Exception as ex:
6861.4.1 by Jelmer Vernooij
Make progress bars context managers.
293
                trace.warning('conversion error: %s' % ex)
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
294
                exceptions.append(ex)
6861.4.1 by Jelmer Vernooij
Make progress bars context managers.
295
                continue
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
296
6861.4.1 by Jelmer Vernooij
Make progress bars context managers.
297
            # Do any required post processing
298
            succeeded.append(control_dir)
299
            if clean_up:
300
                try:
301
                    ui.ui_factory.note(gettext('Removing backup ...'))
302
                    if not dry_run:
303
                        cv.clean_up()
304
                except Exception as ex:
7143.15.2 by Jelmer Vernooij
Run autopep8.
305
                    trace.warning(
306
                        gettext('failed to clean-up {0}: {1}') % (location, ex))
6861.4.1 by Jelmer Vernooij
Make progress bars context managers.
307
                    exceptions.append(ex)
4360.10.31 by Matthew Fuller
Wrap a progress bar around the iteration of entries to upgrade.
308
4360.10.4 by Ian Clatworthy
support multiple urls, --pack and --dry-run
309
    # Return the result
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
310
    return succeeded, exceptions