diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py --- a/hgext/fsmonitor/__init__.py +++ b/hgext/fsmonitor/__init__.py @@ -335,7 +335,7 @@ nonnormalset = { f for f, e in self._map.items() - if e.v1_state() != b"n" or e.v1_mtime() == -1 + if e._v1_state() != b"n" or e._v1_mtime() == -1 } copymap = self._map.copymap diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c --- a/mercurial/cext/parsers.c +++ b/mercurial/cext/parsers.c @@ -289,27 +289,6 @@ self->mtime_ns); }; -static PyObject *dirstate_item_v1_state(dirstateItemObject *self) -{ - char state = dirstate_item_c_v1_state(self); - return PyBytes_FromStringAndSize(&state, 1); -}; - -static PyObject *dirstate_item_v1_mode(dirstateItemObject *self) -{ - return PyLong_FromLong(dirstate_item_c_v1_mode(self)); -}; - -static PyObject *dirstate_item_v1_size(dirstateItemObject *self) -{ - return PyLong_FromLong(dirstate_item_c_v1_size(self)); -}; - -static PyObject *dirstate_item_v1_mtime(dirstateItemObject *self) -{ - return PyLong_FromLong(dirstate_item_c_v1_mtime(self)); -}; - static PyObject *dirstate_item_mtime_likely_equal_to(dirstateItemObject *self, PyObject *other) { @@ -403,20 +382,6 @@ return t; } -/* This will never change since it's bound to V1, unlike `dirstate_item_new` */ -static PyObject *dirstate_item_from_v1_meth(PyTypeObject *subtype, - PyObject *args) -{ - /* We do all the initialization here and not a tp_init function because - * dirstate_item is immutable. */ - char state; - int size, mode, mtime; - if (!PyArg_ParseTuple(args, "ciii", &state, &mode, &size, &mtime)) { - return NULL; - } - return (PyObject *)dirstate_item_from_v1_data(state, mode, size, mtime); -}; - static PyObject *dirstate_item_from_v2_meth(PyTypeObject *subtype, PyObject *args) { @@ -526,18 +491,8 @@ static PyMethodDef dirstate_item_methods[] = { {"v2_data", (PyCFunction)dirstate_item_v2_data, METH_NOARGS, "return data suitable for v2 serialization"}, - {"v1_state", (PyCFunction)dirstate_item_v1_state, METH_NOARGS, - "return a \"state\" suitable for v1 serialization"}, - {"v1_mode", (PyCFunction)dirstate_item_v1_mode, METH_NOARGS, - "return a \"mode\" suitable for v1 serialization"}, - {"v1_size", (PyCFunction)dirstate_item_v1_size, METH_NOARGS, - "return a \"size\" suitable for v1 serialization"}, - {"v1_mtime", (PyCFunction)dirstate_item_v1_mtime, METH_NOARGS, - "return a \"mtime\" suitable for v1 serialization"}, {"mtime_likely_equal_to", (PyCFunction)dirstate_item_mtime_likely_equal_to, METH_O, "True if the stored mtime is likely equal to the given mtime"}, - {"from_v1_data", (PyCFunction)dirstate_item_from_v1_meth, - METH_VARARGS | METH_CLASS, "build a new DirstateItem object from V1 data"}, {"from_v2_data", (PyCFunction)dirstate_item_from_v2_meth, METH_VARARGS | METH_CLASS, "build a new DirstateItem object from V2 data"}, {"set_possibly_dirty", (PyCFunction)dirstate_item_set_possibly_dirty, diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py --- a/mercurial/pure/parsers.py +++ b/mercurial/pure/parsers.py @@ -291,15 +291,15 @@ @property def mode(self): - return self.v1_mode() + return self._v1_mode() @property def size(self): - return self.v1_size() + return self._v1_size() @property def mtime(self): - return self.v1_mtime() + return self._v1_mtime() def mtime_likely_equal_to(self, other_mtime): self_sec = self._mtime_s @@ -338,7 +338,7 @@ """ if not self.any_tracked: return b'?' - return self.v1_state() + return self._v1_state() @property def has_fallback_exec(self): @@ -498,7 +498,7 @@ # since we never set _DIRSTATE_V2_HAS_DIRCTORY_MTIME return (flags, self._size or 0, self._mtime_s or 0, self._mtime_ns or 0) - def v1_state(self): + def _v1_state(self): """return a "state" suitable for v1 serialization""" if not self.any_tracked: # the object has no state to record, this is -currently- @@ -513,11 +513,11 @@ else: return b'n' - def v1_mode(self): + def _v1_mode(self): """return a "mode" suitable for v1 serialization""" return self._mode if self._mode is not None else 0 - def v1_size(self): + def _v1_size(self): """return a "size" suitable for v1 serialization""" if not self.any_tracked: # the object has no state to record, this is -currently- @@ -536,7 +536,7 @@ else: return self._size - def v1_mtime(self): + def _v1_mtime(self): """return a "mtime" suitable for v1 serialization""" if not self.any_tracked: # the object has no state to record, this is -currently- @@ -963,10 +963,10 @@ f = b"%s\0%s" % (f, copymap[f]) e = _pack( b">cllll", - e.v1_state(), - e.v1_mode(), - e.v1_size(), - e.v1_mtime(), + e._v1_state(), + e._v1_mode(), + e._v1_size(), + e._v1_mtime(), len(f), ) write(e) diff --git a/rust/hg-cpython/src/dirstate/item.rs b/rust/hg-cpython/src/dirstate/item.rs --- a/rust/hg-cpython/src/dirstate/item.rs +++ b/rust/hg-cpython/src/dirstate/item.rs @@ -8,10 +8,8 @@ use cpython::Python; use cpython::PythonObject; use hg::dirstate::DirstateEntry; -use hg::dirstate::EntryState; use hg::dirstate::TruncatedTimestamp; use std::cell::Cell; -use std::convert::TryFrom; py_class!(pub class DirstateItem |py| { data entry: Cell; @@ -173,27 +171,6 @@ Ok(self.entry(py).get().any_tracked()) } - def v1_state(&self) -> PyResult { - let (state, _mode, _size, _mtime) = self.entry(py).get().v1_data(); - let state_byte: u8 = state.into(); - Ok(PyBytes::new(py, &[state_byte])) - } - - def v1_mode(&self) -> PyResult { - let (_state, mode, _size, _mtime) = self.entry(py).get().v1_data(); - Ok(mode) - } - - def v1_size(&self) -> PyResult { - let (_state, _mode, size, _mtime) = self.entry(py).get().v1_data(); - Ok(size) - } - - def v1_mtime(&self) -> PyResult { - let (_state, _mode, _size, mtime) = self.entry(py).get().v1_data(); - Ok(mtime) - } - def mtime_likely_equal_to(&self, other: (u32, u32, bool)) -> PyResult { if let Some(mtime) = self.entry(py).get().truncated_mtime() { @@ -203,22 +180,6 @@ } } - @classmethod - def from_v1_data( - _cls, - state: PyBytes, - mode: i32, - size: i32, - mtime: i32, - ) -> PyResult { - let state = <[u8; 1]>::try_from(state.data(py)) - .ok() - .and_then(|state| EntryState::try_from(state[0]).ok()) - .ok_or_else(|| PyErr::new::(py, "invalid state"))?; - let entry = DirstateEntry::from_v1_data(state, mode, size, mtime); - DirstateItem::create_instance(py, Cell::new(entry)) - } - def drop_merge_data(&self) -> PyResult { self.update(py, |entry| entry.drop_merge_data()); Ok(PyNone)