forked from mirrors/jj
copies: break method chaining in CopiesTreeDiffStream::poll_next()
So that it can be wrapped within a while loop + continue.
This commit is contained in:
parent
7684ab5994
commit
47ff9ad231
1 changed files with 21 additions and 23 deletions
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{ready, Context, Poll};
|
||||||
|
|
||||||
use futures::Stream;
|
use futures::Stream;
|
||||||
|
|
||||||
|
@ -121,28 +121,26 @@ impl Stream for CopiesTreeDiffStream<'_> {
|
||||||
type Item = CopiesTreeDiffEntry;
|
type Item = CopiesTreeDiffEntry;
|
||||||
|
|
||||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||||
self.inner.as_mut().poll_next(cx).map(|option| {
|
let Some(diff_entry) = ready!(self.inner.as_mut().poll_next(cx)) else {
|
||||||
option.map(|diff_entry| {
|
return Poll::Ready(None);
|
||||||
let Some(CopyRecord { source, .. }) =
|
};
|
||||||
self.copy_records.for_target(&diff_entry.path)
|
|
||||||
else {
|
|
||||||
return CopiesTreeDiffEntry {
|
|
||||||
source: diff_entry.path.clone(),
|
|
||||||
target: diff_entry.path,
|
|
||||||
value: diff_entry.value,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
CopiesTreeDiffEntry {
|
let Some(CopyRecord { source, .. }) = self.copy_records.for_target(&diff_entry.path) else {
|
||||||
source: source.clone(),
|
return Poll::Ready(Some(CopiesTreeDiffEntry {
|
||||||
target: diff_entry.path,
|
source: diff_entry.path.clone(),
|
||||||
value: diff_entry.value.and_then(|(_, target_value)| {
|
target: diff_entry.path,
|
||||||
self.source_tree
|
value: diff_entry.value,
|
||||||
.path_value(source)
|
}));
|
||||||
.map(|source_value| (source_value, target_value))
|
};
|
||||||
}),
|
|
||||||
}
|
Poll::Ready(Some(CopiesTreeDiffEntry {
|
||||||
})
|
source: source.clone(),
|
||||||
})
|
target: diff_entry.path,
|
||||||
|
value: diff_entry.value.and_then(|(_, target_value)| {
|
||||||
|
self.source_tree
|
||||||
|
.path_value(source)
|
||||||
|
.map(|source_value| (source_value, target_value))
|
||||||
|
}),
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue