The idea is that conflicts often involve packages that simply need to be rebuilt, so it would be nice to have an option to trigger the rebuild automatically.
In order to solve blockers, some packages may need to be removed rather than rebuilt or upgraded, and for these packages some alternative to the existing @__auto_slot_operator_replace_installed__ set will be needed.
(In reply to Zac Medico from comment #1) > In order to solve blockers, some packages may need to be removed rather than > rebuilt or upgraded, and for these packages some alternative to the existing > @__auto_slot_operator_replace_installed__ set will be needed. The existing package.mask behavior is close to the desired behavior for @__auto_slot_operator_replace_installed__, since package.mask is effective for operations like replacing pycrypto with pycryptodome. Also, package.mask allows for fallback to the installed instance when no other option is available. We may be need a mechanism to eliminate unnecessary rebuilds, like this code from bug 439688: https://gitweb.gentoo.org/proj/portage.git/commit/?id=222dfa56e8fb311f4bea54012bdfd5d1a474d56c
I have experimented with using the slot_operator_mask_built backtracking info to trigger rebuilds when necessary. Very few changes were necessary, and I was able to get all existing unit tests to pass. The depgraph._complete_graph method pulls a given rebuild into the graph only if it's reachable from @world. The _complete_graph package selection configuration only chooses from the packages that are already installed or in the graph. It needs to be fixed to use the appropriate package selection configuration for packages that are intended to be rebuilt (this also applies to installed packages when we need to uninstall packages in order to solve conflicts, like when transitioning installed packages to use pycryptodome instead of pycrypto).
During _complete_graph execution, package selection rules need to be like this: Default behavior is to select packages only from those that are already installed or have already been added to the graph. Enable all available package sources if any of the following is true: 1) The parent package is not installed yet. 2) The current atom matches a package tagged for rebuild via backtrack parameters.
Also, if the parent package is already installed and has a disjunctive dependency group (|| dep) where a package tagged for rebuild is among the choices, then enable all available package sources for all choices in the disjunctive dependency group. This is needed for cases where a package tagged for rebuild (or possible removal) needs to be removed, and disjunctive dependency groups that this package had previously satisfied need to be re-evaluated.