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 (59 lines) | |||
M | rust/hg-cpython/src/dirstate/dirstate_map.rs (10 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
2f4497425c1d | 43e90fac11fc | Raphaël Gomès | Mon, Mar 28, 12:13 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 |
)?; | )?; | ||||
if !had_entry { | if !had_entry { | ||||
self.nodes_with_entry_count += 1 | self.nodes_with_entry_count += 1 | ||||
} | } | ||||
node.data = NodeData::Entry(new_entry); | node.data = NodeData::Entry(new_entry); | ||||
Ok(()) | Ok(()) | ||||
} | } | ||||
/// It is the responsibility of the caller to know that there was an entry | |||||
/// there before. Does not handle the removal of copy source | |||||
fn set_untracked( | |||||
&mut self, | |||||
filename: &HgPath, | |||||
old_entry: DirstateEntry, | |||||
) -> Result<(), DirstateV2ParseError> { | |||||
let node = Self::get_or_insert_node( | |||||
self.on_disk, | |||||
&mut self.unreachable_bytes, | |||||
&mut self.root, | |||||
filename, | |||||
WithBasename::to_cow_owned, | |||||
|ancestor| { | |||||
ancestor.tracked_descendants_count = ancestor | |||||
.tracked_descendants_count | |||||
.checked_sub(1) | |||||
.expect("tracked_descendants_count should be >= 0"); | |||||
}, | |||||
)?; | |||||
let mut new_entry = old_entry.clone(); | |||||
new_entry.set_untracked(); | |||||
node.data = NodeData::Entry(new_entry); | |||||
Ok(()) | |||||
} | |||||
fn set_clean( | fn set_clean( | ||||
&mut self, | &mut self, | ||||
filename: &HgPath, | filename: &HgPath, | ||||
old_entry: DirstateEntry, | old_entry: DirstateEntry, | ||||
mode: u32, | mode: u32, | ||||
size: u32, | size: u32, | ||||
mtime: TruncatedTimestamp, | mtime: TruncatedTimestamp, | ||||
) -> Result<(), DirstateError> { | ) -> Result<(), DirstateError> { | ||||
pub fn set_tracked( | pub fn set_tracked( | ||||
&mut self, | &mut self, | ||||
filename: &HgPath, | filename: &HgPath, | ||||
) -> Result<bool, DirstateV2ParseError> { | ) -> Result<bool, DirstateV2ParseError> { | ||||
let old_entry_opt = self.get(filename)?; | let old_entry_opt = self.get(filename)?; | ||||
self.with_dmap_mut(|map| map.set_tracked(filename, old_entry_opt)) | self.with_dmap_mut(|map| map.set_tracked(filename, old_entry_opt)) | ||||
} | } | ||||
pub fn set_untracked( | |||||
&mut self, | |||||
filename: &HgPath, | |||||
) -> Result<bool, DirstateError> { | |||||
let old_entry_opt = self.get(filename)?; | |||||
match old_entry_opt { | |||||
None => Ok(false), | |||||
Some(old_entry) => { | |||||
if !old_entry.tracked() { | |||||
// `DirstateMap::set_untracked` is not a noop if | |||||
// already not tracked as it will decrement the | |||||
// tracked counters while going down. | |||||
return Ok(true); | |||||
} | |||||
if old_entry.added() { | |||||
// Untracking an "added" entry will just result in a | |||||
// worthless entry (and other parts of the code will | |||||
// complain about it), just drop it entirely. | |||||
self.drop_entry_and_copy_source(filename)?; | |||||
return Ok(true); | |||||
} | |||||
if !old_entry.p2_info() { | |||||
self.copy_map_remove(filename)?; | |||||
} | |||||
self.with_dmap_mut(|map| { | |||||
map.set_untracked(filename, old_entry)?; | |||||
Ok(true) | |||||
}) | |||||
} | |||||
} | |||||
} | |||||
pub fn set_clean( | pub fn set_clean( | ||||
&mut self, | &mut self, | ||||
filename: &HgPath, | filename: &HgPath, | ||||
mode: u32, | mode: u32, | ||||
size: u32, | size: u32, | ||||
mtime: TruncatedTimestamp, | mtime: TruncatedTimestamp, | ||||
) -> Result<(), DirstateError> { | ) -> Result<(), DirstateError> { | ||||
let old_entry = match self.get(filename)? { | let old_entry = match self.get(filename)? { |
let path = HgPath::new(bytes.data(py)); | let path = HgPath::new(bytes.data(py)); | ||||
let res = self.inner(py).borrow_mut().set_tracked(path); | let res = self.inner(py).borrow_mut().set_tracked(path); | ||||
let was_tracked = res.or_else(|_| { | let was_tracked = res.or_else(|_| { | ||||
Err(PyErr::new::<exc::OSError, _>(py, "Dirstate error".to_string())) | Err(PyErr::new::<exc::OSError, _>(py, "Dirstate error".to_string())) | ||||
})?; | })?; | ||||
Ok(was_tracked.to_py_object(py)) | Ok(was_tracked.to_py_object(py)) | ||||
} | } | ||||
def set_untracked(&self, f: PyObject) -> PyResult<PyBool> { | |||||
let bytes = f.extract::<PyBytes>(py)?; | |||||
let path = HgPath::new(bytes.data(py)); | |||||
let res = self.inner(py).borrow_mut().set_untracked(path); | |||||
let was_tracked = res.or_else(|_| { | |||||
Err(PyErr::new::<exc::OSError, _>(py, "Dirstate error".to_string())) | |||||
})?; | |||||
Ok(was_tracked.to_py_object(py)) | |||||
} | |||||
def set_clean( | def set_clean( | ||||
&self, | &self, | ||||
f: PyObject, | f: PyObject, | ||||
mode: u32, | mode: u32, | ||||
size: u32, | size: u32, | ||||
mtime: (i64, u32, bool) | mtime: (i64, u32, bool) | ||||
) -> PyResult<PyNone> { | ) -> PyResult<PyNone> { | ||||
let (mtime_s, mtime_ns, second_ambiguous) = mtime; | let (mtime_s, mtime_ns, second_ambiguous) = mtime; |