Expand description
eclipse config migrate — bringing a config file forward without touching what its owner chose.
super::CONFIG_VERSION is stamped into the file, so this can tell how old it is. What it
cannot tell from the stamp alone is which lines a person edited, and that is the whole problem:
a file written by 0.9.0 has every key in it as a comment, and a file written by 0.10.0 has every
key live. Adding a key is safe. Changing a default is not — unless the file still holds the old
default, which is the same shape git’s merge uses: ours wins where it differs from base,
theirs wins where it does not.
So there are three inputs:
- ours — the file on disk, the one with the operator’s edits in it.
- base — the template this file was generated from, kept beside the state directory
(
baseline_path). Without it there is no way to tell “the operator chose 120” from “0.9.0 shipped 120”, so a missing baseline degrades to additions only and says so. - theirs —
super::starter_config(), what this build ships.
Six rules, in the order they matter:
- A key theirs sets and ours does not is added, at the shipped value.
- A key with no shipped value at all (a temperature, a cap) is added as a comment, which is how the file says “not in use” for a key whose off state has no spelling. That is what keeps the file complete without imposing anything.
- A key ours sets to exactly what base says, while theirs says something else, moves — the default changed and nobody chose the old one.
- A key ours set to anything else stays, whatever theirs says. This is the rule the whole thing exists for.
- A key in
RENAMEDis written under its new name and the old line is commented out, so the value survives a rename. The table is empty until there is a rename to record; the mechanism is here so the first one is a one-line change rather than a redesign. - Nothing is ever deleted. A key this build does not know is left exactly where it is —
eclipse config checknames it, and a migration that quietly drops a line someone typed is a migration nobody runs twice.
Every write goes through super::set_in_text, which edits one line of text and proves the
result loads, so comments, ordering and hand-written formatting survive. The file is copied to
<name>.bak before the first change, and the baseline is rewritten afterwards — the next
migration needs to know what this one shipped.
Structs§
- Plan
- The result of planning a migration: the text to write, and what it would do.
Enums§
- Change
- What a migration did to one key.
Constants§
- RENAMED
- Keys that moved.
(old path, new path).
Functions§
- baseline_
path - Where the template a file was generated from is kept:
<config dir>/state/config.baseline.toml. - plan
- Plan a migration. Pure: no files, no clock, no environment — the caller owns all three.
- plan_
with plan, with the rename table supplied — so a test can prove the mechanism with a pair that does not exist in this build.- write_
baseline - Record the template this build ships as the baseline for
config_path.