Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pes_events_scanner: override repositories when applying an event #1194

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,11 @@ 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:
# First remove the package with the old repository and add it back, but now with the new
# repository. As the Package class has a custom __hash__ and __eq__ comparing only name
# and modulestream, the pkg.repository field is ignore and therefore the add() call
# does not update the entry.
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:
Expand All @@ -163,7 +166,11 @@ 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__, ignoring
# # the repository field)
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading