diff --git a/britney2/migration.py b/britney2/migration.py index fbb83ab..e7563af 100644 --- a/britney2/migration.py +++ b/britney2/migration.py @@ -227,7 +227,7 @@ class MigrationManager(object): affected by the change (as (name, arch)-tuples) and the dictionary undo which can be used to rollback the changes. """ - undo = {'binaries': {}, 'sources': {}, 'virtual': {}, 'nvirtual': []} + undo = {'binaries': {}, 'sources': {}, 'virtual': {}} affected_direct = set() updated_binaries = set() @@ -338,11 +338,9 @@ class MigrationManager(object): # register new provided packages for provided_pkg, prov_version, _ in new_pkg_data.provides: key = (provided_pkg, parch) - if provided_pkg not in provides_t_a: - undo['nvirtual'].append(key) - provides_t_a[provided_pkg] = set() - elif key not in undo['virtual']: - undo['virtual'][key] = provides_t_a[provided_pkg].copy() + if key not in undo['virtual']: + restore_as = provides_t_a[provided_pkg].copy() if provided_pkg in provides_t_a else None + undo['virtual'][key] = restore_as provides_t_a[provided_pkg].add((binary, prov_version)) if not equivalent_replacement: # all the reverse dependencies are affected by the change diff --git a/britney2/transaction.py b/britney2/transaction.py index 330ffc0..ef0ce77 100644 --- a/britney2/transaction.py +++ b/britney2/transaction.py @@ -100,12 +100,13 @@ class MigrationTransactionState(object): # STEP 4 # undo all changes to virtual packages - for (undo, updated_binaries) in lundo: - for provided_pkg, arch in undo['nvirtual']: - del provides_t[arch][provided_pkg] - for p in undo['virtual']: + for (undo, _) in lundo: + for p, value in undo['virtual'].items(): provided_pkg, arch = p - provides_t[arch][provided_pkg] = undo['virtual'][p] + if value is None: + del provides_t[arch][provided_pkg] + else: + provides_t[arch][provided_pkg] = undo['virtual'][p] @property def is_rolled_back(self):