mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-30 16:10:23 +00:00
rewrite: use MergedTree::diff_stream()
when restoring from tree
This commit is contained in:
parent
5b02987012
commit
6a5615c933
1 changed files with 10 additions and 3 deletions
|
@ -17,7 +17,9 @@
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use futures::StreamExt;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
use pollster::FutureExt;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::backend::{BackendError, BackendResult, CommitId, MergedTreeId, ObjectId};
|
use crate::backend::{BackendError, BackendResult, CommitId, MergedTreeId, ObjectId};
|
||||||
|
@ -83,10 +85,15 @@ pub fn restore_tree(
|
||||||
// TODO: We should be able to not traverse deeper in the diff if the matcher
|
// TODO: We should be able to not traverse deeper in the diff if the matcher
|
||||||
// matches an entire subtree.
|
// matches an entire subtree.
|
||||||
let mut tree_builder = MergedTreeBuilder::new(destination.id().clone());
|
let mut tree_builder = MergedTreeBuilder::new(destination.id().clone());
|
||||||
for (repo_path, diff) in source.diff(destination, matcher) {
|
async {
|
||||||
|
let mut diff_stream = source.diff_stream(destination, matcher);
|
||||||
|
while let Some((repo_path, diff)) = diff_stream.next().await {
|
||||||
let (source_value, _destination_value) = diff?;
|
let (source_value, _destination_value) = diff?;
|
||||||
tree_builder.set_or_remove(repo_path, source_value);
|
tree_builder.set_or_remove(repo_path, source_value);
|
||||||
}
|
}
|
||||||
|
Ok::<(), BackendError>(())
|
||||||
|
}
|
||||||
|
.block_on()?;
|
||||||
tree_builder.write_tree(destination.store())
|
tree_builder.write_tree(destination.store())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue