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