Skip to main content

Module reverse_merge

Module reverse_merge 

Source
Expand description

Reverse-merge engine — propagates deployed-file edits back to the template source.

Wraps burgertocow::generate_diff_with_markers and diffy::Patch into a single function that takes a template and the cached marker-annotated render (from the baseline cache) plus the current deployed text, and produces one of three outcomes:

  • ReverseMergeOutcome::Unchanged — pure data edit (only variable values changed). The template is correct as-is.
  • ReverseMergeOutcome::Patched — burgertocow produced a clean unified diff; the patched template content is returned for the caller to write back to the source file.
  • ReverseMergeOutcome::Conflict — burgertocow couldn’t safely attribute every edit to a static template line (typically because the edit overlaps a {{ var }} region). The conflict block string is returned for the caller to surface to the user; the template source is left alone.

§Why we don’t re-render here

The whole point of caching tracked_render in the baseline is that dodot transform check can compute reverse-diffs without invoking the template engine again. Re-rendering would re-trigger any secret-provider auth prompts in the variable context — auth fatigue that the magic.lex design specifically rules out. We rehydrate the cached tracked string via burgertocow::TrackedRender::from_tracked_string (added in burgertocow 0.3) and feed it into generate_diff_with_markers directly.

Enums§

ReverseMergeOutcome
Result of a reverse-merge attempt.

Functions§

reverse_merge
Compute a reverse-merge for one processed file.
reverse_merge_no_mask
Convenience for callers that haven’t loaded a secrets sidecar for this file (or are computing reverse-merge for a file that has no secret(...) calls). Equivalent to reverse_merge with an empty mask — burgertocow then behaves byte-identically to the pre-0.4 single-mask-less entry point.