No reason to require an owned path here.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
No reason to require an owned path here.
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | rust/hg-core/src/dirstate_tree/dirstate_map.rs (9 lines) | |||
M | rust/hg-cpython/src/dirstate/dirstate_map.rs (15 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
9af536ae751c | 842a84af0b9a | Raphaël Gomès | Mar 30 2022, 5:39 AM |
Status | Author | Revision | |
---|---|---|---|
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare |
} | } | ||||
node.copy_source.take().map(Cow::into_owned) | node.copy_source.take().map(Cow::into_owned) | ||||
})) | })) | ||||
}) | }) | ||||
} | } | ||||
pub fn copy_map_insert( | pub fn copy_map_insert( | ||||
&mut self, | &mut self, | ||||
key: HgPathBuf, | key: &HgPath, | ||||
value: HgPathBuf, | value: &HgPath, | ||||
) -> Result<Option<HgPathBuf>, DirstateV2ParseError> { | ) -> Result<Option<HgPathBuf>, DirstateV2ParseError> { | ||||
self.with_dmap_mut(|map| { | self.with_dmap_mut(|map| { | ||||
let node = DirstateMap::get_or_insert_node( | let node = DirstateMap::get_or_insert_node( | ||||
map.on_disk, | map.on_disk, | ||||
&mut map.unreachable_bytes, | &mut map.unreachable_bytes, | ||||
&mut map.root, | &mut map.root, | ||||
&key, | &key, | ||||
WithBasename::to_cow_owned, | WithBasename::to_cow_owned, | ||||
|_ancestor| {}, | |_ancestor| {}, | ||||
)?; | )?; | ||||
if node.copy_source.is_none() { | if node.copy_source.is_none() { | ||||
map.nodes_with_copy_source_count += 1 | 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)) | |||||
}) | }) | ||||
} | } | ||||
pub fn len(&self) -> usize { | pub fn len(&self) -> usize { | ||||
let map = self.get_map(); | let map = self.get_map(); | ||||
map.nodes_with_entry_count as usize | map.nodes_with_entry_count as usize | ||||
} | } | ||||
use hg::dirstate::{ParentFileData, TruncatedTimestamp}; | use hg::dirstate::{ParentFileData, TruncatedTimestamp}; | ||||
use crate::{ | use crate::{ | ||||
dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator}, | dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator}, | ||||
dirstate::item::DirstateItem, | dirstate::item::DirstateItem, | ||||
pybytes_deref::PyBytesDeref, | pybytes_deref::PyBytesDeref, | ||||
}; | }; | ||||
use hg::{ | use hg::{ | ||||
dirstate::StateMapIter, | dirstate::StateMapIter, dirstate_tree::on_disk::DirstateV2ParseError, | ||||
dirstate_tree::on_disk::DirstateV2ParseError, | dirstate_tree::owning::OwningDirstateMap, revlog::Node, | ||||
dirstate_tree::owning::OwningDirstateMap, | utils::files::normalize_case, utils::hg_path::HgPath, DirstateEntry, | ||||
revlog::Node, | DirstateError, DirstateParents, EntryState, | ||||
utils::files::normalize_case, | |||||
utils::hg_path::{HgPath, HgPathBuf}, | |||||
DirstateEntry, DirstateError, DirstateParents, EntryState, | |||||
}; | }; | ||||
// TODO | // TODO | ||||
// This object needs to share references to multiple members of its Rust | // This object needs to share references to multiple members of its Rust | ||||
// inner struct, namely `copy_map`, `dirs` and `all_dirs`. | // inner struct, namely `copy_map`, `dirs` and `all_dirs`. | ||||
// Right now `CopyMap` is done, but it needs to have an explicit reference | // Right now `CopyMap` is done, but it needs to have an explicit reference | ||||
// to `RustDirstateMap` which itself needs to have an encapsulation for | // to `RustDirstateMap` which itself needs to have an encapsulation for | ||||
// every method in `CopyMap` (copymapcopy, etc.). | // every method in `CopyMap` (copymapcopy, etc.). | ||||
key: PyObject, | key: PyObject, | ||||
value: PyObject | value: PyObject | ||||
) -> PyResult<PyObject> { | ) -> PyResult<PyObject> { | ||||
let key = key.extract::<PyBytes>(py)?; | let key = key.extract::<PyBytes>(py)?; | ||||
let value = value.extract::<PyBytes>(py)?; | let value = value.extract::<PyBytes>(py)?; | ||||
self.inner(py) | self.inner(py) | ||||
.borrow_mut() | .borrow_mut() | ||||
.copy_map_insert( | .copy_map_insert( | ||||
HgPathBuf::from_bytes(key.data(py)), | HgPath::new(key.data(py)), | ||||
HgPathBuf::from_bytes(value.data(py)), | HgPath::new(value.data(py)), | ||||
) | ) | ||||
.map_err(|e| v2_error(py, e))?; | .map_err(|e| v2_error(py, e))?; | ||||
Ok(py.None()) | Ok(py.None()) | ||||
} | } | ||||
def copymappop( | def copymappop( | ||||
&self, | &self, | ||||
key: PyObject, | key: PyObject, | ||||
default: Option<PyObject> | default: Option<PyObject> |