Skip to content

Conversation

@nevans
Copy link
Collaborator

@nevans nevans commented Nov 6, 2025

Grouping defaults by version and putting them all together at the bottom has almost guaranteed merge conflicts whenever a feature branch rebased or a backport branch is cherry-picked.

At the cost of one final merge conflict per branch, this should significantly reduce future merge conflicts in the config file. It's also easier to match documentation with default values when they're right next to each other.

This will be used to simplify the code in lib/net/imap/config.rb.
In this first step, only a couple pieces are extracted:
* `AttrVersionDefaults` stores the `Config.version_defaults` hash.
  The hash's `#default_proc` is defined there, too.
* `AttrVersionDefaults.compile` only freezes that hash.
This refactoring decouples the assignment of versioned default values
and the creation of `version_defaults` config objects.  At first,
`version_defaults` stores hashes for each version's updated defaults.
At the end, the hashes are transformed into config objects by
`Config::AttrVersionDefaults.compile!`.
This also causes Config[0.7r] through Config[1.0r] to be aliases (rather
than clones) of each other.
This avoids usage of the private `Config#defaults_hash` method, relying
instead on the public `#load_defaults` API.
At the cost of one big conflict now, this should significantly reduce
future merge conflicts in the config file.  It's also easier to match
documentation with default values when they're right next to each other.

This also assigns all of the original (`Config[0]`) defaults explicitly,
and not only where they differ from Config.default.
Similar to the versioned defaults, this could be a source of conflicts
when merging, rebasing, or cherry-picking feature and backport branches.
Now that all of the attributes specify their defaults, the current
version's default config can be compiled from that.

The sanity-check at the end of `config.rb` has been removed.  It was
there to protect against bad merges.  Now that `Config.default` is also
compiled from the version defaults added to each attr_accessor, the
tests in `test/net/imap/test_config.rb` are good enough.
@nevans
Copy link
Collaborator Author

nevans commented Nov 9, 2025

@nevans nevans merged commit 61b2e4d into master Nov 9, 2025
30 of 32 checks passed
@nevans nevans deleted the config/defaults branch November 9, 2025 19:26
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.

2 participants