diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -443,7 +443,6 @@ def _addpath( self, f, - state=None, mode=0, size=None, mtime=None, @@ -472,7 +471,6 @@ self._updatedfiles.add(f) self._map.addfile( f, - state=state, mode=mode, size=size, mtime=mtime, @@ -499,7 +497,7 @@ mode = s.st_mode size = s.st_size mtime = s[stat.ST_MTIME] - self._addpath(f, b'n', mode, size, mtime) + self._addpath(f, mode=mode, size=size, mtime=mtime) self._map.copymap.pop(f, None) if f in self._map.nonnormalset: self._map.nonnormalset.remove(f) diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py --- a/mercurial/dirstatemap.py +++ b/mercurial/dirstatemap.py @@ -147,7 +147,6 @@ def addfile( self, f, - state=None, mode=0, size=None, mtime=None, @@ -180,9 +179,9 @@ size = NONNORMAL mtime = AMBIGUOUS_TIME else: - assert state != b'a' assert size != FROM_P2 assert size != NONNORMAL + state = b'n' size = size & rangemask mtime = mtime & rangemask assert state is not None @@ -475,7 +474,6 @@ def addfile( self, f, - state=None, mode=0, size=None, mtime=None, @@ -486,7 +484,6 @@ ): return self._rustmap.addfile( f, - state, mode, size, mtime, diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs b/rust/hg-core/src/dirstate/dirstate_map.rs --- a/rust/hg-core/src/dirstate/dirstate_map.rs +++ b/rust/hg-core/src/dirstate/dirstate_map.rs @@ -99,6 +99,7 @@ entry.size = SIZE_NON_NORMAL; entry.mtime = MTIME_UNSET; } else { + entry.state = EntryState::Normal; entry.size = entry.size & V1_RANGEMASK; entry.mtime = entry.mtime & V1_RANGEMASK; } diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs b/rust/hg-core/src/dirstate_tree/dirstate_map.rs --- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs +++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs @@ -750,6 +750,7 @@ entry.size = SIZE_NON_NORMAL; entry.mtime = MTIME_UNSET; } else { + entry.state = EntryState::Normal; entry.size = entry.size & V1_RANGEMASK; entry.mtime = entry.mtime & V1_RANGEMASK; } diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs b/rust/hg-cpython/src/dirstate/dirstate_map.rs --- a/rust/hg-cpython/src/dirstate/dirstate_map.rs +++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs @@ -108,7 +108,6 @@ def addfile( &self, f: PyObject, - state: PyObject, mode: PyObject, size: PyObject, mtime: PyObject, @@ -119,16 +118,6 @@ ) -> PyResult { let f = f.extract::(py)?; let filename = HgPath::new(f.data(py)); - let state = if state.is_none(py) { - // Arbitrary default value - EntryState::Normal - } else { - state.extract::(py)?.data(py)[0] - .try_into() - .map_err(|e: HgError| { - PyErr::new::(py, e.to_string()) - })? - }; let mode = if mode.is_none(py) { // fallback default value 0 @@ -148,7 +137,8 @@ mtime.extract(py)? }; let entry = DirstateEntry { - state: state, + // XXX Arbitrary default value since the value is determined later + state: EntryState::Normal, mode: mode, size: size, mtime: mtime,