Commit d8131d8
authored
🐛 Don't mutate rebuild='env' src_trace_projects config during builds (#75)
## Summary
Incremental Sphinx builds always re-read every document, logging
`[config changed ('src_trace_projects')] N added, 0 changed, 0 removed`,
even
when nothing changed — incremental builds behave like full rebuilds.
`src_trace_projects` is registered with `rebuild="env"`, so Sphinx
pickles it
into `environment.pickle` and invalidates the environment whenever the
pickled
("old") value differs from the freshly computed ("new") one.
`generate_project_configs()` stores runtime `analyse_config` /
`source_discover_config` dataclass objects in that value; on their own
they
round-trip through pickle as `==`-equal.
The bug: the `src-trace` directive mutated the stored `analyse_config`
**in
place** during the build (`src_dir`, `src_files`, `git_root` set to
build-time,
resolved values). Those build-time values were persisted into the
pickle, while
the next build's `config-inited` produced a fresh `analyse_config`
(`src_files=[]`, `src_dir=Path(".")`), so the comparison always
differed:
| Side | `src_dir` | `src_files` |
|------|-----------|-------------|
| persisted (pickle, "old") | `/abs/.../dcdc` | `['demo_3.cpp', ...]` |
| fresh config-inited ("new") | `Path('.')` | `[]` |
## Fix
Operate on a per-directive `dataclasses.replace()` copy instead of
mutating the
`analyse_config` stored in the `rebuild="env"` config value. The stored
value
then stays equal to what `generate_project_configs()` yields, so
incremental
builds report `0 added, 0 changed, 0 removed`.
## Verification
- New regression test
`test_incremental_build_keeps_src_trace_projects_unchanged`
builds the fixture twice and asserts the 2nd (incremental) build sees
`CONFIG_OK` — fails before the fix (`CONFIG_CHANGED
('src_trace_projects')`),
passes after.
- Full suite: **207 passed**.
- Manual triple build: builds 2 & 3 now report `0 added, 0 changed, 0
removed`.
Fixes #741 parent c9e78da commit d8131d8
2 files changed
Lines changed: 66 additions & 5 deletions
Lines changed: 18 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
116 | | - | |
117 | | - | |
118 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
119 | 125 | | |
120 | | - | |
| 126 | + | |
| 127 | + | |
121 | 128 | | |
122 | 129 | | |
123 | 130 | | |
124 | 131 | | |
125 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
126 | 139 | | |
127 | 140 | | |
128 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
228 | 229 | | |
229 | 230 | | |
230 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
0 commit comments