From a5352d353b416d13a542025dcc79d834a3689acf Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Wed, 19 Dec 2018 21:44:50 +0000 Subject: [PATCH] Simplify undo code handling sources Signed-off-by: Niels Thykier --- britney2/migration.py | 12 ++++-------- britney2/transaction.py | 8 ++++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/britney2/migration.py b/britney2/migration.py index e7563af..8b4488c 100644 --- a/britney2/migration.py +++ b/britney2/migration.py @@ -245,16 +245,12 @@ class MigrationManager(object): # Handle the source package if item.architecture == 'source': sources_t = target_suite.sources - if item.package in sources_t: - source = sources_t[item.package] - undo['sources'][item.package] = source - del sources_t[item.package] - else: - # the package didn't exist, so we mark it as to-be-removed in case of undo - undo['sources']['-' + item.package] = True + undo['sources'][item.package] = sources_t.get(item.package) # add/update the source package - if not item.is_removal: + if item.is_removal: + del sources_t[item.package] + else: sources_t[item.package] = source_suite.sources[item.package] eqv_set = compute_eqv_set(pkg_universe, updates, rms) diff --git a/britney2/transaction.py b/britney2/transaction.py index ef0ce77..e26d53a 100644 --- a/britney2/transaction.py +++ b/britney2/transaction.py @@ -68,11 +68,11 @@ class MigrationTransactionState(object): # STEP 1 # undo all the changes for sources for (undo, updated_binaries) in lundo: - for k in undo['sources']: - if k[0] == '-': - del sources_t[k[1:]] + for (k, v) in undo['sources'].items(): + if v is None: + del sources_t[k] else: - sources_t[k] = undo['sources'][k] + sources_t[k] = v # STEP 2 # undo all new/updated binaries