-
-
Notifications
You must be signed in to change notification settings - Fork 652
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
Don't eagerly merge configs. #20459
Don't eagerly merge configs. #20459
Conversation
Merging the config values is incorrect for list- and dict-valued options, where we want to concatenate edits, not stomp them. For example, if for some list-valued option the default value is [0,1], config1 has -[0] and config2 has +[2,3] then the resulting value should be [1,2,3], but before this change it would have been [0,1,2,3].
config: Value, | ||
} | ||
|
||
impl ConfigSource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff looks scarier than it is. The meat of this change is the introduction of a ConfigSource, representing a single Config, and moving the generic get_value/get_list/get_dict logic to it unchanged. Then Config has a vec of these ConfigSources, and does the right thing.
The rest is just test and plumbing changes.
@@ -56,24 +56,46 @@ fn test_display() { | |||
} | |||
|
|||
#[test] | |||
fn test_section_overlap() { | |||
// Two files with the same section should result in merged content for that section. | |||
fn test_multiple_sources() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test has been enhanced to test more multiple source scenarios.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two nits that I think would really help readability, and one question. Looks good overall, but would be nice with a small cleanup.
Thanks for the review! |
Merging the config values is incorrect for list- and
dict-valued options, where we want to concatenate
edits, not stomp them.
For example, if for some list-valued option the default
value is [0,1], config1 has -[0] and config2 has +[2,3]
then the resulting value should be [1,2,3], but before
this change it would have been [0,1,2,3].
Instead, we preserve each config file as a separate
source, and do the appropriate stomping/merging
at option value get time.