#!/usr/bin/env python3 """Engine split, step 5: `Session` state. The action recording and playback state left `ActionState` (`s.actions`) for the core type `ActionRecording` (`s.recording`); the journal mark `recording` is called `target` there. Small state types moved to `crates/engine-core/src/state.rs` (their old paths are re-exported), the action-history bookkeeping to `action_history.rs`, and the stored-preferences document with the methods that combine preferences, colour settings and presets to `prefs/saved.rs`. `Clip::from_svg` is the free function `edit_cmds::clip_from_svg`, and the preset store is a session slot read through `preset_store::PresetStoreExt` (`s.preset_store()`, `s.preset_store_mut()`). python3 scripts/engine_split/session_state.py split Rewrites every Rust file under `crates/` and `apps/`: the recording fields, `Clip::from_svg` and the preset store field. The rest of the step (type moves, slots, hooks) is hand-written, its own commit. python3 scripts/engine_split/session_state.py branch --base --head On a branch rebased onto the step. `--head` is the branch commit from before the rebase (`ORIG_HEAD` right after it). Rewrites the files the branch changed, and lists the branch's edits to definitions that moved (re-apply those in the new file). Running either mode twice gives the same result. What it cannot do is printed at the end of every run. """ import argparse, os, re, sys sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from rust_source import edited_definitions, git # noqa: E402 FIELDS = ["record_tools", "recording", "take", "playing", "playback_stack", "playback_steps", "budget_shared", "batch_depth", "script_depth", "script_steps"] RENAMED = {"recording": "target"} RECORDING = re.compile(r"\.actions\.(" + "|".join(FIELDS) + r")\b") FROM_SVG = re.compile(r"\bedit_cmds::Clip::from_svg\(") BARE_FROM_SVG = re.compile(r"(?` now; - a file that now calls `preset_store()` / `preset_store_mut()` needs `use photocraft_engine::preset_store::PresetStoreExt;` (`crate::preset_store::...` in core); - an assignment to the old field (`s.preset_store = Some(store)`): attach a store with `Session::attach_preset_store`, which keeps it in the preset store slot; - edits to a moved definition: re-apply them in the new file named above; - a new `Session` field: a plain core field when the pipeline reads it, else a slot its crate registers (`Install::slot`, read through the crate's extension trait). """ def main(): ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) sub = ap.add_subparsers(dest="mode", required=True) sub.add_parser("split") b = sub.add_parser("branch") b.add_argument("--base", required=True) b.add_argument("--head", required=True) args = ap.parse_args() os.chdir(git("rev-parse", "--show-toplevel").strip()) if args.mode == "split": split() else: branch(args.base, args.head) for line in REPORT: print(line) print(CANNOT_DO) if __name__ == "__main__": main()