[PATCH 5 of 6] phases: rename variable used for owned dict of phasesets

Yuya Nishihara yuya at tcha.org
Sat Jul 18 10:13:01 UTC 2020


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1595064917 -32400
#      Sat Jul 18 18:35:17 2020 +0900
# Node ID fe02e378f9bfd1606b405001871ae7052d68157e
# Parent  ff0940d0168168165b3fd14ebaa7ad476c0aac85
phases: rename variable used for owned dict of phasesets

The phaseroots variable is used for two different objects: borrowed set
and owned dict of sets. It's hard to track which object should have to be
decrefed on error return.

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -788,6 +788,7 @@ static PyObject *compute_phases_map_sets
 	PyObject *roots = Py_None;
 	PyObject *pyphase = NULL;
 	PyObject *pyrev = NULL;
+	PyObject *phasesetsdict = NULL;
 	PyObject *phaseroots = NULL;
 	PyObject *phasesets[4] = {NULL, NULL, NULL, NULL};
 	Py_ssize_t len = index_length(self);
@@ -875,14 +876,16 @@ static PyObject *compute_phases_map_sets
 		}
 		Py_DECREF(pyrev);
 	}
-	phaseroots = _dict_new_presized(numphases);
-	if (phaseroots == NULL)
+
+	phasesetsdict = _dict_new_presized(numphases);
+	if (phasesetsdict == NULL)
 		goto release;
 	for (i = 0; i < numphases; ++i) {
 		pyphase = PyInt_FromLong(trackedphases[i]);
 		if (pyphase == NULL)
 			goto release;
-		if (PyDict_SetItem(phaseroots, pyphase, phasesets[i]) == -1) {
+		if (PyDict_SetItem(phasesetsdict, pyphase, phasesets[i]) ==
+		    -1) {
 			Py_DECREF(pyphase);
 			goto release;
 		}
@@ -890,12 +893,12 @@ static PyObject *compute_phases_map_sets
 		phasesets[i] = NULL;
 	}
 
-	return Py_BuildValue("nN", len, phaseroots);
+	return Py_BuildValue("nN", len, phasesetsdict);
 
 release:
 	for (i = 0; i < numphases; ++i)
 		Py_XDECREF(phasesets[i]);
-	Py_XDECREF(phaseroots);
+	Py_XDECREF(phasesetsdict);
 
 	free(phases);
 	return NULL;



More information about the Mercurial-devel mailing list