diff --git a/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_events_scanner.py b/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_events_scanner.py index f9411dfe0e..4f36c75612 100644 --- a/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_events_scanner.py +++ b/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_events_scanner.py @@ -139,8 +139,9 @@ def compute_pkg_changes_between_consequent_releases(source_installed_pkgs, if event.action == Action.PRESENT: for pkg in event.in_pkgs: if pkg in seen_pkgs: + # Remove the package with the old repository, add the one with the new one. The Package class has + # a custom __hash__ and __eq__ comparing only name and modulestream - pkg.repository is ignored. if pkg in target_pkgs: - # Remove the package with the old repository, add the one with the new one target_pkgs.remove(pkg) target_pkgs.add(pkg) elif event.action == Action.DEPRECATED: @@ -163,7 +164,10 @@ def compute_pkg_changes_between_consequent_releases(source_installed_pkgs, event.id, event.action, removed_pkgs_str, added_pkgs_str) # In pkgs are present, event can be applied + # Note: We do a .difference(event.out_packages) followed by an .union(event.out_packages) to overwrite + # # repositories of the packages (Package has overwritten __hash__ and __eq__) target_pkgs = target_pkgs.difference(event.in_pkgs) + target_pkgs = target_pkgs.difference(event.out_pkgs) target_pkgs = target_pkgs.union(event.out_pkgs) pkgs_to_demodularize = pkgs_to_demodularize.difference(event.in_pkgs) diff --git a/repos/system_upgrade/common/actors/peseventsscanner/tests/test_pes_event_scanner.py b/repos/system_upgrade/common/actors/peseventsscanner/tests/test_pes_event_scanner.py index 7cdcf82052..80ece77065 100644 --- a/repos/system_upgrade/common/actors/peseventsscanner/tests/test_pes_event_scanner.py +++ b/repos/system_upgrade/common/actors/peseventsscanner/tests/test_pes_event_scanner.py @@ -123,6 +123,15 @@ def pkgs_into_tuples(pkgs): [(8, 0)], {Package('renamed-out', 'rhel8-repo', None)} ), + ( + {Package('A', 'rhel7-repo', None), Package('B', 'rhel7-repo', None)}, + [ + Event(1, Action.SPLIT, {Package('A', 'rhel7-repo', None)}, + {Package('A', 'rhel8-repo', None), Package('B', 'rhel8-repo', None)}, (7, 6), (8, 0), []) + ], + [(8, 0)], + {Package('A', 'rhel8-repo', None), Package('B', 'rhel8-repo', None)} + ), ) ) def test_event_application_fundamentals(monkeypatch, installed_pkgs, events, releases, expected_target_pkgs):