Skip to main content

write_patches

Function write_patches 

pub fn write_patches(
    doc: &mut AutoCommit,
    patches: Vec<Patch>,
    insert_anchor: &[ChangeHash],
    index_anchor: &[ChangeHash],
)
Expand description

Write an already-derived patch set forward into doc’s open transaction.

The half of write_revert_patches after the diff, split out so a caller that already derived a full patch stream can reuse the index translation. Filtered history uses write_selected_patches to retain skipped structural steps in the logical index stream without changing their live content.

The two anchors bracket the change being inverted. index_anchor is the state the patches start from: the first patch into a sequence indexes it as of then, and each later one as the patches before it left it. insert_anchor is the state they lead to, whose formatting a recreated text object takes back. Passing them the wrong way round moves edits to the wrong elements, so both are named rather than positional.