mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-05-18 14:01:33 +00:00
try_migration: Remove implicit rollback
The issue with an implicit rollback is that the caller has no idea whether it should invoke rollback or not if an exception occurs. Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
a05a249e04
commit
814926f5c3
13
britney.py
13
britney.py
@ -1809,7 +1809,7 @@ class Britney(object):
|
|||||||
# return the affected packages (direct and than all)
|
# return the affected packages (direct and than all)
|
||||||
return (affected_direct, affected_all)
|
return (affected_direct, affected_all)
|
||||||
|
|
||||||
def try_migration(self, actions, nuninst_now, transaction, automatic_revert=True):
|
def try_migration(self, actions, nuninst_now, transaction, stop_on_first_regression=True):
|
||||||
is_accepted = True
|
is_accepted = True
|
||||||
affected_architectures = set()
|
affected_architectures = set()
|
||||||
item = actions
|
item = actions
|
||||||
@ -1855,7 +1855,7 @@ class Britney(object):
|
|||||||
# - The automatic-revert is needed since some callers (notably via hints) may
|
# - The automatic-revert is needed since some callers (notably via hints) may
|
||||||
# accept the outcome of this migration and expect nuninst to be updated.
|
# accept the outcome of this migration and expect nuninst to be updated.
|
||||||
# (e.g. "force-hint" or "hint")
|
# (e.g. "force-hint" or "hint")
|
||||||
if automatic_revert:
|
if stop_on_first_regression:
|
||||||
affected_all -= affected_direct
|
affected_all -= affected_direct
|
||||||
else:
|
else:
|
||||||
affected_direct = set()
|
affected_direct = set()
|
||||||
@ -1878,7 +1878,7 @@ class Britney(object):
|
|||||||
check_archall, nuninst_after)
|
check_archall, nuninst_after)
|
||||||
|
|
||||||
# if the uninstallability counter is worse than before, break the loop
|
# if the uninstallability counter is worse than before, break the loop
|
||||||
if automatic_revert:
|
if stop_on_first_regression:
|
||||||
worse = False
|
worse = False
|
||||||
if len(nuninst_after[arch]) > len(nuninst_now[arch]):
|
if len(nuninst_after[arch]) > len(nuninst_now[arch]):
|
||||||
worse = True
|
worse = True
|
||||||
@ -1892,10 +1892,6 @@ class Britney(object):
|
|||||||
is_accepted = False
|
is_accepted = False
|
||||||
break
|
break
|
||||||
|
|
||||||
# check if the action improved the uninstallability counters
|
|
||||||
if not is_accepted and automatic_revert:
|
|
||||||
transaction.rollback()
|
|
||||||
|
|
||||||
return (is_accepted, nuninst_after, arch)
|
return (is_accepted, nuninst_after, arch)
|
||||||
|
|
||||||
def iter_packages(self, packages, selected, nuninst=None, parent_transaction=None):
|
def iter_packages(self, packages, selected, nuninst=None, parent_transaction=None):
|
||||||
@ -1959,6 +1955,7 @@ class Britney(object):
|
|||||||
rescheduled_packages.extend(maybe_rescheduled_packages)
|
rescheduled_packages.extend(maybe_rescheduled_packages)
|
||||||
maybe_rescheduled_packages.clear()
|
maybe_rescheduled_packages.clear()
|
||||||
else:
|
else:
|
||||||
|
transaction.rollback()
|
||||||
broken = sorted(b for b in nuninst_after[failed_arch]
|
broken = sorted(b for b in nuninst_after[failed_arch]
|
||||||
if b not in nuninst_last_accepted[failed_arch])
|
if b not in nuninst_last_accepted[failed_arch])
|
||||||
compare_nuninst = None
|
compare_nuninst = None
|
||||||
@ -2039,7 +2036,7 @@ class Britney(object):
|
|||||||
(_, nuninst_end, undo_list,) = self.try_migration(selected,
|
(_, nuninst_end, undo_list,) = self.try_migration(selected,
|
||||||
self.nuninst_orig,
|
self.nuninst_orig,
|
||||||
transaction,
|
transaction,
|
||||||
automatic_revert=False)
|
stop_on_first_regression=False)
|
||||||
|
|
||||||
if recurse:
|
if recurse:
|
||||||
# Ensure upgrade_me and selected do not overlap, if we
|
# Ensure upgrade_me and selected do not overlap, if we
|
||||||
|
Loading…
x
Reference in New Issue
Block a user