Mercurial > hg
comparison rust/hg-cpython/src/dirstate/dirstate_map.rs @ 47511:eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
This code deal with special logic to preserving "merged" and "from_p2" information when removing a file. These are implementation details that are more suitable for the dirstatemap layer. Since the dirstatemap layer alreaday have most of the information necessary to do so, the move is easy.
This move helps us to encapsulate more implementation details within the dirstatemap and its entry. Easing the use of a different storage for dirstate v2.
Differential Revision: https://phab.mercurial-scm.org/D10953
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 03 Jul 2021 19:52:00 +0200 |
parents | eb416759af7e |
children | f6f25ab6bfc8 |
comparison
equal
deleted
inserted
replaced
47510:94c58f3aab56 | 47511:eaae39894312 |
---|---|
135 } | 135 } |
136 | 136 |
137 def removefile( | 137 def removefile( |
138 &self, | 138 &self, |
139 f: PyObject, | 139 f: PyObject, |
140 oldstate: PyObject, | 140 in_merge: PyObject |
141 size: PyObject | |
142 ) -> PyResult<PyObject> { | 141 ) -> PyResult<PyObject> { |
143 self.inner(py).borrow_mut() | 142 self.inner(py).borrow_mut() |
144 .remove_file( | 143 .remove_file( |
145 HgPath::new(f.extract::<PyBytes>(py)?.data(py)), | 144 HgPath::new(f.extract::<PyBytes>(py)?.data(py)), |
146 oldstate.extract::<PyBytes>(py)?.data(py)[0] | 145 in_merge.extract::<PyBool>(py)?.is_true(), |
147 .try_into() | |
148 .map_err(|e: HgError| { | |
149 PyErr::new::<exc::ValueError, _>(py, e.to_string()) | |
150 })?, | |
151 size.extract(py)?, | |
152 ) | 146 ) |
153 .or_else(|_| { | 147 .or_else(|_| { |
154 Err(PyErr::new::<exc::OSError, _>( | 148 Err(PyErr::new::<exc::OSError, _>( |
155 py, | 149 py, |
156 "Dirstate error".to_string(), | 150 "Dirstate error".to_string(), |