# HG changeset patch # User Yuya Nishihara <yuya@tcha.org> # Date 1595064917 -32400 # Sat Jul 18 18:35:17 2020 +0900 # Node ID ba5e4b11d085301a06d55aec02633a660ba1754b # Parent b00fa1782efe63ce76cab537495a607ee8289a2d 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 @@ -793,6 +793,7 @@ 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); @@ -880,14 +881,16 @@ } 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; } @@ -895,12 +898,12 @@ 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;