Patchwork D10982: dirstate-item: rename the class to DirstateItem

login
register
mail settings
Submitter phabricator
Date July 4, 2021, 9:57 p.m.
Message ID <differential-rev-PHID-DREV-adwcigc7facwlrafo7xn-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49296/
State Superseded
Headers show

Comments

phabricator - July 4, 2021, 9:57 p.m.
marmoute created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The object is no longer a tuple, so it seems clearer to rename it (and its
  associated method)

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10982

AFFECTED FILES
  hgext/git/dirstate.py
  mercurial/cext/charencode.c
  mercurial/cext/dirs.c
  mercurial/cext/parsers.c
  mercurial/cext/parsers.pyi
  mercurial/cext/util.h
  mercurial/dirstate.py
  mercurial/dirstatemap.py
  mercurial/interfaces/dirstate.py
  mercurial/pure/parsers.py
  rust/hg-cpython/src/dirstate.rs
  rust/hg-cpython/src/dirstate/dirstate_map.rs
  rust/hg-cpython/src/parsers.rs
  tests/fakedirstatewritetime.py

CHANGE DETAILS




To: marmoute, durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/fakedirstatewritetime.py b/tests/fakedirstatewritetime.py
--- a/tests/fakedirstatewritetime.py
+++ b/tests/fakedirstatewritetime.py
@@ -43,7 +43,7 @@ 
     actualnow = int(now)
     for f, e in dmap.items():
         if e[0] == 'n' and e[3] == actualnow:
-            e = parsers.dirstatetuple(e[0], e[1], e[2], -1)
+            e = parsers.DirstateItem(e[0], e[1], e[2], -1)
             dmap[f] = e
 
     return orig(dmap, copymap, pl, fakenow)
diff --git a/rust/hg-cpython/src/parsers.rs b/rust/hg-cpython/src/parsers.rs
--- a/rust/hg-cpython/src/parsers.rs
+++ b/rust/hg-cpython/src/parsers.rs
@@ -20,7 +20,7 @@ 
 };
 use std::convert::TryInto;
 
-use crate::dirstate::{extract_dirstate, make_dirstate_tuple};
+use crate::dirstate::{extract_dirstate, make_dirstate_item};
 
 fn parse_dirstate_wrapper(
     py: Python,
@@ -43,7 +43,7 @@ 
                 dmap.set_item(
                     py,
                     PyBytes::new(py, filename.as_bytes()),
-                    make_dirstate_tuple(py, entry)?,
+                    make_dirstate_item(py, entry)?,
                 )?;
             }
             for (path, copy_path) in copy_map {
@@ -105,7 +105,7 @@ 
                 dmap.set_item(
                     py,
                     PyBytes::new(py, filename.as_bytes()),
-                    make_dirstate_tuple(py, &entry)?,
+                    make_dirstate_item(py, &entry)?,
                 )?;
             }
             Ok(PyBytes::new(py, &packed))
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
@@ -19,7 +19,7 @@ 
 
 use crate::{
     dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator},
-    dirstate::make_dirstate_tuple,
+    dirstate::make_dirstate_item,
     dirstate::non_normal_entries::{
         NonNormalEntries, NonNormalEntriesIterator,
     },
@@ -98,7 +98,7 @@ 
             .map_err(|e| v2_error(py, e))?
         {
             Some(entry) => {
-                Ok(Some(make_dirstate_tuple(py, &entry)?))
+                Ok(Some(make_dirstate_item(py, &entry)?))
             },
             None => Ok(default)
         }
@@ -370,7 +370,7 @@ 
             .map_err(|e| v2_error(py, e))?
         {
             Some(entry) => {
-                Ok(make_dirstate_tuple(py, &entry)?)
+                Ok(make_dirstate_item(py, &entry)?)
             },
             None => Err(PyErr::new::<exc::KeyError, _>(
                 py,
@@ -548,7 +548,7 @@ 
         let (f, entry) = res.map_err(|e| v2_error(py, e))?;
         Ok(Some((
             PyBytes::new(py, f.as_bytes()),
-            make_dirstate_tuple(py, &entry)?,
+            make_dirstate_item(py, &entry)?,
         )))
     }
 }
diff --git a/rust/hg-cpython/src/dirstate.rs b/rust/hg-cpython/src/dirstate.rs
--- a/rust/hg-cpython/src/dirstate.rs
+++ b/rust/hg-cpython/src/dirstate.rs
@@ -38,8 +38,8 @@ 
 // for a pure Python tuple of the same effective structure to be used,
 // rendering this type and the capsule below useless.
 py_capsule_fn!(
-    from mercurial.cext.parsers import make_dirstate_tuple_CAPI
-        as make_dirstate_tuple_capi
+    from mercurial.cext.parsers import make_dirstate_item_CAPI
+        as make_dirstate_item_capi
         signature (
             state: c_char,
             mode: c_int,
@@ -48,12 +48,12 @@ 
         ) -> *mut RawPyObject
 );
 
-pub fn make_dirstate_tuple(
+pub fn make_dirstate_item(
     py: Python,
     entry: &DirstateEntry,
 ) -> PyResult<PyObject> {
     // might be silly to retrieve capsule function in hot loop
-    let make = make_dirstate_tuple_capi::retrieve(py)?;
+    let make = make_dirstate_item_capi::retrieve(py)?;
 
     let &DirstateEntry {
         state,
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -40,7 +40,7 @@ 
 NONNORMAL = -1
 
 
-class dirstatetuple(object):
+class DirstateItem(object):
     """represente a dirstate entry
 
     It constains:
@@ -530,7 +530,7 @@ 
         if b'\0' in f:
             f, c = f.split(b'\0')
             copymap[f] = c
-        dmap[f] = dirstatetuple(*e[:4])
+        dmap[f] = DirstateItem(*e[:4])
     return parents
 
 
@@ -550,7 +550,7 @@ 
             # dirstate, forcing future 'status' calls to compare the
             # contents of the file if the size is the same. This prevents
             # mistakenly treating such files as clean.
-            e = dirstatetuple(e[0], e[1], e[2], -1)
+            e = DirstateItem(e[0], e[1], e[2], -1)
             dmap[f] = e
 
         if f in copymap:
diff --git a/mercurial/interfaces/dirstate.py b/mercurial/interfaces/dirstate.py
--- a/mercurial/interfaces/dirstate.py
+++ b/mercurial/interfaces/dirstate.py
@@ -84,7 +84,7 @@ 
         """Iterate the dirstate's contained filenames as bytestrings."""
 
     def items():
-        """Iterate the dirstate's entries as (filename, dirstatetuple).
+        """Iterate the dirstate's entries as (filename, DirstateItem.
 
         As usual, filename is a bytestring.
         """
diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -23,7 +23,7 @@ 
 
 propertycache = util.propertycache
 
-dirstatetuple = parsers.dirstatetuple
+DirstateItem = parsers.DirstateItem
 
 
 # a special value used internally for `size` if the file come from the other parent
@@ -194,7 +194,7 @@ 
             self._dirs.addpath(f)
         if old_entry is None and "_alldirs" in self.__dict__:
             self._alldirs.addpath(f)
-        self._map[f] = dirstatetuple(state, mode, size, mtime)
+        self._map[f] = DirstateItem(state, mode, size, mtime)
         if state != b'n' or mtime == AMBIGUOUS_TIME:
             self.nonnormalset.add(f)
         if size == FROM_P2:
@@ -232,7 +232,7 @@ 
         if "filefoldmap" in self.__dict__:
             normed = util.normcase(f)
             self.filefoldmap.pop(normed, None)
-        self._map[f] = dirstatetuple(b'r', 0, size, 0)
+        self._map[f] = DirstateItem(b'r', 0, size, 0)
         self.nonnormalset.add(f)
 
     def dropfile(self, f):
@@ -261,7 +261,7 @@ 
         for f in files:
             e = self.get(f)
             if e is not None and e[0] == b'n' and e[3] == now:
-                self._map[f] = dirstatetuple(e[0], e[1], e[2], AMBIGUOUS_TIME)
+                self._map[f] = DirstateItem(e[0], e[1], e[2], AMBIGUOUS_TIME)
                 self.nonnormalset.add(f)
 
     def nonnormalentries(self):
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -45,7 +45,7 @@ 
 filecache = scmutil.filecache
 _rangemask = dirstatemap.rangemask
 
-dirstatetuple = parsers.dirstatetuple
+DirstateItem = parsers.DirstateItem
 
 
 class repocache(filecache):
diff --git a/mercurial/cext/util.h b/mercurial/cext/util.h
--- a/mercurial/cext/util.h
+++ b/mercurial/cext/util.h
@@ -28,11 +28,11 @@ 
 	int mode;
 	int size;
 	int mtime;
-} dirstateTupleObject;
+} dirstateItemObject;
 /* clang-format on */
 
-extern PyTypeObject dirstateTupleType;
-#define dirstate_tuple_check(op) (Py_TYPE(op) == &dirstateTupleType)
+extern PyTypeObject dirstateItemType;
+#define dirstate_tuple_check(op) (Py_TYPE(op) == &dirstateItemType)
 
 #ifndef MIN
 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
diff --git a/mercurial/cext/parsers.pyi b/mercurial/cext/parsers.pyi
--- a/mercurial/cext/parsers.pyi
+++ b/mercurial/cext/parsers.pyi
@@ -12,7 +12,7 @@ 
 version: int
 versionerrortext: str
 
-class dirstatetuple:
+class DirstateItem:
     __doc__: str
 
     def __len__(self) -> int: ...
diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -43,11 +43,11 @@ 
 	return _dict_new_presized(expected_size);
 }
 
-static inline dirstateTupleObject *make_dirstate_tuple(char state, int mode,
-                                                       int size, int mtime)
+static inline dirstateItemObject *make_dirstate_item(char state, int mode,
+                                                     int size, int mtime)
 {
-	dirstateTupleObject *t =
-	    PyObject_New(dirstateTupleObject, &dirstateTupleType);
+	dirstateItemObject *t =
+	    PyObject_New(dirstateItemObject, &dirstateItemType);
 	if (!t) {
 		return NULL;
 	}
@@ -58,19 +58,19 @@ 
 	return t;
 }
 
-static PyObject *dirstate_tuple_new(PyTypeObject *subtype, PyObject *args,
-                                    PyObject *kwds)
+static PyObject *dirstate_item_new(PyTypeObject *subtype, PyObject *args,
+                                   PyObject *kwds)
 {
 	/* We do all the initialization here and not a tp_init function because
-	 * dirstate_tuple is immutable. */
-	dirstateTupleObject *t;
+	 * dirstate_item is immutable. */
+	dirstateItemObject *t;
 	char state;
 	int size, mode, mtime;
 	if (!PyArg_ParseTuple(args, "ciii", &state, &mode, &size, &mtime)) {
 		return NULL;
 	}
 
-	t = (dirstateTupleObject *)subtype->tp_alloc(subtype, 1);
+	t = (dirstateItemObject *)subtype->tp_alloc(subtype, 1);
 	if (!t) {
 		return NULL;
 	}
@@ -82,19 +82,19 @@ 
 	return (PyObject *)t;
 }
 
-static void dirstate_tuple_dealloc(PyObject *o)
+static void dirstate_item_dealloc(PyObject *o)
 {
 	PyObject_Del(o);
 }
 
-static Py_ssize_t dirstate_tuple_length(PyObject *o)
+static Py_ssize_t dirstate_item_length(PyObject *o)
 {
 	return 4;
 }
 
-static PyObject *dirstate_tuple_item(PyObject *o, Py_ssize_t i)
+static PyObject *dirstate_item_item(PyObject *o, Py_ssize_t i)
 {
-	dirstateTupleObject *t = (dirstateTupleObject *)o;
+	dirstateItemObject *t = (dirstateItemObject *)o;
 	switch (i) {
 	case 0:
 		return PyBytes_FromStringAndSize(&t->state, 1);
@@ -110,38 +110,38 @@ 
 	}
 }
 
-static PySequenceMethods dirstate_tuple_sq = {
-    dirstate_tuple_length, /* sq_length */
-    0,                     /* sq_concat */
-    0,                     /* sq_repeat */
-    dirstate_tuple_item,   /* sq_item */
-    0,                     /* sq_ass_item */
-    0,                     /* sq_contains */
-    0,                     /* sq_inplace_concat */
-    0                      /* sq_inplace_repeat */
+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 *dirstatetuple_v1_state(dirstateTupleObject *self)
+static PyObject *dirstate_item_v1_state(dirstateItemObject *self)
 {
 	return PyBytes_FromStringAndSize(&self->state, 1);
 };
 
-static PyObject *dirstatetuple_v1_mode(dirstateTupleObject *self)
+static PyObject *dirstate_item_v1_mode(dirstateItemObject *self)
 {
 	return PyInt_FromLong(self->mode);
 };
 
-static PyObject *dirstatetuple_v1_size(dirstateTupleObject *self)
+static PyObject *dirstate_item_v1_size(dirstateItemObject *self)
 {
 	return PyInt_FromLong(self->size);
 };
 
-static PyObject *dirstatetuple_v1_mtime(dirstateTupleObject *self)
+static PyObject *dirstate_item_v1_mtime(dirstateItemObject *self)
 {
 	return PyInt_FromLong(self->mtime);
 };
 
-static PyObject *dirstatetuple_need_delay(dirstateTupleObject *self,
+static PyObject *dirstate_item_need_delay(dirstateItemObject *self,
                                           PyObject *value)
 {
 	long now;
@@ -155,41 +155,41 @@ 
 	}
 };
 
-static PyMethodDef dirstatetuple_methods[] = {
-    {"v1_state", (PyCFunction)dirstatetuple_v1_state, METH_NOARGS,
+static PyMethodDef dirstate_item_methods[] = {
+    {"v1_state", (PyCFunction)dirstate_item_v1_state, METH_NOARGS,
      "return a \"state\" suitable for v1 serialization"},
-    {"v1_mode", (PyCFunction)dirstatetuple_v1_mode, METH_NOARGS,
+    {"v1_mode", (PyCFunction)dirstate_item_v1_mode, METH_NOARGS,
      "return a \"mode\" suitable for v1 serialization"},
-    {"v1_size", (PyCFunction)dirstatetuple_v1_size, METH_NOARGS,
+    {"v1_size", (PyCFunction)dirstate_item_v1_size, METH_NOARGS,
      "return a \"size\" suitable for v1 serialization"},
-    {"v1_mtime", (PyCFunction)dirstatetuple_v1_mtime, METH_NOARGS,
+    {"v1_mtime", (PyCFunction)dirstate_item_v1_mtime, METH_NOARGS,
      "return a \"mtime\" suitable for v1 serialization"},
-    {"need_delay", (PyCFunction)dirstatetuple_need_delay, METH_O,
+    {"need_delay", (PyCFunction)dirstate_item_need_delay, METH_O,
      "True if the stored mtime would be ambiguous with the current time"},
     {NULL} /* Sentinel */
 };
 
-static PyObject *dirstatetuple_get_mode(dirstateTupleObject *self)
+static PyObject *dirstate_item_get_mode(dirstateItemObject *self)
 {
 	return PyInt_FromLong(self->mode);
 };
 
-static PyObject *dirstatetuple_get_size(dirstateTupleObject *self)
+static PyObject *dirstate_item_get_size(dirstateItemObject *self)
 {
 	return PyInt_FromLong(self->size);
 };
 
-static PyObject *dirstatetuple_get_mtime(dirstateTupleObject *self)
+static PyObject *dirstate_item_get_mtime(dirstateItemObject *self)
 {
 	return PyInt_FromLong(self->mtime);
 };
 
-static PyObject *dirstatetuple_get_state(dirstateTupleObject *self)
+static PyObject *dirstate_item_get_state(dirstateItemObject *self)
 {
 	return PyBytes_FromStringAndSize(&self->state, 1);
 };
 
-static PyObject *dirstatetuple_get_tracked(dirstateTupleObject *self)
+static PyObject *dirstate_item_get_tracked(dirstateItemObject *self)
 {
 	if (self->state == 'a' || self->state == 'm' || self->state == 'n') {
 		Py_RETURN_TRUE;
@@ -198,7 +198,7 @@ 
 	}
 };
 
-static PyObject *dirstatetuple_get_added(dirstateTupleObject *self)
+static PyObject *dirstate_item_get_added(dirstateItemObject *self)
 {
 	if (self->state == 'a') {
 		Py_RETURN_TRUE;
@@ -207,7 +207,7 @@ 
 	}
 };
 
-static PyObject *dirstatetuple_get_merged(dirstateTupleObject *self)
+static PyObject *dirstate_item_get_merged(dirstateItemObject *self)
 {
 	if (self->state == 'm') {
 		Py_RETURN_TRUE;
@@ -216,7 +216,7 @@ 
 	}
 };
 
-static PyObject *dirstatetuple_get_merged_removed(dirstateTupleObject *self)
+static PyObject *dirstate_item_get_merged_removed(dirstateItemObject *self)
 {
 	if (self->state == 'r' && self->size == dirstate_v1_nonnormal) {
 		Py_RETURN_TRUE;
@@ -225,7 +225,7 @@ 
 	}
 };
 
-static PyObject *dirstatetuple_get_from_p2(dirstateTupleObject *self)
+static PyObject *dirstate_item_get_from_p2(dirstateItemObject *self)
 {
 	if (self->state == 'n' && self->size == dirstate_v1_from_p2) {
 		Py_RETURN_TRUE;
@@ -234,7 +234,7 @@ 
 	}
 };
 
-static PyObject *dirstatetuple_get_from_p2_removed(dirstateTupleObject *self)
+static PyObject *dirstate_item_get_from_p2_removed(dirstateItemObject *self)
 {
 	if (self->state == 'r' && self->size == dirstate_v1_from_p2) {
 		Py_RETURN_TRUE;
@@ -243,7 +243,7 @@ 
 	}
 };
 
-static PyObject *dirstatetuple_get_removed(dirstateTupleObject *self)
+static PyObject *dirstate_item_get_removed(dirstateItemObject *self)
 {
 	if (self->state == 'r') {
 		Py_RETURN_TRUE;
@@ -252,62 +252,62 @@ 
 	}
 };
 
-static PyGetSetDef dirstatetuple_getset[] = {
-    {"mode", (getter)dirstatetuple_get_mode, NULL, "mode", NULL},
-    {"size", (getter)dirstatetuple_get_size, NULL, "size", NULL},
-    {"mtime", (getter)dirstatetuple_get_mtime, NULL, "mtime", NULL},
-    {"state", (getter)dirstatetuple_get_state, NULL, "state", NULL},
-    {"tracked", (getter)dirstatetuple_get_tracked, NULL, "tracked", NULL},
-    {"added", (getter)dirstatetuple_get_added, NULL, "added", NULL},
-    {"merged_removed", (getter)dirstatetuple_get_merged_removed, NULL,
+static PyGetSetDef dirstate_item_getset[] = {
+    {"mode", (getter)dirstate_item_get_mode, NULL, "mode", NULL},
+    {"size", (getter)dirstate_item_get_size, NULL, "size", NULL},
+    {"mtime", (getter)dirstate_item_get_mtime, NULL, "mtime", NULL},
+    {"state", (getter)dirstate_item_get_state, NULL, "state", NULL},
+    {"tracked", (getter)dirstate_item_get_tracked, NULL, "tracked", NULL},
+    {"added", (getter)dirstate_item_get_added, NULL, "added", NULL},
+    {"merged_removed", (getter)dirstate_item_get_merged_removed, NULL,
      "merged_removed", NULL},
-    {"merged", (getter)dirstatetuple_get_merged, NULL, "merged", NULL},
-    {"from_p2_removed", (getter)dirstatetuple_get_from_p2_removed, NULL,
+    {"merged", (getter)dirstate_item_get_merged, NULL, "merged", NULL},
+    {"from_p2_removed", (getter)dirstate_item_get_from_p2_removed, NULL,
      "from_p2_removed", NULL},
-    {"from_p2", (getter)dirstatetuple_get_from_p2, NULL, "from_p2", NULL},
-    {"removed", (getter)dirstatetuple_get_removed, NULL, "removed", NULL},
+    {"from_p2", (getter)dirstate_item_get_from_p2, NULL, "from_p2", NULL},
+    {"removed", (getter)dirstate_item_get_removed, NULL, "removed", NULL},
     {NULL} /* Sentinel */
 };
 
-PyTypeObject dirstateTupleType = {
-    PyVarObject_HEAD_INIT(NULL, 0)      /* header */
-    "dirstate_tuple",                   /* tp_name */
-    sizeof(dirstateTupleObject),        /* tp_basicsize */
-    0,                                  /* tp_itemsize */
-    (destructor)dirstate_tuple_dealloc, /* tp_dealloc */
-    0,                                  /* tp_print */
-    0,                                  /* tp_getattr */
-    0,                                  /* tp_setattr */
-    0,                                  /* tp_compare */
-    0,                                  /* tp_repr */
-    0,                                  /* tp_as_number */
-    &dirstate_tuple_sq,                 /* tp_as_sequence */
-    0,                                  /* tp_as_mapping */
-    0,                                  /* tp_hash  */
-    0,                                  /* tp_call */
-    0,                                  /* tp_str */
-    0,                                  /* tp_getattro */
-    0,                                  /* tp_setattro */
-    0,                                  /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT,                 /* tp_flags */
-    "dirstate tuple",                   /* tp_doc */
-    0,                                  /* tp_traverse */
-    0,                                  /* tp_clear */
-    0,                                  /* tp_richcompare */
-    0,                                  /* tp_weaklistoffset */
-    0,                                  /* tp_iter */
-    0,                                  /* tp_iternext */
-    dirstatetuple_methods,              /* tp_methods */
-    0,                                  /* tp_members */
-    dirstatetuple_getset,               /* tp_getset */
-    0,                                  /* tp_base */
-    0,                                  /* tp_dict */
-    0,                                  /* tp_descr_get */
-    0,                                  /* tp_descr_set */
-    0,                                  /* tp_dictoffset */
-    0,                                  /* tp_init */
-    0,                                  /* tp_alloc */
-    dirstate_tuple_new,                 /* tp_new */
+PyTypeObject dirstateItemType = {
+    PyVarObject_HEAD_INIT(NULL, 0)     /* header */
+    "dirstate_tuple",                  /* tp_name */
+    sizeof(dirstateItemObject),        /* tp_basicsize */
+    0,                                 /* tp_itemsize */
+    (destructor)dirstate_item_dealloc, /* tp_dealloc */
+    0,                                 /* tp_print */
+    0,                                 /* tp_getattr */
+    0,                                 /* tp_setattr */
+    0,                                 /* tp_compare */
+    0,                                 /* tp_repr */
+    0,                                 /* tp_as_number */
+    &dirstate_item_sq,                 /* tp_as_sequence */
+    0,                                 /* tp_as_mapping */
+    0,                                 /* tp_hash  */
+    0,                                 /* tp_call */
+    0,                                 /* tp_str */
+    0,                                 /* tp_getattro */
+    0,                                 /* tp_setattro */
+    0,                                 /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT,                /* tp_flags */
+    "dirstate tuple",                  /* tp_doc */
+    0,                                 /* tp_traverse */
+    0,                                 /* tp_clear */
+    0,                                 /* tp_richcompare */
+    0,                                 /* tp_weaklistoffset */
+    0,                                 /* tp_iter */
+    0,                                 /* tp_iternext */
+    dirstate_item_methods,             /* tp_methods */
+    0,                                 /* tp_members */
+    dirstate_item_getset,              /* tp_getset */
+    0,                                 /* tp_base */
+    0,                                 /* tp_dict */
+    0,                                 /* tp_descr_get */
+    0,                                 /* tp_descr_set */
+    0,                                 /* tp_dictoffset */
+    0,                                 /* tp_init */
+    0,                                 /* tp_alloc */
+    dirstate_item_new,                 /* tp_new */
 };
 
 static PyObject *parse_dirstate(PyObject *self, PyObject *args)
@@ -364,7 +364,7 @@ 
 		}
 
 		entry =
-		    (PyObject *)make_dirstate_tuple(state, mode, size, mtime);
+		    (PyObject *)make_dirstate_item(state, mode, size, mtime);
 		cpos = memchr(cur, 0, flen);
 		if (cpos) {
 			fname = PyBytes_FromStringAndSize(cur, cpos - cur);
@@ -425,13 +425,13 @@ 
 
 	pos = 0;
 	while (PyDict_Next(dmap, &pos, &fname, &v)) {
-		dirstateTupleObject *t;
+		dirstateItemObject *t;
 		if (!dirstate_tuple_check(v)) {
 			PyErr_SetString(PyExc_TypeError,
 			                "expected a dirstate tuple");
 			goto bail;
 		}
-		t = (dirstateTupleObject *)v;
+		t = (dirstateItemObject *)v;
 
 		if (t->state == 'n' && t->size == -2) {
 			if (PySet_Add(otherpset, fname) == -1) {
@@ -526,7 +526,7 @@ 
 	p += 20;
 
 	for (pos = 0; PyDict_Next(map, &pos, &k, &v);) {
-		dirstateTupleObject *tuple;
+		dirstateItemObject *tuple;
 		char state;
 		int mode, size, mtime;
 		Py_ssize_t len, l;
@@ -538,7 +538,7 @@ 
 			                "expected a dirstate tuple");
 			goto bail;
 		}
-		tuple = (dirstateTupleObject *)v;
+		tuple = (dirstateItemObject *)v;
 
 		state = tuple->state;
 		mode = tuple->mode;
@@ -548,7 +548,7 @@ 
 			/* See pure/parsers.py:pack_dirstate for why we do
 			 * this. */
 			mtime = -1;
-			mtime_unset = (PyObject *)make_dirstate_tuple(
+			mtime_unset = (PyObject *)make_dirstate_item(
 			    state, mode, size, mtime);
 			if (!mtime_unset) {
 				goto bail;
@@ -841,17 +841,16 @@ 
 	revlog_module_init(mod);
 
 	capsule = PyCapsule_New(
-	    make_dirstate_tuple,
-	    "mercurial.cext.parsers.make_dirstate_tuple_CAPI", NULL);
+	    make_dirstate_item,
+	    "mercurial.cext.parsers.make_dirstate_item_CAPI", NULL);
 	if (capsule != NULL)
-		PyModule_AddObject(mod, "make_dirstate_tuple_CAPI", capsule);
+		PyModule_AddObject(mod, "make_dirstate_item_CAPI", capsule);
 
-	if (PyType_Ready(&dirstateTupleType) < 0) {
+	if (PyType_Ready(&dirstateItemType) < 0) {
 		return;
 	}
-	Py_INCREF(&dirstateTupleType);
-	PyModule_AddObject(mod, "dirstatetuple",
-	                   (PyObject *)&dirstateTupleType);
+	Py_INCREF(&dirstateItemType);
+	PyModule_AddObject(mod, "DirstateItem", (PyObject *)&dirstateItemType);
 }
 
 static int check_python_version(void)
diff --git a/mercurial/cext/dirs.c b/mercurial/cext/dirs.c
--- a/mercurial/cext/dirs.c
+++ b/mercurial/cext/dirs.c
@@ -177,7 +177,7 @@ 
 				                "expected a dirstate tuple");
 				return -1;
 			}
-			if (((dirstateTupleObject *)value)->state == skipchar)
+			if (((dirstateItemObject *)value)->state == skipchar)
 				continue;
 		}
 
diff --git a/mercurial/cext/charencode.c b/mercurial/cext/charencode.c
--- a/mercurial/cext/charencode.c
+++ b/mercurial/cext/charencode.c
@@ -223,7 +223,7 @@ 
 	PyObject *file_foldmap = NULL;
 	enum normcase_spec spec;
 	PyObject *k, *v;
-	dirstateTupleObject *tuple;
+	dirstateItemObject *tuple;
 	Py_ssize_t pos = 0;
 	const char *table;
 
@@ -263,7 +263,7 @@ 
 			goto quit;
 		}
 
-		tuple = (dirstateTupleObject *)v;
+		tuple = (dirstateItemObject *)v;
 		if (tuple->state != 'r') {
 			PyObject *normed;
 			if (table != NULL) {
diff --git a/hgext/git/dirstate.py b/hgext/git/dirstate.py
--- a/hgext/git/dirstate.py
+++ b/hgext/git/dirstate.py
@@ -111,7 +111,7 @@ 
 
     def items(self):
         for ie in self.git.index:
-            yield ie.path, None  # value should be a dirstatetuple
+            yield ie.path, None  # value should be a DirstateItem
 
     # py2,3 compat forward
     iteritems = items