Show More
@@ -1286,19 +1286,21 b' static PyObject *compute_phases_map_sets' | |||||
1286 | long phase; |
|
1286 | long phase; | |
1287 |
|
1287 | |||
1288 | if (!PyArg_ParseTuple(args, "O", &roots)) |
|
1288 | if (!PyArg_ParseTuple(args, "O", &roots)) | |
1289 |
goto |
|
1289 | goto done; | |
1290 | if (roots == NULL || !PyList_Check(roots)) |
|
1290 | if (roots == NULL || !PyList_Check(roots)) | |
1291 |
goto |
|
1291 | goto done; | |
1292 |
|
1292 | |||
1293 | phases = calloc(len, 1); /* phase per rev: {0: public, 1: draft, 2: secret} */ |
|
1293 | phases = calloc(len, 1); /* phase per rev: {0: public, 1: draft, 2: secret} */ | |
1294 | if (phases == NULL) |
|
1294 | if (phases == NULL) { | |
1295 | goto release_none; |
|
1295 | PyErr_NoMemory(); | |
|
1296 | goto done; | |||
|
1297 | } | |||
1296 | /* Put the phase information of all the roots in phases */ |
|
1298 | /* Put the phase information of all the roots in phases */ | |
1297 | numphase = PyList_GET_SIZE(roots)+1; |
|
1299 | numphase = PyList_GET_SIZE(roots)+1; | |
1298 | minrevallphases = len + 1; |
|
1300 | minrevallphases = len + 1; | |
1299 | phasessetlist = PyList_New(numphase); |
|
1301 | phasessetlist = PyList_New(numphase); | |
1300 | if (phasessetlist == NULL) |
|
1302 | if (phasessetlist == NULL) | |
1301 |
goto |
|
1303 | goto done; | |
1302 |
|
1304 | |||
1303 | PyList_SET_ITEM(phasessetlist, 0, Py_None); |
|
1305 | PyList_SET_ITEM(phasessetlist, 0, Py_None); | |
1304 | Py_INCREF(Py_None); |
|
1306 | Py_INCREF(Py_None); | |
@@ -1307,13 +1309,13 b' static PyObject *compute_phases_map_sets' | |||||
1307 | phaseroots = PyList_GET_ITEM(roots, i); |
|
1309 | phaseroots = PyList_GET_ITEM(roots, i); | |
1308 | phaseset = PySet_New(NULL); |
|
1310 | phaseset = PySet_New(NULL); | |
1309 | if (phaseset == NULL) |
|
1311 | if (phaseset == NULL) | |
1310 |
goto release |
|
1312 | goto release; | |
1311 | PyList_SET_ITEM(phasessetlist, i+1, phaseset); |
|
1313 | PyList_SET_ITEM(phasessetlist, i+1, phaseset); | |
1312 | if (!PyList_Check(phaseroots)) |
|
1314 | if (!PyList_Check(phaseroots)) | |
1313 |
goto release |
|
1315 | goto release; | |
1314 | minrevphase = add_roots_get_min(self, phaseroots, i+1, phases); |
|
1316 | minrevphase = add_roots_get_min(self, phaseroots, i+1, phases); | |
1315 | if (minrevphase == -2) /* Error from add_roots_get_min */ |
|
1317 | if (minrevphase == -2) /* Error from add_roots_get_min */ | |
1316 |
goto release |
|
1318 | goto release; | |
1317 | minrevallphases = MIN(minrevallphases, minrevphase); |
|
1319 | minrevallphases = MIN(minrevallphases, minrevphase); | |
1318 | } |
|
1320 | } | |
1319 | /* Propagate the phase information from the roots to the revs */ |
|
1321 | /* Propagate the phase information from the roots to the revs */ | |
@@ -1322,14 +1324,14 b' static PyObject *compute_phases_map_sets' | |||||
1322 | for (i = minrevallphases; i < len; i++) { |
|
1324 | for (i = minrevallphases; i < len; i++) { | |
1323 | if (index_get_parents(self, i, parents, |
|
1325 | if (index_get_parents(self, i, parents, | |
1324 | (int)len - 1) < 0) |
|
1326 | (int)len - 1) < 0) | |
1325 |
goto release |
|
1327 | goto release; | |
1326 | set_phase_from_parents(phases, parents[0], parents[1], i); |
|
1328 | set_phase_from_parents(phases, parents[0], parents[1], i); | |
1327 | } |
|
1329 | } | |
1328 | } |
|
1330 | } | |
1329 | /* Transform phase list to a python list */ |
|
1331 | /* Transform phase list to a python list */ | |
1330 | phaseslist = PyList_New(len); |
|
1332 | phaseslist = PyList_New(len); | |
1331 | if (phaseslist == NULL) |
|
1333 | if (phaseslist == NULL) | |
1332 |
goto release |
|
1334 | goto release; | |
1333 | for (i = 0; i < len; i++) { |
|
1335 | for (i = 0; i < len; i++) { | |
1334 | phase = phases[i]; |
|
1336 | phase = phases[i]; | |
1335 | /* We only store the sets of phase for non public phase, the public phase |
|
1337 | /* We only store the sets of phase for non public phase, the public phase | |
@@ -1344,21 +1346,19 b' static PyObject *compute_phases_map_sets' | |||||
1344 | } |
|
1346 | } | |
1345 | ret = PyList_New(2); |
|
1347 | ret = PyList_New(2); | |
1346 | if (ret == NULL) |
|
1348 | if (ret == NULL) | |
1347 |
goto release |
|
1349 | goto release; | |
1348 |
|
1350 | |||
1349 | PyList_SET_ITEM(ret, 0, phaseslist); |
|
1351 | PyList_SET_ITEM(ret, 0, phaseslist); | |
1350 | PyList_SET_ITEM(ret, 1, phasessetlist); |
|
1352 | PyList_SET_ITEM(ret, 1, phasessetlist); | |
1351 | /* We don't release phaseslist and phasessetlist as we return them to |
|
1353 | /* We don't release phaseslist and phasessetlist as we return them to | |
1352 | * python */ |
|
1354 | * python */ | |
1353 | goto release_phases; |
|
1355 | goto done; | |
1354 |
|
1356 | |||
1355 | release_phaseslist: |
|
1357 | release: | |
1356 | Py_XDECREF(phaseslist); |
|
1358 | Py_XDECREF(phaseslist); | |
1357 | release_phasesetlist: |
|
|||
1358 | Py_XDECREF(phasessetlist); |
|
1359 | Py_XDECREF(phasessetlist); | |
1359 | release_phases: |
|
1360 | done: | |
1360 | free(phases); |
|
1361 | free(phases); | |
1361 | release_none: |
|
|||
1362 | return ret; |
|
1362 | return ret; | |
1363 | } |
|
1363 | } | |
1364 |
|
1364 |
General Comments 0
You need to be logged in to leave comments.
Login now