[Request] [+- ] D12476: rust-dirstatemap: use `&HgPath` instead of `HgPathBuf` in `copy_map_insert`
Alphare (Raphaël Gomès)
phabricator at mercurial-scm.org
Wed Apr 6 14:13:33 UTC 2022
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
No reason to require an owned path here.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D12476
AFFECTED FILES
rust/hg-core/src/dirstate_tree/dirstate_map.rs
rust/hg-cpython/src/dirstate/dirstate_map.rs
CHANGE DETAILS
diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs b/rust/hg-cpython/src/dirstate/dirstate_map.rs
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs
@@ -23,13 +23,10 @@
pybytes_deref::PyBytesDeref,
};
use hg::{
- dirstate::StateMapIter,
- dirstate_tree::on_disk::DirstateV2ParseError,
- dirstate_tree::owning::OwningDirstateMap,
- revlog::Node,
- utils::files::normalize_case,
- utils::hg_path::{HgPath, HgPathBuf},
- DirstateEntry, DirstateError, DirstateParents, EntryState,
+ dirstate::StateMapIter, dirstate_tree::on_disk::DirstateV2ParseError,
+ dirstate_tree::owning::OwningDirstateMap, revlog::Node,
+ utils::files::normalize_case, utils::hg_path::HgPath, DirstateEntry,
+ DirstateError, DirstateParents, EntryState,
};
// TODO
@@ -428,8 +425,8 @@
self.inner(py)
.borrow_mut()
.copy_map_insert(
- HgPathBuf::from_bytes(key.data(py)),
- HgPathBuf::from_bytes(value.data(py)),
+ HgPath::new(key.data(py)),
+ HgPath::new(value.data(py)),
)
.map_err(|e| v2_error(py, e))?;
Ok(py.None())
diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -1278,8 +1278,8 @@
pub fn copy_map_insert(
&mut self,
- key: HgPathBuf,
- value: HgPathBuf,
+ key: &HgPath,
+ value: &HgPath,
) -> Result<Option<HgPathBuf>, DirstateV2ParseError> {
self.with_dmap_mut(|map| {
let node = DirstateMap::get_or_insert_node(
@@ -1293,7 +1293,10 @@
if node.copy_source.is_none() {
map.nodes_with_copy_source_count += 1
}
- Ok(node.copy_source.replace(value.into()).map(Cow::into_owned))
+ Ok(node
+ .copy_source
+ .replace(value.to_owned().into())
+ .map(Cow::into_owned))
})
}
To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20220406/9b7b2b7e/attachment-0001.html>
More information about the Mercurial-patches
mailing list