| @@ -1,9 +1,9 @@ |
| 1 | 1 | use crate::{ |
| 2 | | − visit, |
| 3 | | − visit::{changes::Error::Cancelled, record::Change, TreeInfo, TreeInfoPair}, |
| 2 | + tree, |
| 3 | + tree::{changes::Error::Cancelled, visit::Change, TreeInfo, TreeInfoPair}, |
| 4 | 4 | }; |
| 5 | 5 | use git_hash::{oid, ObjectId}; |
| 6 | | −use git_object::{immutable, tree}; |
| 6 | +use git_object::immutable; |
| 7 | 7 | use quick_error::quick_error; |
| 8 | 8 | use std::{borrow::BorrowMut, collections::VecDeque}; |
| 9 | 9 | |
| @@ -24,8 +24,8 @@ quick_error! { · 14 unmodified lines |
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | | −impl<'a> visit::Changes<'a> { |
| 28 | | − /// Returns the changes that need to be applied to `self` to get `other`. |
| 27 | +impl<'a> tree::Changes<'a> { |
| 28 | + /// that need to be applied to `self` to get `other`. |
| 29 | 29 | /// TODO: Talk about choices in error handling and why Option<T> is enough, as opposed to the usual Result<Option<T>> |
| 30 | 30 | /// Talk about progress (done via delegate if needed) |
| 31 | 31 | /// |
| @@ -51,8 +51,8 @@ impl<'a> visit::Changes<'a> { · 19 unmodified lines |
| 51 | 51 | ) -> Result<(), Error> |
| 52 | 52 | where |
| 53 | 53 | LocateFn: for<'b> FnMut(&oid, &'b mut Vec<u8>) -> Option<immutable::tree::TreeIter<'b>>, |
| 54 | | − R: visit::Record, |
| 55 | | − StateMut: BorrowMut<visit::State<R::PathId>>, |
| 54 | + R: tree::Visit, |
| 55 | + StateMut: BorrowMut<tree::State<R::PathId>>, |
| 56 | 56 | { |
| 57 | 57 | let state = state.borrow_mut(); |
| 58 | 58 | state.clear(); |
| @@ -111,14 +111,14 @@ impl<'a> visit::Changes<'a> { · 52 unmodified lines |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | | −fn delete_entry_schedule_recursion<R: visit::Record>( |
| 114 | +fn delete_entry_schedule_recursion<R: tree::Visit>( |
| 115 | 115 | entry: immutable::tree::Entry<'_>, |
| 116 | 116 | queue: &mut VecDeque<TreeInfoPair<R::PathId>>, |
| 117 | 117 | delegate: &mut R, |
| 118 | 118 | ) -> Result<(), Error> { |
| 119 | 119 | delegate.push_path_component(entry.filename); |
| 120 | 120 | if delegate |
| 121 | | − .record(Change::Deletion { |
| 121 | + .visit(Change::Deletion { |
| 122 | 122 | entry_mode: entry.mode, |
| 123 | 123 | oid: entry.oid.to_owned(), |
| 124 | 124 | }) |
| @@ -140,14 +140,14 @@ fn delete_entry_schedule_recursion<R: visit::Record>( · 15 unmodified lines |
| 140 | 140 | Ok(()) |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | | −fn add_entry_schedule_recursion<R: visit::Record>( |
| 143 | +fn add_entry_schedule_recursion<R: tree::Visit>( |
| 144 | 144 | entry: immutable::tree::Entry<'_>, |
| 145 | 145 | queue: &mut VecDeque<TreeInfoPair<R::PathId>>, |
| 146 | 146 | delegate: &mut R, |
| 147 | 147 | ) -> Result<(), Error> { |
| 148 | 148 | delegate.push_path_component(entry.filename); |
| 149 | 149 | if delegate |
| 150 | | − .record(Change::Addition { |
| 150 | + .visit(Change::Addition { |
| 151 | 151 | entry_mode: entry.mode, |
| 152 | 152 | oid: entry.oid.to_owned(), |
| 153 | 153 | }) |
| @@ -168,7 +168,7 @@ fn add_entry_schedule_recursion<R: visit::Record>( · 14 unmodified lines |
| 168 | 168 | } |
| 169 | 169 | Ok(()) |
| 170 | 170 | } |
| 171 | | −fn catchup_rhs_with_lhs<R: visit::Record>( |
| 171 | +fn catchup_rhs_with_lhs<R: tree::Visit>( |
| 172 | 172 | rhs_entries: &mut IteratorType<immutable::TreeIter<'_>>, |
| 173 | 173 | lhs: immutable::tree::Entry<'_>, |
| 174 | 174 | rhs: immutable::tree::Entry<'_>, |
| @@ -208,7 +208,7 @@ fn catchup_rhs_with_lhs<R: visit::Record>( · 33 unmodified lines |
| 208 | 208 | Ok(()) |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | | −fn catchup_lhs_with_rhs<R: visit::Record>( |
| 211 | +fn catchup_lhs_with_rhs<R: tree::Visit>( |
| 212 | 212 | lhs_entries: &mut IteratorType<immutable::TreeIter<'_>>, |
| 213 | 213 | lhs: immutable::tree::Entry<'_>, |
| 214 | 214 | rhs: immutable::tree::Entry<'_>, |
| @@ -248,19 +248,19 @@ fn catchup_lhs_with_rhs<R: visit::Record>( · 33 unmodified lines |
| 248 | 248 | Ok(()) |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | | −fn handle_lhs_and_rhs_with_equal_filenames<R: visit::Record>( |
| 251 | +fn handle_lhs_and_rhs_with_equal_filenames<R: tree::Visit>( |
| 252 | 252 | lhs: immutable::tree::Entry<'_>, |
| 253 | 253 | rhs: immutable::tree::Entry<'_>, |
| 254 | 254 | queue: &mut VecDeque<TreeInfoPair<R::PathId>>, |
| 255 | 255 | delegate: &mut R, |
| 256 | 256 | ) -> Result<(), Error> { |
| 257 | | − use tree::EntryMode::*; |
| 257 | + use git_object::tree::EntryMode::*; |
| 258 | 258 | match (lhs.mode, rhs.mode) { |
| 259 | 259 | (Tree, Tree) => { |
| 260 | 260 | let path_id = delegate.push_tracked_path_component(lhs.filename); |
| 261 | 261 | if lhs.oid != rhs.oid |
| 262 | 262 | && delegate |
| 263 | | − .record(Change::Modification { |
| 263 | + .visit(Change::Modification { |
| 264 | 264 | previous_entry_mode: lhs.mode, |
| 265 | 265 | previous_oid: lhs.oid.to_owned(), |
| 266 | 266 | entry_mode: rhs.mode, |
| @@ -284,7 +284,7 @@ fn handle_lhs_and_rhs_with_equal_filenames<R: visit::Record>( · 17 unmodified lines |
| 284 | 284 | (lhs_mode, Tree) if lhs_mode.is_no_tree() => { |
| 285 | 285 | let path_id = delegate.push_tracked_path_component(lhs.filename); |
| 286 | 286 | if delegate |
| 287 | | − .record(Change::Deletion { |
| 287 | + .visit(Change::Deletion { |
| 288 | 288 | entry_mode: lhs.mode, |
| 289 | 289 | oid: lhs.oid.to_owned(), |
| 290 | 290 | }) |
| @@ -293,7 +293,7 @@ fn handle_lhs_and_rhs_with_equal_filenames<R: visit::Record>( · 2 unmodified lines |
| 293 | 293 | return Err(Cancelled); |
| 294 | 294 | }; |
| 295 | 295 | if delegate |
| 296 | | − .record(Change::Addition { |
| 296 | + .visit(Change::Addition { |
| 297 | 297 | entry_mode: rhs.mode, |
| 298 | 298 | oid: rhs.oid.to_owned(), |
| 299 | 299 | }) |
| @@ -312,7 +312,7 @@ fn handle_lhs_and_rhs_with_equal_filenames<R: visit::Record>( · 12 unmodified lines |
| 312 | 312 | (Tree, rhs_mode) if rhs_mode.is_no_tree() => { |
| 313 | 313 | let path_id = delegate.push_tracked_path_component(lhs.filename); |
| 314 | 314 | if delegate |
| 315 | | − .record(Change::Deletion { |
| 315 | + .visit(Change::Deletion { |
| 316 | 316 | entry_mode: lhs.mode, |
| 317 | 317 | oid: lhs.oid.to_owned(), |
| 318 | 318 | }) |
| @@ -321,7 +321,7 @@ fn handle_lhs_and_rhs_with_equal_filenames<R: visit::Record>( · 2 unmodified lines |
| 321 | 321 | return Err(Error::Cancelled); |
| 322 | 322 | } |
| 323 | 323 | if delegate |
| 324 | | − .record(Change::Addition { |
| 324 | + .visit(Change::Addition { |
| 325 | 325 | entry_mode: rhs.mode, |
| 326 | 326 | oid: rhs.oid.to_owned(), |
| 327 | 327 | }) |
| @@ -342,7 +342,7 @@ fn handle_lhs_and_rhs_with_equal_filenames<R: visit::Record>( · 14 unmodified lines |
| 342 | 342 | debug_assert!(lhs_non_tree.is_no_tree() && rhs_non_tree.is_no_tree()); |
| 343 | 343 | if lhs.oid != rhs.oid |
| 344 | 344 | && delegate |
| 345 | | − .record(Change::Modification { |
| 345 | + .visit(Change::Modification { |
| 346 | 346 | previous_entry_mode: lhs.mode, |
| 347 | 347 | previous_oid: lhs.oid.to_owned(), |
| 348 | 348 | entry_mode: rhs.mode, |