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

Repoquery: Add --duplicates option #178

Merged
merged 2 commits into from Nov 30, 2022

Conversation

kontura
Copy link
Contributor

@kontura kontura commented Nov 29, 2022

Adds filter_duplicates() method to PackageQuery.

For: #122

Tests: rpm-software-management/ci-dnf-stack#1187

for (int pos_second = start_block; pos_second < stop_block; ++pos_second) {
Id id_second = samename[pos_second];
s_second = pool.id2solvable(id_second);
if ((s_first->evr == s_second->evr) && (s_first->arch != s_second->arch)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All packages in the block should have the same arch. Why is && (s_first->arch != s_second->arch) needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not, I forgot that the arch check was moved. 👍 👍

Since thanks to your other suggestion we no longer compare each solvable to it self I think we can drop the condition entirely. If there somehow was a package installed twice with the same name, arch and even evr I think we would want it in the query. Packages with the same nevra but different id surely are duplicates in general for the filter_duplices().

What do you think?

for (int pos_first = start_block; pos_first < stop_block; ++pos_first) {
Id id_first = samename[pos_first];
s_first = pool.id2solvable(id_first);
for (int pos_second = start_block; pos_second < stop_block; ++pos_second) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You compare each couple of solvables twice (i.e. pkgA with pkgB and than pkgB with pkgA again). I think you can start the inner cycle with for (int pos_second = pos_first.... Or even pos_second = pos_first + 1 to avoid comparison of solvable with itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thank you!

@kontura kontura force-pushed the repoquery_duplicates branch 2 times, most recently from 81ae48c to 9ef25f8 Compare November 30, 2022 11:34
Copy link
Member

@m-blaha m-blaha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

@m-blaha m-blaha merged commit 719f468 into rpm-software-management:main Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants