Showing the changes to git-diff/src (1 of 2 files). Show all
Unified · Split
| @@ -37,6 +37,7 @@ impl<'a> visit::Changes<'a> { · 36 unmodified lines | ||
| 37 | 37 | /// * it does a breadth first iteration as buffer space only fits two trees, the current one on the one we compare with. |
| 38 | 38 | /// * does not do rename tracking but attempts to reduce allocations to zero (so performance is mostly determined |
| 39 | 39 | /// by the delegate implementation which should be as specific as possible. |
| 40 | + /// * cycle checking is not performed, but can be performed in the delegate | |
| 40 | 41 | pub fn needed_to_obtain<LocateFn, R>( |
| 41 | 42 | mut self, |
| 42 | 43 | other: immutable::TreeIter<'a>, |
| @@ -58,15 +59,27 @@ impl<'a> visit::Changes<'a> { · 15 unmodified lines | ||
| 58 | 59 | delegate.pop_path_component(); |
| 59 | 60 | } |
| 60 | 61 | match (lhs_entries.next(), rhs_entries.next()) { |
| 61 | − (None, None) => match state.trees.pop_front() { | |
| 62 | − Some((None, Some(rhs))) => { | |
| 63 | − delegate.set_current_path(rhs.parent_path_id.clone()); | |
| 64 | − rhs_entries = locate(&rhs.tree_id, &mut state.buf2).ok_or(Error::NotFound(rhs.tree_id))?; | |
| 65 | − avoid_popping_path = Some(()); | |
| 66 | − } | |
| 67 | − None => return Ok(()), | |
| 68 | − _ => todo!("all other combinations to re-stock iterators"), | |
| 69 | − }, | |
| 62 | + (None, None) => { | |
| 63 | + match state.trees.pop_front() { | |
| 64 | + Some((None, Some(rhs))) => { | |
| 65 | + delegate.set_current_path(rhs.parent_path_id.clone()); | |
| 66 | + rhs_entries = locate(&rhs.tree_id, &mut state.buf2).ok_or(Error::NotFound(rhs.tree_id))?; | |
| 67 | + } | |
| 68 | + Some((Some(lhs), Some(rhs))) => { | |
| 69 | + delegate.set_current_path(lhs.parent_path_id.clone()); | |
| 70 | + lhs_entries = locate(&lhs.tree_id, &mut state.buf1).ok_or(Error::NotFound(lhs.tree_id))?; | |
| 71 | + rhs_entries = locate(&rhs.tree_id, &mut state.buf2).ok_or(Error::NotFound(rhs.tree_id))?; | |
| 72 | + } | |
| 73 | + Some((Some(_lhs), None)) => { | |
| 74 | + todo!("locate none|tree"); | |
| 75 | + // delegate.set_current_path(lhs.parent_path_id.clone()); | |
| 76 | + // lhs_entries = locate(&lhs.tree_id, &mut state.buf1).ok_or(Error::NotFound(lhs.tree_id))?; | |
| 77 | + } | |
| 78 | + Some((None, None)) => unreachable!("BUG: it makes no sense to fill the stack with empties"), | |
| 79 | + None => return Ok(()), | |
| 80 | + }; | |
| 81 | + avoid_popping_path = Some(()); | |
| 82 | + } | |
| 70 | 83 | (Some(lhs), Some(rhs)) => { |
| 71 | 84 | use std::cmp::Ordering::*; |
| 72 | 85 | let (lhs, rhs) = (lhs?, rhs?); |
| @@ -75,7 +88,7 @@ impl<'a> visit::Changes<'a> { · 2 unmodified lines | ||
| 75 | 88 | use tree::EntryMode::*; |
| 76 | 89 | match (lhs.mode, rhs.mode) { |
| 77 | 90 | (Tree, Tree) => { |
| 78 | − let _path_id = delegate.push_tracked_path_component(lhs.filename); | |
| 91 | + let path_id = delegate.push_tracked_path_component(lhs.filename); | |
| 79 | 92 | if lhs.oid != rhs.oid |
| 80 | 93 | && delegate |
| 81 | 94 | .record(Change::Modification { |
| @@ -88,7 +101,16 @@ impl<'a> visit::Changes<'a> { · 6 unmodified lines | ||
| 88 | 101 | { |
| 89 | 102 | return Err(Cancelled); |
| 90 | 103 | } |
| 91 | − todo!("schedule tree|tree iteration schedule the trees with stack") | |
| 104 | + state.trees.push_back(( | |
| 105 | + Some(TreeInfo { | |
| 106 | + tree_id: lhs.oid.to_owned(), | |
| 107 | + parent_path_id: path_id.clone(), | |
| 108 | + }), | |
| 109 | + Some(TreeInfo { | |
| 110 | + tree_id: rhs.oid.to_owned(), | |
| 111 | + parent_path_id: path_id, | |
| 112 | + }), | |
| 113 | + )); | |
| 92 | 114 | } |
| 93 | 115 | (lhs_mode, Tree) if lhs_mode.is_no_tree() => { |
| 94 | 116 | let path_id = delegate.push_tracked_path_component(lhs.filename); |