Mercurial > hg
changeset 49124:d9a66d62c604
rust-dirstatemap: use `&HgPath` instead of `HgPathBuf` in `copy_map_insert`
No reason to require an owned path here.
Differential Revision: https://phab.mercurial-scm.org/D12522
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Wed, 30 Mar 2022 11:39:53 +0200 |
parents | afe60def963d |
children | 28a6178a07a2 |
files | rust/hg-core/src/dirstate_tree/dirstate_map.rs rust/hg-cpython/src/dirstate/dirstate_map.rs |
diffstat | 2 files changed, 12 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs Tue Mar 29 17:23:24 2022 +0200 +++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs Wed Mar 30 11:39:53 2022 +0200 @@ -1284,8 +1284,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( @@ -1299,7 +1299,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)) }) }
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs Tue Mar 29 17:23:24 2022 +0200 +++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs Wed Mar 30 11:39:53 2022 +0200 @@ -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 @@ -411,8 +408,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())