Skip to content
Snippets Groups Projects
Commit 4eec0a022681 authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

copies-rust: rename TimeStampedPathCopies to InternalPathCopies

We are looking into moving away from TimeStampedPathCopy (that use is_ancestors
call to detect overwrite) in favor of an approach that does not requires
is_ancestors calls. Yet we will still need an internal representation that
differs from the returned result.

So we call it "InternalPathCopies" which is generic but clear.

Differential Revision: https://phab.mercurial-scm.org/D9641
parent 811a41896d24
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,7 @@
}
/// maps CopyDestination to Copy Source (+ a "timestamp" for the operation)
type TimeStampedPathCopies = OrdMap<PathToken, TimeStampedPathCopy>;
type InternalPathCopies = OrdMap<PathToken, TimeStampedPathCopy>;
/// hold parent 1, parent 2 and relevant files actions.
pub type RevInfo<'a> = (Revision, Revision, ChangedFiles<'a>);
......@@ -382,7 +382,7 @@
// We will chain the copies information accumulated for the parent with
// the individual copies information the curent revision. Creating a
// new TimeStampedPath for each `rev` → `children` vertex.
let mut copies: Option<TimeStampedPathCopies> = None;
let mut copies: Option<InternalPathCopies> = None;
if p1 != NULL_REVISION {
// Retrieve data computed in a previous iteration
let parent_copies = get_and_clean_parent_copies(
......@@ -471,6 +471,6 @@
///
/// If parent is not part of the set we are expected to walk, return None.
fn get_and_clean_parent_copies(
all_copies: &mut HashMap<Revision, TimeStampedPathCopies>,
all_copies: &mut HashMap<Revision, InternalPathCopies>,
children_count: &mut HashMap<Revision, usize>,
parent_rev: Revision,
......@@ -475,8 +475,8 @@
children_count: &mut HashMap<Revision, usize>,
parent_rev: Revision,
) -> Option<TimeStampedPathCopies> {
) -> Option<InternalPathCopies> {
let count = children_count.get_mut(&parent_rev)?;
*count -= 1;
if *count == 0 {
match all_copies.remove(&parent_rev) {
Some(c) => Some(c),
......@@ -478,10 +478,10 @@
let count = children_count.get_mut(&parent_rev)?;
*count -= 1;
if *count == 0 {
match all_copies.remove(&parent_rev) {
Some(c) => Some(c),
None => Some(TimeStampedPathCopies::default()),
None => Some(InternalPathCopies::default()),
}
} else {
match all_copies.get(&parent_rev) {
Some(c) => Some(c.clone()),
......@@ -484,8 +484,8 @@
}
} else {
match all_copies.get(&parent_rev) {
Some(c) => Some(c.clone()),
None => Some(TimeStampedPathCopies::default()),
None => Some(InternalPathCopies::default()),
}
}
}
......@@ -495,7 +495,7 @@
fn add_from_changes<A: Fn(Revision, Revision) -> bool>(
path_map: &mut TwoWayPathMap,
oracle: &mut AncestorOracle<A>,
base_copies: &TimeStampedPathCopies,
base_copies: &InternalPathCopies,
changes: &ChangedFiles,
parent: Parent,
current_rev: Revision,
......@@ -499,7 +499,7 @@
changes: &ChangedFiles,
parent: Parent,
current_rev: Revision,
) -> TimeStampedPathCopies {
) -> InternalPathCopies {
let mut copies = base_copies.clone();
for action in changes.iter_actions(parent) {
match action {
......@@ -540,7 +540,7 @@
//
// We need to explicitly record them as dropped to
// propagate this information when merging two
// TimeStampedPathCopies object.
// InternalPathCopies object.
let deleted = path_map.tokenize(deleted_path);
copies.entry(deleted).and_modify(|old| {
oracle.record_overwrite(old.rev, current_rev);
......@@ -560,7 +560,7 @@
fn merge_copies_dict<A: Fn(Revision, Revision) -> bool>(
path_map: &TwoWayPathMap,
current_merge: Revision,
mut minor: TimeStampedPathCopies,
mut major: TimeStampedPathCopies,
mut minor: InternalPathCopies,
mut major: InternalPathCopies,
changes: &ChangedFiles,
oracle: &mut AncestorOracle<A>,
......@@ -565,6 +565,6 @@
changes: &ChangedFiles,
oracle: &mut AncestorOracle<A>,
) -> TimeStampedPathCopies {
) -> InternalPathCopies {
// This closure exist as temporary help while multiple developper are
// actively working on this code. Feel free to re-inline it once this
// code is more settled.
......@@ -587,7 +587,7 @@
} else if major.is_empty() {
minor
} else if minor.len() * 2 < major.len() {
// Lets says we are merging two TimeStampedPathCopies instance A and B.
// Lets says we are merging two InternalPathCopies instance A and B.
//
// If A contains N items, the merge result will never contains more
// than N values differents than the one in A
......@@ -601,7 +601,7 @@
// between A and B.
//
// This help performance a lot in case were a tiny
// TimeStampedPathCopies is merged with a much larger one.
// InternalPathCopies is merged with a much larger one.
for (dest, src_minor) in minor {
let src_major = major.get(&dest);
match src_major {
......@@ -755,7 +755,7 @@
}
/// represent the side that should prevail when merging two
/// TimeStampedPathCopies
/// InternalPathCopies
enum MergePick {
/// The "major" (p1) side prevails
Major,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment