Simplify undo code handling sources

Signed-off-by: Niels Thykier <niels@thykier.net>
ubuntu/rebased
Niels Thykier 6 years ago
parent 59ae7e3d68
commit a5352d353b
No known key found for this signature in database
GPG Key ID: A65B78DBE67C7AAC

@ -245,16 +245,12 @@ class MigrationManager(object):
# Handle the source package # Handle the source package
if item.architecture == 'source': if item.architecture == 'source':
sources_t = target_suite.sources sources_t = target_suite.sources
if item.package in sources_t: undo['sources'][item.package] = sources_t.get(item.package)
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
# add/update the source 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] sources_t[item.package] = source_suite.sources[item.package]
eqv_set = compute_eqv_set(pkg_universe, updates, rms) eqv_set = compute_eqv_set(pkg_universe, updates, rms)

@ -68,11 +68,11 @@ class MigrationTransactionState(object):
# STEP 1 # STEP 1
# undo all the changes for sources # undo all the changes for sources
for (undo, updated_binaries) in lundo: for (undo, updated_binaries) in lundo:
for k in undo['sources']: for (k, v) in undo['sources'].items():
if k[0] == '-': if v is None:
del sources_t[k[1:]] del sources_t[k]
else: else:
sources_t[k] = undo['sources'][k] sources_t[k] = v
# STEP 2 # STEP 2
# undo all new/updated binaries # undo all new/updated binaries

Loading…
Cancel
Save