pub fn apply_or_revert<R, E>(
local_tree: &WorkingTree,
subpath: &Path,
basis_tree: &dyn Tree,
dirty_tracker: Option<&mut DirtyTreeTracker>,
applier: impl FnOnce(&Path) -> Result<R, E>,
) -> Result<(R, Vec<TreeChange>, Option<Vec<PathBuf>>), ApplyError<R, E>>Expand description
Apply a change in a clean tree.
This will either run a callback in a tree, or if the callback fails, revert the tree to the original state.
The original tree should be clean; you can run check_clean_tree() to verify this.
§Arguments
local_tree- Local treesubpath- Subpath to apply changes tobasis_tree- Basis tree to reset todirty_tracker- Dirty trackerapplier- Callback to apply changes
§Returns
Result<(R, Vec<TreeChange>, Option<Vec<std::path::PathBuf>>), E>- Result of the callback, the changes made, and the files that were changed