Reland: Cleanup the logic for "merging" package "patches" #447
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a reland of c88bad4 which I had to revert in 01f2ff7 since we had to downgrade the
config
crate (4c6f027). The reland is possible since we could upgrade theconfig
crate to version 0.15 (9f05d6a) in the meantime. I cherry-picked c88bad4 but had to manually merge in the changes from 55920b5 and 97f0cee as well.See below for the original commit message:
The old logic was pretty complex and only necessary to build the correct relative paths to the patch files (the paths in
pkg.toml
must be prepended with the relative path to the directory containing thepkg.toml
file).Since the recently released version 0.14.0 of the
config
crate we can access the "origin" of a configuration value (Value::origin()
) so we can use that information to avoid having to check if thepatches
have changed every time we merge anotherpkg.toml
file.Unfortunately this does currently require a dedicated source implementation (
PkgTomlSource
but actually why not) sinceconfig::File::from_str()
always sets the URI/origin toNone
and the newset_patches_base_dir()
function is a bit of a hack... IMO the new code is much more readable, more efficient, and overall still cleaner though (most of the new code is for error handling and the customSource
implementation).Signed-off-by: Michael Weiss michael.weiss@eviden.com
(cherry picked from commit c88bad4)