[PATCH 3 of 6] revlog: rename indexType to HgRevlogIndex_Type as it's a global symbol

Yuya Nishihara yuya at tcha.org
Wed Dec 5 08:43:34 EST 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1543754484 -32400
#      Sun Dec 02 21:41:24 2018 +0900
# Node ID 3842abba948cd7f4bb3fad6805265a35fb94a083
# Parent  7d8bcaf492259a58190f2e34a10db6399ba7b096
revlog: rename indexType to HgRevlogIndex_Type as it's a global symbol

It follows the CPython naming convention, but uses Hg instead of Py.

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -1516,7 +1516,8 @@ static int ntobj_init(nodetreeObject *se
 {
 	PyObject *index;
 	unsigned capacity;
-	if (!PyArg_ParseTuple(args, "O!I", &indexType, &index, &capacity))
+	if (!PyArg_ParseTuple(args, "O!I", &HgRevlogIndex_Type, &index,
+	                      &capacity))
 		return -1;
 	Py_INCREF(index);
 	return nt_init(&self->nt, (indexObject *)index, capacity);
@@ -2581,7 +2582,7 @@ static PyGetSetDef index_getset[] = {
     {NULL} /* Sentinel */
 };
 
-PyTypeObject indexType = {
+PyTypeObject HgRevlogIndex_Type = {
     PyVarObject_HEAD_INIT(NULL, 0) /* header */
     "parsers.index",               /* tp_name */
     sizeof(indexObject),           /* tp_basicsize */
@@ -2637,7 +2638,7 @@ PyObject *parse_index2(PyObject *self, P
 	indexObject *idx;
 	int ret;
 
-	idx = PyObject_New(indexObject, &indexType);
+	idx = PyObject_New(indexObject, &HgRevlogIndex_Type);
 	if (idx == NULL)
 		goto bail;
 
@@ -2714,9 +2715,9 @@ static int rustla_init(rustlazyancestors
 	Py_ssize_t i;
 
 	indexObject *index;
-	if (!PyArg_ParseTuple(args, "O!O!lO!", &indexType, &index, &PyList_Type,
-	                      &initrevsarg, &stoprev, &PyBool_Type,
-	                      &inclusivearg))
+	if (!PyArg_ParseTuple(args, "O!O!lO!", &HgRevlogIndex_Type, &index,
+	                      &PyList_Type, &initrevsarg, &stoprev,
+	                      &PyBool_Type, &inclusivearg))
 		return -1;
 
 	Py_INCREF(index);
@@ -2843,11 +2844,11 @@ static PyTypeObject rustlazyancestorsTyp
 
 void revlog_module_init(PyObject *mod)
 {
-	indexType.tp_new = PyType_GenericNew;
-	if (PyType_Ready(&indexType) < 0)
+	HgRevlogIndex_Type.tp_new = PyType_GenericNew;
+	if (PyType_Ready(&HgRevlogIndex_Type) < 0)
 		return;
-	Py_INCREF(&indexType);
-	PyModule_AddObject(mod, "index", (PyObject *)&indexType);
+	Py_INCREF(&HgRevlogIndex_Type);
+	PyModule_AddObject(mod, "index", (PyObject *)&HgRevlogIndex_Type);
 
 	nodetreeType.tp_new = PyType_GenericNew;
 	if (PyType_Ready(&nodetreeType) < 0)
diff --git a/mercurial/cext/revlog.h b/mercurial/cext/revlog.h
--- a/mercurial/cext/revlog.h
+++ b/mercurial/cext/revlog.h
@@ -10,6 +10,6 @@
 
 #include <Python.h>
 
-extern PyTypeObject indexType;
+extern PyTypeObject HgRevlogIndex_Type;
 
 #endif /* _HG_REVLOG_H_ */


More information about the Mercurial-devel mailing list