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