Show More
@@ -323,15 +323,6 b' pub struct DataHolder<D> {' | |||||
323 | pub type RevInfoMaker<'a, D> = |
|
323 | pub type RevInfoMaker<'a, D> = | |
324 | Box<dyn for<'r> Fn(Revision, &'r mut DataHolder<D>) -> RevInfo<'r> + 'a>; |
|
324 | Box<dyn for<'r> Fn(Revision, &'r mut DataHolder<D>) -> RevInfo<'r> + 'a>; | |
325 |
|
325 | |||
326 | /// enum used to carry information about the parent β child currently processed |
|
|||
327 | #[derive(Copy, Clone, Debug)] |
|
|||
328 | enum Parent { |
|
|||
329 | /// The `p1(x) β x` edge |
|
|||
330 | FirstParent, |
|
|||
331 | /// The `p2(x) β x` edge |
|
|||
332 | SecondParent, |
|
|||
333 | } |
|
|||
334 |
|
||||
335 | /// A small "tokenizer" responsible of turning full HgPath into lighter |
|
326 | /// A small "tokenizer" responsible of turning full HgPath into lighter | |
336 | /// PathToken |
|
327 | /// PathToken | |
337 | /// |
|
328 | /// | |
@@ -393,7 +384,6 b' pub fn combine_changeset_copies<D>(' | |||||
393 | // We will chain the copies information accumulated for the parent with |
|
384 | // We will chain the copies information accumulated for the parent with | |
394 | // the individual copies information the curent revision. Creating a |
|
385 | // the individual copies information the curent revision. Creating a | |
395 | // new TimeStampedPath for each `rev` β `children` vertex. |
|
386 | // new TimeStampedPath for each `rev` β `children` vertex. | |
396 | let mut copies: Option<InternalPathCopies> = None; |
|
|||
397 | // Retrieve data computed in a previous iteration |
|
387 | // Retrieve data computed in a previous iteration | |
398 | let p1_copies = match p1 { |
|
388 | let p1_copies = match p1 { | |
399 | NULL_REVISION => None, |
|
389 | NULL_REVISION => None, | |
@@ -412,26 +402,8 b' pub fn combine_changeset_copies<D>(' | |||||
412 | ), // will be None if the vertex is not to be traversed |
|
402 | ), // will be None if the vertex is not to be traversed | |
413 | }; |
|
403 | }; | |
414 | // combine it with data for that revision |
|
404 | // combine it with data for that revision | |
415 |
let p1_copies = |
|
405 | let (p1_copies, p2_copies) = | |
416 | None => None, |
|
406 | chain_changes(&mut path_map, p1_copies, p2_copies, &changes, rev); | |
417 | Some(parent_copies) => Some(add_from_changes( |
|
|||
418 | &mut path_map, |
|
|||
419 | &parent_copies, |
|
|||
420 | &changes, |
|
|||
421 | Parent::FirstParent, |
|
|||
422 | rev, |
|
|||
423 | )), |
|
|||
424 | }; |
|
|||
425 | let p2_copies = match p2_copies { |
|
|||
426 | None => None, |
|
|||
427 | Some(parent_copies) => Some(add_from_changes( |
|
|||
428 | &mut path_map, |
|
|||
429 | &parent_copies, |
|
|||
430 | &changes, |
|
|||
431 | Parent::SecondParent, |
|
|||
432 | rev, |
|
|||
433 | )), |
|
|||
434 | }; |
|
|||
435 | let copies = match (p1_copies, p2_copies) { |
|
407 | let copies = match (p1_copies, p2_copies) { | |
436 | (None, None) => None, |
|
408 | (None, None) => None, | |
437 | (c, None) => c, |
|
409 | (c, None) => c, | |
@@ -489,41 +461,47 b' fn get_and_clean_parent_copies(' | |||||
489 |
|
461 | |||
490 | /// Combine ChangedFiles with some existing PathCopies information and return |
|
462 | /// Combine ChangedFiles with some existing PathCopies information and return | |
491 | /// the result |
|
463 | /// the result | |
492 |
fn |
|
464 | fn chain_changes( | |
493 | path_map: &mut TwoWayPathMap, |
|
465 | path_map: &mut TwoWayPathMap, | |
494 |
base_copies: |
|
466 | base_p1_copies: Option<InternalPathCopies>, | |
|
467 | base_p2_copies: Option<InternalPathCopies>, | |||
495 | changes: &ChangedFiles, |
|
468 | changes: &ChangedFiles, | |
496 | parent: Parent, |
|
|||
497 | current_rev: Revision, |
|
469 | current_rev: Revision, | |
498 | ) -> InternalPathCopies { |
|
470 | ) -> (Option<InternalPathCopies>, Option<InternalPathCopies>) { | |
499 | let mut copies = base_copies.clone(); |
|
471 | // Fast path the "nothing to do" case. | |
|
472 | if let (None, None) = (&base_p1_copies, &base_p2_copies) { | |||
|
473 | return (None, None); | |||
|
474 | } | |||
|
475 | ||||
|
476 | let mut p1_copies = base_p1_copies.clone(); | |||
|
477 | let mut p2_copies = base_p2_copies.clone(); | |||
500 | for action in changes.iter_actions() { |
|
478 | for action in changes.iter_actions() { | |
501 | match action { |
|
479 | match action { | |
502 | Action::CopiedFromP1(path_dest, path_source) => { |
|
480 | Action::CopiedFromP1(path_dest, path_source) => { | |
503 |
match |
|
481 | match &mut p1_copies { | |
504 |
|
|
482 | None => (), // This is not a vertex we should proceed. | |
505 |
|
|
483 | Some(copies) => add_one_copy( | |
506 | current_rev, |
|
484 | current_rev, | |
507 | path_map, |
|
485 | path_map, | |
508 |
|
|
486 | copies, | |
509 |
|
|
487 | base_p1_copies.as_ref().unwrap(), | |
510 | path_dest, |
|
488 | path_dest, | |
511 | path_source, |
|
489 | path_source, | |
512 | ), |
|
490 | ), | |
513 |
} |
|
491 | } | |
514 | } |
|
492 | } | |
515 | Action::CopiedFromP2(path_dest, path_source) => { |
|
493 | Action::CopiedFromP2(path_dest, path_source) => { | |
516 |
match |
|
494 | match &mut p2_copies { | |
517 |
|
|
495 | None => (), // This is not a vertex we should proceed. | |
518 |
|
|
496 | Some(copies) => add_one_copy( | |
519 | current_rev, |
|
497 | current_rev, | |
520 | path_map, |
|
498 | path_map, | |
521 |
|
|
499 | copies, | |
522 |
|
|
500 | base_p2_copies.as_ref().unwrap(), | |
523 | path_dest, |
|
501 | path_dest, | |
524 | path_source, |
|
502 | path_source, | |
525 | ), |
|
503 | ), | |
526 |
} |
|
504 | } | |
527 | } |
|
505 | } | |
528 | Action::Removed(deleted_path) => { |
|
506 | Action::Removed(deleted_path) => { | |
529 | // We must drop copy information for removed file. |
|
507 | // We must drop copy information for removed file. | |
@@ -532,13 +510,26 b' fn add_from_changes(' | |||||
532 | // propagate this information when merging two |
|
510 | // propagate this information when merging two | |
533 | // InternalPathCopies object. |
|
511 | // InternalPathCopies object. | |
534 | let deleted = path_map.tokenize(deleted_path); |
|
512 | let deleted = path_map.tokenize(deleted_path); | |
535 | copies.entry(deleted).and_modify(|old| { |
|
513 | match &mut p1_copies { | |
536 |
|
|
514 | None => (), | |
537 |
|
|
515 | Some(copies) => { | |
|
516 | copies.entry(deleted).and_modify(|old| { | |||
|
517 | old.mark_delete(current_rev); | |||
|
518 | }); | |||
|
519 | } | |||
|
520 | }; | |||
|
521 | match &mut p2_copies { | |||
|
522 | None => (), | |||
|
523 | Some(copies) => { | |||
|
524 | copies.entry(deleted).and_modify(|old| { | |||
|
525 | old.mark_delete(current_rev); | |||
|
526 | }); | |||
|
527 | } | |||
|
528 | }; | |||
538 | } |
|
529 | } | |
539 | } |
|
530 | } | |
540 | } |
|
531 | } | |
541 | copies |
|
532 | (p1_copies, p2_copies) | |
542 | } |
|
533 | } | |
543 |
|
534 | |||
544 | // insert one new copy information in an InternalPathCopies |
|
535 | // insert one new copy information in an InternalPathCopies |
General Comments 0
You need to be logged in to leave comments.
Login now