##// END OF EJS Templates
copies-rust: rename TimeStampedPathCopies to InternalPathCopies...
marmoute -
r47311:313610be default
parent child Browse files
Show More
@@ -25,7 +25,7 b' struct TimeStampedPathCopy {'
25 }
25 }
26
26
27 /// maps CopyDestination to Copy Source (+ a "timestamp" for the operation)
27 /// maps CopyDestination to Copy Source (+ a "timestamp" for the operation)
28 type TimeStampedPathCopies = OrdMap<PathToken, TimeStampedPathCopy>;
28 type InternalPathCopies = OrdMap<PathToken, TimeStampedPathCopy>;
29
29
30 /// hold parent 1, parent 2 and relevant files actions.
30 /// hold parent 1, parent 2 and relevant files actions.
31 pub type RevInfo<'a> = (Revision, Revision, ChangedFiles<'a>);
31 pub type RevInfo<'a> = (Revision, Revision, ChangedFiles<'a>);
@@ -382,7 +382,7 b' pub fn combine_changeset_copies<A: Fn(Re'
382 // We will chain the copies information accumulated for the parent with
382 // We will chain the copies information accumulated for the parent with
383 // the individual copies information the curent revision. Creating a
383 // the individual copies information the curent revision. Creating a
384 // new TimeStampedPath for each `rev` β†’ `children` vertex.
384 // new TimeStampedPath for each `rev` β†’ `children` vertex.
385 let mut copies: Option<TimeStampedPathCopies> = None;
385 let mut copies: Option<InternalPathCopies> = None;
386 if p1 != NULL_REVISION {
386 if p1 != NULL_REVISION {
387 // Retrieve data computed in a previous iteration
387 // Retrieve data computed in a previous iteration
388 let parent_copies = get_and_clean_parent_copies(
388 let parent_copies = get_and_clean_parent_copies(
@@ -471,21 +471,21 b' pub fn combine_changeset_copies<A: Fn(Re'
471 ///
471 ///
472 /// If parent is not part of the set we are expected to walk, return None.
472 /// If parent is not part of the set we are expected to walk, return None.
473 fn get_and_clean_parent_copies(
473 fn get_and_clean_parent_copies(
474 all_copies: &mut HashMap<Revision, TimeStampedPathCopies>,
474 all_copies: &mut HashMap<Revision, InternalPathCopies>,
475 children_count: &mut HashMap<Revision, usize>,
475 children_count: &mut HashMap<Revision, usize>,
476 parent_rev: Revision,
476 parent_rev: Revision,
477 ) -> Option<TimeStampedPathCopies> {
477 ) -> Option<InternalPathCopies> {
478 let count = children_count.get_mut(&parent_rev)?;
478 let count = children_count.get_mut(&parent_rev)?;
479 *count -= 1;
479 *count -= 1;
480 if *count == 0 {
480 if *count == 0 {
481 match all_copies.remove(&parent_rev) {
481 match all_copies.remove(&parent_rev) {
482 Some(c) => Some(c),
482 Some(c) => Some(c),
483 None => Some(TimeStampedPathCopies::default()),
483 None => Some(InternalPathCopies::default()),
484 }
484 }
485 } else {
485 } else {
486 match all_copies.get(&parent_rev) {
486 match all_copies.get(&parent_rev) {
487 Some(c) => Some(c.clone()),
487 Some(c) => Some(c.clone()),
488 None => Some(TimeStampedPathCopies::default()),
488 None => Some(InternalPathCopies::default()),
489 }
489 }
490 }
490 }
491 }
491 }
@@ -495,11 +495,11 b' fn get_and_clean_parent_copies('
495 fn add_from_changes<A: Fn(Revision, Revision) -> bool>(
495 fn add_from_changes<A: Fn(Revision, Revision) -> bool>(
496 path_map: &mut TwoWayPathMap,
496 path_map: &mut TwoWayPathMap,
497 oracle: &mut AncestorOracle<A>,
497 oracle: &mut AncestorOracle<A>,
498 base_copies: &TimeStampedPathCopies,
498 base_copies: &InternalPathCopies,
499 changes: &ChangedFiles,
499 changes: &ChangedFiles,
500 parent: Parent,
500 parent: Parent,
501 current_rev: Revision,
501 current_rev: Revision,
502 ) -> TimeStampedPathCopies {
502 ) -> InternalPathCopies {
503 let mut copies = base_copies.clone();
503 let mut copies = base_copies.clone();
504 for action in changes.iter_actions(parent) {
504 for action in changes.iter_actions(parent) {
505 match action {
505 match action {
@@ -540,7 +540,7 b' fn add_from_changes<A: Fn(Revision, Revi'
540 //
540 //
541 // We need to explicitly record them as dropped to
541 // We need to explicitly record them as dropped to
542 // propagate this information when merging two
542 // propagate this information when merging two
543 // TimeStampedPathCopies object.
543 // InternalPathCopies object.
544 let deleted = path_map.tokenize(deleted_path);
544 let deleted = path_map.tokenize(deleted_path);
545 copies.entry(deleted).and_modify(|old| {
545 copies.entry(deleted).and_modify(|old| {
546 oracle.record_overwrite(old.rev, current_rev);
546 oracle.record_overwrite(old.rev, current_rev);
@@ -560,11 +560,11 b' fn add_from_changes<A: Fn(Revision, Revi'
560 fn merge_copies_dict<A: Fn(Revision, Revision) -> bool>(
560 fn merge_copies_dict<A: Fn(Revision, Revision) -> bool>(
561 path_map: &TwoWayPathMap,
561 path_map: &TwoWayPathMap,
562 current_merge: Revision,
562 current_merge: Revision,
563 mut minor: TimeStampedPathCopies,
563 mut minor: InternalPathCopies,
564 mut major: TimeStampedPathCopies,
564 mut major: InternalPathCopies,
565 changes: &ChangedFiles,
565 changes: &ChangedFiles,
566 oracle: &mut AncestorOracle<A>,
566 oracle: &mut AncestorOracle<A>,
567 ) -> TimeStampedPathCopies {
567 ) -> InternalPathCopies {
568 // This closure exist as temporary help while multiple developper are
568 // This closure exist as temporary help while multiple developper are
569 // actively working on this code. Feel free to re-inline it once this
569 // actively working on this code. Feel free to re-inline it once this
570 // code is more settled.
570 // code is more settled.
@@ -587,7 +587,7 b' fn merge_copies_dict<A: Fn(Revision, Rev'
587 } else if major.is_empty() {
587 } else if major.is_empty() {
588 minor
588 minor
589 } else if minor.len() * 2 < major.len() {
589 } else if minor.len() * 2 < major.len() {
590 // Lets says we are merging two TimeStampedPathCopies instance A and B.
590 // Lets says we are merging two InternalPathCopies instance A and B.
591 //
591 //
592 // If A contains N items, the merge result will never contains more
592 // If A contains N items, the merge result will never contains more
593 // than N values differents than the one in A
593 // than N values differents than the one in A
@@ -601,7 +601,7 b' fn merge_copies_dict<A: Fn(Revision, Rev'
601 // between A and B.
601 // between A and B.
602 //
602 //
603 // This help performance a lot in case were a tiny
603 // This help performance a lot in case were a tiny
604 // TimeStampedPathCopies is merged with a much larger one.
604 // InternalPathCopies is merged with a much larger one.
605 for (dest, src_minor) in minor {
605 for (dest, src_minor) in minor {
606 let src_major = major.get(&dest);
606 let src_major = major.get(&dest);
607 match src_major {
607 match src_major {
@@ -755,7 +755,7 b' fn merge_copies_dict<A: Fn(Revision, Rev'
755 }
755 }
756
756
757 /// represent the side that should prevail when merging two
757 /// represent the side that should prevail when merging two
758 /// TimeStampedPathCopies
758 /// InternalPathCopies
759 enum MergePick {
759 enum MergePick {
760 /// The "major" (p1) side prevails
760 /// The "major" (p1) side prevails
761 Major,
761 Major,
General Comments 0
You need to be logged in to leave comments. Login now