Show More
@@ -563,8 +563,7 b' class dirstate(object):' | |||||
563 |
|
563 | |||
564 | def drop(self, f): |
|
564 | def drop(self, f): | |
565 | '''Drop a file from the dirstate''' |
|
565 | '''Drop a file from the dirstate''' | |
566 | oldstate = self[f] |
|
566 | if self._map.dropfile(f): | |
567 | if self._map.dropfile(f, oldstate): |
|
|||
568 | self._dirty = True |
|
567 | self._dirty = True | |
569 | self._updatedfiles.add(f) |
|
568 | self._updatedfiles.add(f) | |
570 | self._map.copymap.pop(f, None) |
|
569 | self._map.copymap.pop(f, None) | |
@@ -1308,7 +1307,6 b' class dirstate(object):' | |||||
1308 | # general. That is much slower than simply accessing and storing the |
|
1307 | # general. That is much slower than simply accessing and storing the | |
1309 | # tuple members one by one. |
|
1308 | # tuple members one by one. | |
1310 | t = dget(fn) |
|
1309 | t = dget(fn) | |
1311 | state = t.state |
|
|||
1312 | mode = t[1] |
|
1310 | mode = t[1] | |
1313 | size = t[2] |
|
1311 | size = t[2] | |
1314 | time = t[3] |
|
1312 | time = t[3] |
@@ -235,12 +235,17 b' class dirstatemap(object):' | |||||
235 | self._map[f] = dirstatetuple(b'r', 0, size, 0) |
|
235 | self._map[f] = dirstatetuple(b'r', 0, size, 0) | |
236 | self.nonnormalset.add(f) |
|
236 | self.nonnormalset.add(f) | |
237 |
|
237 | |||
238 |
def dropfile(self, f |
|
238 | def dropfile(self, f): | |
239 | """ |
|
239 | """ | |
240 | Remove a file from the dirstate. Returns True if the file was |
|
240 | Remove a file from the dirstate. Returns True if the file was | |
241 | previously recorded. |
|
241 | previously recorded. | |
242 | """ |
|
242 | """ | |
243 |
|
|
243 | old_entry = self._map.pop(f, None) | |
|
244 | exists = False | |||
|
245 | oldstate = b'?' | |||
|
246 | if old_entry is not None: | |||
|
247 | exists = True | |||
|
248 | oldstate = old_entry.state | |||
244 | if exists: |
|
249 | if exists: | |
245 | if oldstate != b"r" and "_dirs" in self.__dict__: |
|
250 | if oldstate != b"r" and "_dirs" in self.__dict__: | |
246 | self._dirs.delpath(f) |
|
251 | self._dirs.delpath(f) |
@@ -205,8 +205,11 b' impl DirstateMap {' | |||||
205 | pub fn drop_file( |
|
205 | pub fn drop_file( | |
206 | &mut self, |
|
206 | &mut self, | |
207 | filename: &HgPath, |
|
207 | filename: &HgPath, | |
208 | old_state: EntryState, |
|
|||
209 | ) -> Result<bool, DirstateError> { |
|
208 | ) -> Result<bool, DirstateError> { | |
|
209 | let old_state = match self.get(filename) { | |||
|
210 | Some(e) => e.state, | |||
|
211 | None => EntryState::Unknown, | |||
|
212 | }; | |||
210 | let exists = self.state_map.remove(filename).is_some(); |
|
213 | let exists = self.state_map.remove(filename).is_some(); | |
211 |
|
214 | |||
212 | if exists { |
|
215 | if exists { |
@@ -803,11 +803,11 b" impl<'on_disk> super::dispatch::Dirstate" | |||||
803 | Ok(self.add_or_remove_file(filename, old_state, entry)?) |
|
803 | Ok(self.add_or_remove_file(filename, old_state, entry)?) | |
804 | } |
|
804 | } | |
805 |
|
805 | |||
806 | fn drop_file( |
|
806 | fn drop_file(&mut self, filename: &HgPath) -> Result<bool, DirstateError> { | |
807 | &mut self, |
|
807 | let old_state = match self.get(filename)? { | |
808 | filename: &HgPath, |
|
808 | Some(e) => e.state, | |
809 |
|
|
809 | None => EntryState::Unknown, | |
810 | ) -> Result<bool, DirstateError> { |
|
810 | }; | |
811 | struct Dropped { |
|
811 | struct Dropped { | |
812 | was_tracked: bool, |
|
812 | was_tracked: bool, | |
813 | had_entry: bool, |
|
813 | had_entry: bool, |
@@ -10,7 +10,6 b' use crate::DirstateError;' | |||||
10 | use crate::DirstateMap; |
|
10 | use crate::DirstateMap; | |
11 | use crate::DirstateParents; |
|
11 | use crate::DirstateParents; | |
12 | use crate::DirstateStatus; |
|
12 | use crate::DirstateStatus; | |
13 | use crate::EntryState; |
|
|||
14 | use crate::PatternFileWarning; |
|
13 | use crate::PatternFileWarning; | |
15 | use crate::StateMapIter; |
|
14 | use crate::StateMapIter; | |
16 | use crate::StatusError; |
|
15 | use crate::StatusError; | |
@@ -74,11 +73,7 b' pub trait DirstateMapMethods {' | |||||
74 | /// |
|
73 | /// | |
75 | /// `old_state` is the state in the entry that `get` would have returned |
|
74 | /// `old_state` is the state in the entry that `get` would have returned | |
76 | /// before this call, or `EntryState::Unknown` if there was no such entry. |
|
75 | /// before this call, or `EntryState::Unknown` if there was no such entry. | |
77 | fn drop_file( |
|
76 | fn drop_file(&mut self, filename: &HgPath) -> Result<bool, DirstateError>; | |
78 | &mut self, |
|
|||
79 | filename: &HgPath, |
|
|||
80 | old_state: EntryState, |
|
|||
81 | ) -> Result<bool, DirstateError>; |
|
|||
82 |
|
77 | |||
83 | /// Among given files, mark the stored `mtime` as ambiguous if there is one |
|
78 | /// Among given files, mark the stored `mtime` as ambiguous if there is one | |
84 | /// (if `state == EntryState::Normal`) equal to the given current Unix |
|
79 | /// (if `state == EntryState::Normal`) equal to the given current Unix | |
@@ -305,12 +300,8 b' impl DirstateMapMethods for DirstateMap ' | |||||
305 | self.remove_file(filename, in_merge) |
|
300 | self.remove_file(filename, in_merge) | |
306 | } |
|
301 | } | |
307 |
|
302 | |||
308 | fn drop_file( |
|
303 | fn drop_file(&mut self, filename: &HgPath) -> Result<bool, DirstateError> { | |
309 | &mut self, |
|
304 | self.drop_file(filename) | |
310 | filename: &HgPath, |
|
|||
311 | old_state: EntryState, |
|
|||
312 | ) -> Result<bool, DirstateError> { |
|
|||
313 | self.drop_file(filename, old_state) |
|
|||
314 | } |
|
305 | } | |
315 |
|
306 | |||
316 | fn clear_ambiguous_times( |
|
307 | fn clear_ambiguous_times( |
@@ -32,7 +32,6 b' use hg::{' | |||||
32 | dirstate::SIZE_NON_NORMAL, |
|
32 | dirstate::SIZE_NON_NORMAL, | |
33 | dirstate_tree::dispatch::DirstateMapMethods, |
|
33 | dirstate_tree::dispatch::DirstateMapMethods, | |
34 | dirstate_tree::on_disk::DirstateV2ParseError, |
|
34 | dirstate_tree::on_disk::DirstateV2ParseError, | |
35 | errors::HgError, |
|
|||
36 | revlog::Node, |
|
35 | revlog::Node, | |
37 | utils::files::normalize_case, |
|
36 | utils::files::normalize_case, | |
38 | utils::hg_path::{HgPath, HgPathBuf}, |
|
37 | utils::hg_path::{HgPath, HgPathBuf}, | |
@@ -181,16 +180,10 b' py_class!(pub class DirstateMap |py| {' | |||||
181 | def dropfile( |
|
180 | def dropfile( | |
182 | &self, |
|
181 | &self, | |
183 | f: PyObject, |
|
182 | f: PyObject, | |
184 | oldstate: PyObject |
|
|||
185 | ) -> PyResult<PyBool> { |
|
183 | ) -> PyResult<PyBool> { | |
186 | self.inner(py).borrow_mut() |
|
184 | self.inner(py).borrow_mut() | |
187 | .drop_file( |
|
185 | .drop_file( | |
188 | HgPath::new(f.extract::<PyBytes>(py)?.data(py)), |
|
186 | HgPath::new(f.extract::<PyBytes>(py)?.data(py)), | |
189 | oldstate.extract::<PyBytes>(py)?.data(py)[0] |
|
|||
190 | .try_into() |
|
|||
191 | .map_err(|e: HgError| { |
|
|||
192 | PyErr::new::<exc::ValueError, _>(py, e.to_string()) |
|
|||
193 | })?, |
|
|||
194 | ) |
|
187 | ) | |
195 | .and_then(|b| Ok(b.to_py_object(py))) |
|
188 | .and_then(|b| Ok(b.to_py_object(py))) | |
196 | .or_else(|e| { |
|
189 | .or_else(|e| { |
@@ -9,7 +9,6 b' use hg::DirstateEntry;' | |||||
9 | use hg::DirstateError; |
|
9 | use hg::DirstateError; | |
10 | use hg::DirstateParents; |
|
10 | use hg::DirstateParents; | |
11 | use hg::DirstateStatus; |
|
11 | use hg::DirstateStatus; | |
12 | use hg::EntryState; |
|
|||
13 | use hg::PatternFileWarning; |
|
12 | use hg::PatternFileWarning; | |
14 | use hg::StateMapIter; |
|
13 | use hg::StateMapIter; | |
15 | use hg::StatusError; |
|
14 | use hg::StatusError; | |
@@ -48,12 +47,8 b' impl DirstateMapMethods for OwningDirsta' | |||||
48 | self.get_mut().remove_file(filename, in_merge) |
|
47 | self.get_mut().remove_file(filename, in_merge) | |
49 | } |
|
48 | } | |
50 |
|
49 | |||
51 | fn drop_file( |
|
50 | fn drop_file(&mut self, filename: &HgPath) -> Result<bool, DirstateError> { | |
52 | &mut self, |
|
51 | self.get_mut().drop_file(filename) | |
53 | filename: &HgPath, |
|
|||
54 | old_state: EntryState, |
|
|||
55 | ) -> Result<bool, DirstateError> { |
|
|||
56 | self.get_mut().drop_file(filename, old_state) |
|
|||
57 | } |
|
52 | } | |
58 |
|
53 | |||
59 | fn clear_ambiguous_times( |
|
54 | fn clear_ambiguous_times( |
General Comments 0
You need to be logged in to leave comments.
Login now