This is the new API that Python has already migrated to.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
( )
hg-reviewers |
This is the new API that Python has already migrated to.
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | rust/hg-core/src/dirstate_tree/dirstate_map.rs (35 lines) | |||
M | rust/hg-cpython/src/dirstate/dirstate_map.rs (10 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
7878687ef0ea | 92349ee98dd0 | Raphaël Gomès | Mon, Mar 28, 12:09 PM |
Status | Author | Revision | |
---|---|---|---|
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare | ||
Needs Review | Alphare |
} | } | ||||
fn as_entry(&self) -> Option<&DirstateEntry> { | fn as_entry(&self) -> Option<&DirstateEntry> { | ||||
match self { | match self { | ||||
NodeData::Entry(entry) => Some(entry), | NodeData::Entry(entry) => Some(entry), | ||||
_ => None, | _ => None, | ||||
} | } | ||||
} | } | ||||
fn as_entry_mut(&mut self) -> Option<&mut DirstateEntry> { | |||||
match self { | |||||
NodeData::Entry(entry) => Some(entry), | |||||
_ => None, | |||||
} | |||||
} | |||||
} | } | ||||
impl<'on_disk> DirstateMap<'on_disk> { | impl<'on_disk> DirstateMap<'on_disk> { | ||||
pub(super) fn empty(on_disk: &'on_disk [u8]) -> Self { | pub(super) fn empty(on_disk: &'on_disk [u8]) -> Self { | ||||
Self { | Self { | ||||
on_disk, | on_disk, | ||||
root: ChildNodes::default(), | root: ChildNodes::default(), | ||||
nodes_with_entry_count: 0, | nodes_with_entry_count: 0, | ||||
}, | }, | ||||
)?; | )?; | ||||
let mut new_entry = old_entry.clone(); | let mut new_entry = old_entry.clone(); | ||||
new_entry.set_clean(mode, size, mtime); | new_entry.set_clean(mode, size, mtime); | ||||
node.data = NodeData::Entry(new_entry); | node.data = NodeData::Entry(new_entry); | ||||
Ok(()) | Ok(()) | ||||
} | } | ||||
fn set_possibly_dirty( | |||||
&mut self, | |||||
filename: &HgPath, | |||||
) -> Result<(), DirstateError> { | |||||
let node = Self::get_or_insert_node( | |||||
self.on_disk, | |||||
&mut self.unreachable_bytes, | |||||
&mut self.root, | |||||
filename, | |||||
WithBasename::to_cow_owned, | |||||
|_ancestor| {}, | |||||
)?; | |||||
let entry = node.data.as_entry_mut().expect("entry should exist"); | |||||
entry.set_possibly_dirty(); | |||||
node.data = NodeData::Entry(*entry); | |||||
Ok(()) | |||||
} | |||||
fn iter_nodes<'tree>( | fn iter_nodes<'tree>( | ||||
&'tree self, | &'tree self, | ||||
) -> impl Iterator< | ) -> impl Iterator< | ||||
Item = Result<NodeRef<'tree, 'on_disk>, DirstateV2ParseError>, | Item = Result<NodeRef<'tree, 'on_disk>, DirstateV2ParseError>, | ||||
> + 'tree { | > + 'tree { | ||||
// Depth first tree traversal. | // Depth first tree traversal. | ||||
// | // | ||||
// If we could afford internal iteration and recursion, | // If we could afford internal iteration and recursion, | ||||
Some(e) => e, | Some(e) => e, | ||||
}; | }; | ||||
self.copy_map_remove(filename)?; | self.copy_map_remove(filename)?; | ||||
self.with_dmap_mut(|map| { | self.with_dmap_mut(|map| { | ||||
map.set_clean(filename, old_entry, mode, size, mtime) | map.set_clean(filename, old_entry, mode, size, mtime) | ||||
}) | }) | ||||
} | } | ||||
pub fn set_possibly_dirty( | |||||
&mut self, | |||||
filename: &HgPath, | |||||
) -> Result<(), DirstateError> { | |||||
if self.get(filename)?.is_none() { | |||||
return Err(DirstateMapError::PathNotFound(filename.into()).into()); | |||||
} | |||||
self.with_dmap_mut(|map| map.set_possibly_dirty(filename)) | |||||
} | |||||
pub fn reset_state( | pub fn reset_state( | ||||
&mut self, | &mut self, | ||||
filename: &HgPath, | filename: &HgPath, | ||||
wc_tracked: bool, | wc_tracked: bool, | ||||
p1_tracked: bool, | p1_tracked: bool, | ||||
p2_info: bool, | p2_info: bool, | ||||
has_meaningful_mtime: bool, | has_meaningful_mtime: bool, | ||||
parent_file_data_opt: Option<ParentFileData>, | parent_file_data_opt: Option<ParentFileData>, |
path, mode, size, timestamp, | path, mode, size, timestamp, | ||||
); | ); | ||||
res.or_else(|_| { | res.or_else(|_| { | ||||
Err(PyErr::new::<exc::OSError, _>(py, "Dirstate error".to_string())) | Err(PyErr::new::<exc::OSError, _>(py, "Dirstate error".to_string())) | ||||
})?; | })?; | ||||
Ok(PyNone) | Ok(PyNone) | ||||
} | } | ||||
def set_possibly_dirty(&self, f: PyObject) -> PyResult<PyNone> { | |||||
let bytes = f.extract::<PyBytes>(py)?; | |||||
let path = HgPath::new(bytes.data(py)); | |||||
let res = self.inner(py).borrow_mut().set_possibly_dirty(path); | |||||
res.or_else(|_| { | |||||
Err(PyErr::new::<exc::OSError, _>(py, "Dirstate error".to_string())) | |||||
})?; | |||||
Ok(PyNone) | |||||
} | |||||
def reset_state( | def reset_state( | ||||
&self, | &self, | ||||
f: PyObject, | f: PyObject, | ||||
wc_tracked: bool, | wc_tracked: bool, | ||||
p1_tracked: bool, | p1_tracked: bool, | ||||
p2_info: bool, | p2_info: bool, | ||||
has_meaningful_mtime: bool, | has_meaningful_mtime: bool, | ||||
parentfiledata: Option<(u32, u32, Option<(i64, u32, bool)>)>, | parentfiledata: Option<(u32, u32, Option<(i64, u32, bool)>)>, |