Skip to content

Commit

Permalink
pes_events_scanner: override repositories when applying an event
Browse files Browse the repository at this point in the history
The Package class has custom __hash__ and __eq__ methods in order to
achieve a straightforward presentation via set manipulation. However,
this causes problems, e.g., when applying split events. For example:
Applying the event Split(in={(A, repo1)}, out={(A, repo2), (B, repo2)})
to the package state {(A, repo1), (B, repo1)} results in the following:
  {(A, repo1), (B, repo1)} --apply--> {(A, repo2), (B, repo1)}
which is undesired as repo1 is a source system repository. Such
a package will get reported to the user as potentially removed during
the upgrade. This patch addresses this unwanted behavior.
  • Loading branch information
mhecko committed Apr 2, 2024
1 parent b65ef94 commit 549998a
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit 549998a

Please sign in to comment.