Its callers have been migrated to the newer dirstate API.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
hg-reviewers |
Its callers have been migrated to the newer dirstate API.
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | rust/hg-core/src/dirstate_tree/dirstate_map.rs (36 lines) | |||
M | rust/hg-cpython/src/dirstate/dirstate_map.rs (19 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
ca1d4fb72f24 | 646fc6eea92d | Raphaël Gomès | Wed, Mar 23, 12:16 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 |
use crate::dirstate::parsers::pack_entry; | use crate::dirstate::parsers::pack_entry; | ||||
use crate::dirstate::parsers::packed_entry_size; | use crate::dirstate::parsers::packed_entry_size; | ||||
use crate::dirstate::parsers::parse_dirstate_entries; | use crate::dirstate::parsers::parse_dirstate_entries; | ||||
use crate::dirstate::CopyMapIter; | use crate::dirstate::CopyMapIter; | ||||
use crate::dirstate::DirstateV2Data; | use crate::dirstate::DirstateV2Data; | ||||
use crate::dirstate::ParentFileData; | use crate::dirstate::ParentFileData; | ||||
use crate::dirstate::StateMapIter; | use crate::dirstate::StateMapIter; | ||||
use crate::dirstate::TruncatedTimestamp; | use crate::dirstate::TruncatedTimestamp; | ||||
use crate::dirstate::SIZE_FROM_OTHER_PARENT; | |||||
use crate::dirstate::SIZE_NON_NORMAL; | |||||
use crate::matchers::Matcher; | use crate::matchers::Matcher; | ||||
use crate::utils::hg_path::{HgPath, HgPathBuf}; | use crate::utils::hg_path::{HgPath, HgPathBuf}; | ||||
use crate::DirstateEntry; | use crate::DirstateEntry; | ||||
use crate::DirstateError; | use crate::DirstateError; | ||||
use crate::DirstateMapError; | use crate::DirstateMapError; | ||||
use crate::DirstateParents; | use crate::DirstateParents; | ||||
use crate::DirstateStatus; | use crate::DirstateStatus; | ||||
use crate::EntryState; | use crate::EntryState; | ||||
p1_tracked, | p1_tracked, | ||||
p2_info, | p2_info, | ||||
has_meaningful_mtime, | has_meaningful_mtime, | ||||
parent_file_data_opt, | parent_file_data_opt, | ||||
) | ) | ||||
}) | }) | ||||
} | } | ||||
pub fn remove_file( | |||||
&mut self, | |||||
filename: &HgPath, | |||||
in_merge: bool, | |||||
) -> Result<(), DirstateError> { | |||||
let old_entry_opt = self.get(filename)?; | |||||
let old_state = old_entry_opt.map(|e| e.state()); | |||||
let mut size = 0; | |||||
if in_merge { | |||||
// XXX we should not be able to have 'm' state and 'FROM_P2' if not | |||||
// during a merge. So I (marmoute) am not sure we need the | |||||
// conditionnal at all. Adding double checking this with assert | |||||
// would be nice. | |||||
if let Some(old_entry) = old_entry_opt { | |||||
// backup the previous state | |||||
if old_entry.state() == EntryState::Merged { | |||||
size = SIZE_NON_NORMAL; | |||||
} else if old_entry.state() == EntryState::Normal | |||||
&& old_entry.size() == SIZE_FROM_OTHER_PARENT | |||||
{ | |||||
// other parent | |||||
size = SIZE_FROM_OTHER_PARENT; | |||||
} | |||||
} | |||||
} | |||||
if size == 0 { | |||||
self.copy_map_remove(filename)?; | |||||
} | |||||
self.with_dmap_mut(|map| { | |||||
let entry = DirstateEntry::new_removed(size); | |||||
Ok(map.add_or_remove_file(filename, old_state, entry)?) | |||||
}) | |||||
} | |||||
pub fn drop_entry_and_copy_source( | pub fn drop_entry_and_copy_source( | ||||
&mut self, | &mut self, | ||||
filename: &HgPath, | filename: &HgPath, | ||||
) -> Result<(), DirstateError> { | ) -> Result<(), DirstateError> { | ||||
let was_tracked = self | let was_tracked = self | ||||
.get(filename)? | .get(filename)? | ||||
.map_or(false, |e| e.state().is_tracked()); | .map_or(false, |e| e.state().is_tracked()); | ||||
struct Dropped { | struct Dropped { |
parent_file_data, | parent_file_data, | ||||
); | ); | ||||
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 removefile( | |||||
&self, | |||||
f: PyObject, | |||||
in_merge: PyObject | |||||
) -> PyResult<PyObject> { | |||||
self.inner(py).borrow_mut() | |||||
.remove_file( | |||||
HgPath::new(f.extract::<PyBytes>(py)?.data(py)), | |||||
in_merge.extract::<PyBool>(py)?.is_true(), | |||||
) | |||||
.or_else(|_| { | |||||
Err(PyErr::new::<exc::OSError, _>( | |||||
py, | |||||
"Dirstate error".to_string(), | |||||
)) | |||||
})?; | |||||
Ok(py.None()) | |||||
} | |||||
def drop_item_and_copy_source( | def drop_item_and_copy_source( | ||||
&self, | &self, | ||||
f: PyBytes, | f: PyBytes, | ||||
) -> PyResult<PyNone> { | ) -> PyResult<PyNone> { | ||||
self.inner(py) | self.inner(py) | ||||
.borrow_mut() | .borrow_mut() | ||||
.drop_entry_and_copy_source(HgPath::new(f.data(py))) | .drop_entry_and_copy_source(HgPath::new(f.data(py))) | ||||
.map_err(|e |dirstate_error(py, e))?; | .map_err(|e |dirstate_error(py, e))?; |