debian_analyzer

Function apply_or_revert

Source
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 tree
  • subpath - Subpath to apply changes to
  • basis_tree - Basis tree to reset to
  • dirty_tracker - Dirty tracker
  • applier - 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