[Updated] D9651: copies-rust: refactor the "deletion" case
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Wed Feb 24 16:03:19 UTC 2021
Closed by commit rHGae57e0792c41: copies-rust: refactor the "deletion" case (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D9651?vs=25794&id=25855
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D9651/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D9651
AFFECTED FILES
rust/hg-core/src/copy_tracing.rs
CHANGE DETAILS
diff --git a/rust/hg-core/src/copy_tracing.rs b/rust/hg-core/src/copy_tracing.rs
--- a/rust/hg-core/src/copy_tracing.rs
+++ b/rust/hg-core/src/copy_tracing.rs
@@ -510,22 +510,35 @@
// propagate this information when merging two
// InternalPathCopies object.
let deleted = path_map.tokenize(deleted_path);
- match &mut p1_copies {
- None => (),
- Some(copies) => {
- copies.entry(deleted).and_modify(|old| {
- old.mark_delete(current_rev);
- });
- }
+
+ let p1_entry = match &mut p1_copies {
+ None => None,
+ Some(copies) => match copies.entry(deleted) {
+ Entry::Occupied(e) => Some(e),
+ Entry::Vacant(_) => None,
+ },
+ };
+ let p2_entry = match &mut p2_copies {
+ None => None,
+ Some(copies) => match copies.entry(deleted) {
+ Entry::Occupied(e) => Some(e),
+ Entry::Vacant(_) => None,
+ },
};
- match &mut p2_copies {
- None => (),
- Some(copies) => {
- copies.entry(deleted).and_modify(|old| {
- old.mark_delete(current_rev);
- });
+
+ match (p1_entry, p2_entry) {
+ (None, None) => (),
+ (Some(mut e), None) => {
+ e.get_mut().mark_delete(current_rev)
}
- };
+ (None, Some(mut e)) => {
+ e.get_mut().mark_delete(current_rev)
+ }
+ (Some(mut e1), Some(mut e2)) => {
+ e1.get_mut().mark_delete(current_rev);
+ e2.get_mut().mark_delete(current_rev);
+ }
+ }
}
}
}
To: marmoute, #hg-reviewers, Alphare
Cc: Alphare, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210224/e6f033f1/attachment-0001.html>
More information about the Mercurial-patches
mailing list