History

[tree-diff] test modification within a directory

Sebastian Thiel committed 5 years ago

Commit ff82a821 parent c223e312 files · +71 −19Browse files

Showing the changes to git-diff/src (1 of 2 files). Show all

Unified · Split

git-diff/src/visit/changes.rs+33−11
@@ -37,6 +37,7 @@ impl<'a> visit::Changes<'a> { · 36 unmodified lines
37 /// * it does a breadth first iteration as buffer space only fits two trees, the current one on the one we compare with.37 /// * it does a breadth first iteration as buffer space only fits two trees, the current one on the one we compare with.
38 /// * does not do rename tracking but attempts to reduce allocations to zero (so performance is mostly determined38 /// * does not do rename tracking but attempts to reduce allocations to zero (so performance is mostly determined
39 /// by the delegate implementation which should be as specific as possible.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 pub fn needed_to_obtain<LocateFn, R>(41 pub fn needed_to_obtain<LocateFn, R>(
41 mut self,42 mut self,
42 other: immutable::TreeIter<'a>,43 other: immutable::TreeIter<'a>,
@@ -58,15 +59,27 @@ impl<'a> visit::Changes<'a> { · 15 unmodified lines
58 delegate.pop_path_component();59 delegate.pop_path_component();
59 }60 }
60 match (lhs_entries.next(), rhs_entries.next()) {61 match (lhs_entries.next(), rhs_entries.next()) {
61 (None, None) => match state.trees.pop_front() {62 (None, None) => {
62 Some((None, Some(rhs))) => {63 match state.trees.pop_front() {
63 delegate.set_current_path(rhs.parent_path_id.clone());64 Some((None, Some(rhs))) => {
64 rhs_entries = locate(&rhs.tree_id, &mut state.buf2).ok_or(Error::NotFound(rhs.tree_id))?;65 delegate.set_current_path(rhs.parent_path_id.clone());
65 avoid_popping_path = Some(());66 rhs_entries = locate(&rhs.tree_id, &mut state.buf2).ok_or(Error::NotFound(rhs.tree_id))?;
66 }67 }
67 None => return Ok(()),68 Some((Some(lhs), Some(rhs))) => {
68 _ => todo!("all other combinations to re-stock iterators"),69 delegate.set_current_path(lhs.parent_path_id.clone());
69 },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 (Some(lhs), Some(rhs)) => {83 (Some(lhs), Some(rhs)) => {
71 use std::cmp::Ordering::*;84 use std::cmp::Ordering::*;
72 let (lhs, rhs) = (lhs?, rhs?);85 let (lhs, rhs) = (lhs?, rhs?);
@@ -75,7 +88,7 @@ impl<'a> visit::Changes<'a> { · 2 unmodified lines
75 use tree::EntryMode::*;88 use tree::EntryMode::*;
76 match (lhs.mode, rhs.mode) {89 match (lhs.mode, rhs.mode) {
77 (Tree, Tree) => {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 if lhs.oid != rhs.oid92 if lhs.oid != rhs.oid
80 && delegate93 && delegate
81 .record(Change::Modification {94 .record(Change::Modification {
@@ -88,7 +101,16 @@ impl<'a> visit::Changes<'a> { · 6 unmodified lines
88 {101 {
89 return Err(Cancelled);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 (lhs_mode, Tree) if lhs_mode.is_no_tree() => {115 (lhs_mode, Tree) if lhs_mode.is_no_tree() => {
94 let path_id = delegate.push_tracked_path_component(lhs.filename);116 let path_id = delegate.push_tracked_path_component(lhs.filename);