Show More
@@ -186,7 +186,7 b" impl<'a> ChangedFiles<'a> {" | |||
|
186 | 186 | } |
|
187 | 187 | |
|
188 | 188 | /// Return an iterator over all the `Action` in this instance. |
|
189 |
fn iter_actions(&self, parent: |
|
|
189 | fn iter_actions(&self, parent: Parent) -> ActionsIterator { | |
|
190 | 190 | ActionsIterator { |
|
191 | 191 | changes: &self, |
|
192 | 192 | parent: parent, |
@@ -259,7 +259,7 b" impl<'a, A: Fn(Revision, Revision) -> bo" | |||
|
259 | 259 | |
|
260 | 260 | struct ActionsIterator<'a> { |
|
261 | 261 | changes: &'a ChangedFiles<'a>, |
|
262 |
parent: |
|
|
262 | parent: Parent, | |
|
263 | 263 | current: u32, |
|
264 | 264 | } |
|
265 | 265 | |
@@ -267,6 +267,10 b" impl<'a> Iterator for ActionsIterator<'a" | |||
|
267 | 267 | type Item = Action<'a>; |
|
268 | 268 | |
|
269 | 269 | fn next(&mut self) -> Option<Action<'a>> { |
|
270 | let copy_flag = match self.parent { | |
|
271 | Parent::FirstParent => P1_COPY, | |
|
272 | Parent::SecondParent => P2_COPY, | |
|
273 | }; | |
|
270 | 274 | while self.current < self.changes.nb_items { |
|
271 | 275 | let (flags, file, source) = self.changes.entry(self.current); |
|
272 | 276 | self.current += 1; |
@@ -274,10 +278,7 b" impl<'a> Iterator for ActionsIterator<'a" | |||
|
274 | 278 | return Some(Action::Removed(file)); |
|
275 | 279 | } |
|
276 | 280 | let copy = flags & COPY_MASK; |
|
277 |
if |
|
|
278 | return Some(Action::Copied(file, source)); | |
|
279 | } | |
|
280 | if self.parent == 2 && copy == P2_COPY { | |
|
281 | if copy == copy_flag { | |
|
281 | 282 | return Some(Action::Copied(file, source)); |
|
282 | 283 | } |
|
283 | 284 | } |
@@ -301,6 +302,15 b' pub struct DataHolder<D> {' | |||
|
301 | 302 | pub type RevInfoMaker<'a, D> = |
|
302 | 303 | Box<dyn for<'r> Fn(Revision, &'r mut DataHolder<D>) -> RevInfo<'r> + 'a>; |
|
303 | 304 | |
|
305 | /// enum used to carry information about the parent β child currently processed | |
|
306 | #[derive(Copy, Clone, Debug)] | |
|
307 | enum Parent { | |
|
308 | /// The `p1(x) β x` edge | |
|
309 | FirstParent, | |
|
310 | /// The `p2(x) β x` edge | |
|
311 | SecondParent, | |
|
312 | } | |
|
313 | ||
|
304 | 314 | /// Same as mercurial.copies._combine_changeset_copies, but in Rust. |
|
305 | 315 | /// |
|
306 | 316 | /// Arguments are: |
@@ -345,10 +355,10 b' pub fn combine_changeset_copies<A: Fn(Re' | |||
|
345 | 355 | let (p1, p2, changes) = rev_info(*child, &mut d); |
|
346 | 356 | |
|
347 | 357 | let parent = if rev == p1 { |
|
348 |
|
|
|
358 | Parent::FirstParent | |
|
349 | 359 | } else { |
|
350 | 360 | assert_eq!(rev, p2); |
|
351 |
|
|
|
361 | Parent::SecondParent | |
|
352 | 362 | }; |
|
353 | 363 | let mut new_copies = copies.clone(); |
|
354 | 364 | |
@@ -406,9 +416,8 b' pub fn combine_changeset_copies<A: Fn(Re' | |||
|
406 | 416 | } |
|
407 | 417 | Some(other_copies) => { |
|
408 | 418 | let (minor, major) = match parent { |
|
409 |
|
|
|
410 |
|
|
|
411 | _ => unreachable!(), | |
|
419 | Parent::FirstParent => (other_copies, new_copies), | |
|
420 | Parent::SecondParent => (new_copies, other_copies), | |
|
412 | 421 | }; |
|
413 | 422 | let merged_copies = |
|
414 | 423 | merge_copies_dict(minor, major, &changes, &mut oracle); |
General Comments 0
You need to be logged in to leave comments.
Login now