changeset 47925:ba9491be5e0c

dirstate-item: drop the deprecated __getitem__ variante This is deprecated since 5.9. Differential Revision: https://phab.mercurial-scm.org/D11362
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 26 Aug 2021 16:39:00 +0200
parents 66ff8d3865b3
children 05f2be3affe3
files mercurial/cext/parsers.c mercurial/pure/parsers.py
diffstat 2 files changed, 1 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cext/parsers.c	Mon Aug 30 12:25:57 2021 +0200
+++ b/mercurial/cext/parsers.c	Thu Aug 26 16:39:00 2021 +0200
@@ -167,40 +167,6 @@
 	PyObject_Del(o);
 }
 
-static Py_ssize_t dirstate_item_length(PyObject *o)
-{
-	return 4;
-}
-
-static PyObject *dirstate_item_item(PyObject *o, Py_ssize_t i)
-{
-	dirstateItemObject *t = (dirstateItemObject *)o;
-	switch (i) {
-	case 0:
-		return PyBytes_FromStringAndSize(&t->state, 1);
-	case 1:
-		return PyInt_FromLong(t->mode);
-	case 2:
-		return PyInt_FromLong(t->size);
-	case 3:
-		return PyInt_FromLong(t->mtime);
-	default:
-		PyErr_SetString(PyExc_IndexError, "index out of range");
-		return NULL;
-	}
-}
-
-static PySequenceMethods dirstate_item_sq = {
-    dirstate_item_length, /* sq_length */
-    0,                    /* sq_concat */
-    0,                    /* sq_repeat */
-    dirstate_item_item,   /* sq_item */
-    0,                    /* sq_ass_item */
-    0,                    /* sq_contains */
-    0,                    /* sq_inplace_concat */
-    0                     /* sq_inplace_repeat */
-};
-
 static PyObject *dirstate_item_v1_state(dirstateItemObject *self)
 {
 	return PyBytes_FromStringAndSize(&self->state, 1);
@@ -562,7 +528,7 @@
     0,                                 /* tp_compare */
     0,                                 /* tp_repr */
     0,                                 /* tp_as_number */
-    &dirstate_item_sq,                 /* tp_as_sequence */
+    0,                                 /* tp_as_sequence */
     0,                                 /* tp_as_mapping */
     0,                                 /* tp_hash  */
     0,                                 /* tp_call */
--- a/mercurial/pure/parsers.py	Mon Aug 30 12:25:57 2021 +0200
+++ b/mercurial/pure/parsers.py	Thu Aug 26 16:39:00 2021 +0200
@@ -223,26 +223,6 @@
         self._size = size
         self._mtime = 0
 
-    def __getitem__(self, idx):
-        if idx == 0 or idx == -4:
-            msg = b"do not use item[x], use item.state"
-            util.nouideprecwarn(msg, b'6.0', stacklevel=2)
-            return self._state
-        elif idx == 1 or idx == -3:
-            msg = b"do not use item[x], use item.mode"
-            util.nouideprecwarn(msg, b'6.0', stacklevel=2)
-            return self._mode
-        elif idx == 2 or idx == -2:
-            msg = b"do not use item[x], use item.size"
-            util.nouideprecwarn(msg, b'6.0', stacklevel=2)
-            return self._size
-        elif idx == 3 or idx == -1:
-            msg = b"do not use item[x], use item.mtime"
-            util.nouideprecwarn(msg, b'6.0', stacklevel=2)
-            return self._mtime
-        else:
-            raise IndexError(idx)
-
     @property
     def mode(self):
         return self._mode