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

copies-rust: use matching to select the final copies information

This is a bit more idiomatic and this prepare a future refactoring where
InternalCopies from both parent would be updated at the same time.

Differential Revision: https://phab.mercurial-scm.org/D9647
parent 389b0328b789
1 merge request!72ci: hook network-io tests into the pipeline
......@@ -414,11 +414,12 @@
p2,
), // will be None if the vertex is not to be traversed
};
if let Some(parent_copies) = p1_copies {
// combine it with data for that revision
let vertex_copies = add_from_changes(
// combine it with data for that revision
let p1_copies = match p1_copies {
None => None,
Some(parent_copies) => Some(add_from_changes(
&mut path_map,
&parent_copies,
&changes,
Parent::FirstParent,
rev,
......@@ -420,17 +421,15 @@
&mut path_map,
&parent_copies,
&changes,
Parent::FirstParent,
rev,
);
// keep that data around for potential later combination
copies = Some(vertex_copies);
}
if let Some(parent_copies) = p2_copies {
// combine it with data for that revision
let vertex_copies = add_from_changes(
)),
};
let p2_copies = match p2_copies {
None => None,
Some(parent_copies) => Some(add_from_changes(
&mut path_map,
&parent_copies,
&changes,
Parent::SecondParent,
rev,
......@@ -432,31 +431,20 @@
&mut path_map,
&parent_copies,
&changes,
Parent::SecondParent,
rev,
);
copies = match copies {
None => Some(vertex_copies),
// Merge has two parents needs to combines their copy
// information.
//
// If we got data from both parents, We need to combine
// them.
Some(copies) => Some(merge_copies_dict(
&path_map,
rev,
vertex_copies,
copies,
&changes,
)),
};
}
match copies {
Some(copies) => {
all_copies.insert(rev, copies);
}
_ => {}
)),
};
let copies = match (p1_copies, p2_copies) {
(None, None) => None,
(c, None) => c,
(None, c) => c,
(Some(p1_copies), Some(p2_copies)) => Some(merge_copies_dict(
&path_map, rev, p2_copies, p1_copies, &changes,
)),
};
if let Some(c) = copies {
all_copies.insert(rev, c);
}
}
......
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