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

Reland: Cleanup the logic for "merging" package "patches" #447

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

primeos-work
Copy link
Member

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 the config 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 the pkg.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 the patches have changed every time we merge another pkg.toml file.

Unfortunately this does currently require a dedicated source implementation (PkgTomlSource but actually why not) since config::File::from_str() always sets the URI/origin to None and the new set_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 custom Source implementation).

Signed-off-by: Michael Weiss michael.weiss@eviden.com
(cherry picked from commit c88bad4)

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 the `config` 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 the
`pkg.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 the `patches` have
changed every time we merge another `pkg.toml` file.

Unfortunately this does currently require a dedicated source
implementation (`PkgTomlSource` but actually why not) since
`config::File::from_str()` always sets the URI/origin to `None` and the
new `set_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
custom `Source` implementation).

[0]: https://github.com/mehcode/config-rs/blob/0.14.0/CHANGELOG.md#0140---2024-02-01

Signed-off-by: Michael Weiss <michael.weiss@eviden.com>
(cherry picked from commit c88bad4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant