From 814926f5c344c5581c7aa04a6cf1b12662546268 Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Mon, 17 Dec 2018 18:30:10 +0000 Subject: [PATCH] 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 --- britney.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/britney.py b/britney.py index 76c5a04..7fc4749 100755 --- a/britney.py +++ b/britney.py @@ -1809,7 +1809,7 @@ class Britney(object): # return the affected packages (direct and than 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 affected_architectures = set() item = actions @@ -1855,7 +1855,7 @@ class Britney(object): # - The automatic-revert is needed since some callers (notably via hints) may # accept the outcome of this migration and expect nuninst to be updated. # (e.g. "force-hint" or "hint") - if automatic_revert: + if stop_on_first_regression: affected_all -= affected_direct else: affected_direct = set() @@ -1878,7 +1878,7 @@ class Britney(object): check_archall, nuninst_after) # if the uninstallability counter is worse than before, break the loop - if automatic_revert: + if stop_on_first_regression: worse = False if len(nuninst_after[arch]) > len(nuninst_now[arch]): worse = True @@ -1892,10 +1892,6 @@ class Britney(object): is_accepted = False break - # check if the action improved the uninstallability counters - if not is_accepted and automatic_revert: - transaction.rollback() - return (is_accepted, nuninst_after, arch) def iter_packages(self, packages, selected, nuninst=None, parent_transaction=None): @@ -1959,6 +1955,7 @@ class Britney(object): rescheduled_packages.extend(maybe_rescheduled_packages) maybe_rescheduled_packages.clear() else: + transaction.rollback() broken = sorted(b for b in nuninst_after[failed_arch] if b not in nuninst_last_accepted[failed_arch]) compare_nuninst = None @@ -2039,7 +2036,7 @@ class Britney(object): (_, nuninst_end, undo_list,) = self.try_migration(selected, self.nuninst_orig, transaction, - automatic_revert=False) + stop_on_first_regression=False) if recurse: # Ensure upgrade_me and selected do not overlap, if we