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

copies-rust: use the `entry` API for copy information too

The code end up being complicated, but it split out the case were we add a new
entry from the case were we overwrite one. And that is the goal here, being able
to easily track value overwrite.

Differential Revision: https://phab.mercurial-scm.org/D9495
parent 13ab69c6
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
use crate::NULL_REVISION;
use im_rc::ordmap::DiffItem;
use im_rc::ordmap::Entry;
use im_rc::ordmap::OrdMap;
use std::cmp::Ordering;
......@@ -510,11 +511,20 @@
// record this information as we will need it to take
// the right decision when merging conflicting copy
// information. See merge_copies_dict for details.
let ttpc = TimeStampedPathCopy {
rev: current_rev,
path: entry,
};
copies.insert(dest.to_owned(), ttpc);
match copies.entry(dest) {
Entry::Vacant(slot) => {
let ttpc = TimeStampedPathCopy {
rev: current_rev,
path: entry,
};
slot.insert(ttpc);
}
Entry::Occupied(mut slot) => {
let mut ttpc = slot.get_mut();
ttpc.rev = current_rev;
ttpc.path = entry;
}
}
}
Action::Removed(deleted_path) => {
// We must drop copy information for removed file.
......
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