pub struct TreeDiff { /* private fields */ }diff only.Expand description
A diff of git trees, holding the ObjectIds of differing files
Implementations§
Source§impl TreeDiff
impl TreeDiff
Sourcepub async fn new<F: FileSystem>(
repo: &Repo<F>,
left: &Tree,
right: &Tree,
) -> GResult<Self>
pub async fn new<F: FileSystem>( repo: &Repo<F>, left: &Tree, right: &Tree, ) -> GResult<Self>
Construct a TreeDiff by diffing two trees
Sourcepub async fn new_cancelable<F: FileSystem>(
repo: &Repo<F>,
left: &Tree,
right: &Tree,
cancel: impl AsyncFnMut() -> bool,
) -> GResult<Self>
pub async fn new_cancelable<F: FileSystem>( repo: &Repo<F>, left: &Tree, right: &Tree, cancel: impl AsyncFnMut() -> bool, ) -> GResult<Self>
Construct a TreeDiff by diffing two trees
The cancel parameter is a function which may cancel the diff operation
by returning true at any point. It is called regularly while the diff
operation is running.
For example,
struct CancelableDiffFactory { canceled: Rc<Cell<bool>> }
impl CancelableDiffFactory {
pub async fn make_diff<F: FileSystem>(
&self,
repo: &Repo<F>,
left: &Tree,
right: &Tree
) -> GResult<TreeDiff> {
let canceled = self.canceled.clone();
let cancel = async move || canceled.get();
TreeDiff::new_cancelable(repo, left, right, cancel).await
}
pub fn cancel(&self) {
self.canceled.set(true);
}
}In this example, a diff operation may be started by some async routine,
and then canceled by another by calling the
CancelableDiffFactory::cancel method.
Sourcepub async fn to_text_diff<F: FileSystem>(&self, repo: &Repo<F>) -> GResult<Diff>
pub async fn to_text_diff<F: FileSystem>(&self, repo: &Repo<F>) -> GResult<Diff>
Sourcepub async fn to_text_diff_full<F: FileSystem>(
&self,
repo: &Repo<F>,
config: &TextDiffConfig,
cancel: impl AsyncFnMut() -> bool,
) -> GResult<Diff>
pub async fn to_text_diff_full<F: FileSystem>( &self, repo: &Repo<F>, config: &TextDiffConfig, cancel: impl AsyncFnMut() -> bool, ) -> GResult<Diff>
Like TreeDiff::to_text_diff but accepts a
similar::TextDiffConfig parameter to configure the file diff
operations and a cancel parameter to externally cancel the diff.
The cancel parameter is analogous to the cancel parameter on
TreeDiff::new_cancelable; see there for further details.