pub fn apply_patch<F>(
tree: &FileTree,
patch: &Patch,
get_payload_blob: F,
) -> Result<FileTree, ApplyError>Expand description
Apply a single patch to a FileTree, producing a new FileTree.
§Operation Semantics
| Operation | Precondition | Effect |
|---|---|---|
| Create | Path must NOT exist | Insert path → blob hash |
| Modify | Path must exist | Update blob hash |
| Delete | Path must exist | Remove path |
| Move | Old path must exist, new must NOT | Rename |
| Metadata | Path must exist (if specified) | No tree change |
| Merge | N/A | No tree change (merge commits carry no payload) |
| Identity | N/A | No change |
§Arguments
tree- The current file tree statepatch- The patch to applyget_payload_blob- Function to resolve the patch payload to a CAS hash. For Modify/Create, the payload is a hex-encoded CAS hash; this function parses it and returns the actual hash.