Show More
@@ -23,16 +23,6 b'' | |||
|
23 | 23 | #include "revlog.h" |
|
24 | 24 | #include "util.h" |
|
25 | 25 | |
|
26 | #ifdef IS_PY3K | |
|
27 | /* The mapping of Python types is meant to be temporary to get Python | |
|
28 | * 3 to compile. We should remove this once Python 3 support is fully | |
|
29 | * supported and proper types are used in the extensions themselves. */ | |
|
30 | #define PyInt_Check PyLong_Check | |
|
31 | #define PyInt_FromLong PyLong_FromLong | |
|
32 | #define PyInt_FromSsize_t PyLong_FromSsize_t | |
|
33 | #define PyInt_AsLong PyLong_AsLong | |
|
34 | #endif | |
|
35 | ||
|
36 | 26 | typedef struct indexObjectStruct indexObject; |
|
37 | 27 | |
|
38 | 28 | typedef struct { |
@@ -802,7 +792,7 b' static PyObject *index_stats(indexObject' | |||
|
802 | 792 | #define istat(__n, __d) \ |
|
803 | 793 | do { \ |
|
804 | 794 | s = PyBytes_FromString(__d); \ |
|
805 |
t = Py |
|
|
795 | t = PyLong_FromSsize_t(self->__n); \ | |
|
806 | 796 | if (!s || !t) \ |
|
807 | 797 | goto bail; \ |
|
808 | 798 | if (PyDict_SetItem(obj, s, t) == -1) \ |
@@ -953,7 +943,7 b' static PyObject *reachableroots2(indexOb' | |||
|
953 | 943 | |
|
954 | 944 | l = PyList_GET_SIZE(roots); |
|
955 | 945 | for (i = 0; i < l; i++) { |
|
956 |
revnum = Py |
|
|
946 | revnum = PyLong_AsLong(PyList_GET_ITEM(roots, i)); | |
|
957 | 947 | if (revnum == -1 && PyErr_Occurred()) |
|
958 | 948 | goto bail; |
|
959 | 949 | /* If root is out of range, e.g. wdir(), it must be unreachable |
@@ -966,7 +956,7 b' static PyObject *reachableroots2(indexOb' | |||
|
966 | 956 | /* Populate tovisit with all the heads */ |
|
967 | 957 | l = PyList_GET_SIZE(heads); |
|
968 | 958 | for (i = 0; i < l; i++) { |
|
969 |
revnum = Py |
|
|
959 | revnum = PyLong_AsLong(PyList_GET_ITEM(heads, i)); | |
|
970 | 960 | if (revnum == -1 && PyErr_Occurred()) |
|
971 | 961 | goto bail; |
|
972 | 962 | if (revnum + 1 < 0 || revnum + 1 >= len + 1) { |
@@ -986,7 +976,7 b' static PyObject *reachableroots2(indexOb' | |||
|
986 | 976 | revnum = tovisit[k++]; |
|
987 | 977 | if (revstates[revnum + 1] & RS_ROOT) { |
|
988 | 978 | revstates[revnum + 1] |= RS_REACHABLE; |
|
989 |
val = Py |
|
|
979 | val = PyLong_FromLong(revnum); | |
|
990 | 980 | if (val == NULL) |
|
991 | 981 | goto bail; |
|
992 | 982 | r = PyList_Append(reachable, val); |
@@ -1031,7 +1021,7 b' static PyObject *reachableroots2(indexOb' | |||
|
1031 | 1021 | RS_REACHABLE) && |
|
1032 | 1022 | !(revstates[i + 1] & RS_REACHABLE)) { |
|
1033 | 1023 | revstates[i + 1] |= RS_REACHABLE; |
|
1034 |
val = Py |
|
|
1024 | val = PyLong_FromSsize_t(i); | |
|
1035 | 1025 | if (val == NULL) |
|
1036 | 1026 | goto bail; |
|
1037 | 1027 | r = PyList_Append(reachable, val); |
@@ -1116,7 +1106,7 b' static PyObject *compute_phases_map_sets' | |||
|
1116 | 1106 | } |
|
1117 | 1107 | |
|
1118 | 1108 | for (i = 0; i < numphases; ++i) { |
|
1119 |
PyObject *pyphase = Py |
|
|
1109 | PyObject *pyphase = PyLong_FromLong(trackedphases[i]); | |
|
1120 | 1110 | PyObject *phaseroots = NULL; |
|
1121 | 1111 | if (pyphase == NULL) |
|
1122 | 1112 | goto release; |
@@ -1175,7 +1165,7 b' static PyObject *compute_phases_map_sets' | |||
|
1175 | 1165 | "bad phase number in internal list"); |
|
1176 | 1166 | goto release; |
|
1177 | 1167 | } |
|
1178 |
pyrev = Py |
|
|
1168 | pyrev = PyLong_FromLong(rev); | |
|
1179 | 1169 | if (pyrev == NULL) |
|
1180 | 1170 | goto release; |
|
1181 | 1171 | if (PySet_Add(pyphase, pyrev) == -1) { |
@@ -1189,7 +1179,7 b' static PyObject *compute_phases_map_sets' | |||
|
1189 | 1179 | if (phasesetsdict == NULL) |
|
1190 | 1180 | goto release; |
|
1191 | 1181 | for (i = 0; i < numphases; ++i) { |
|
1192 |
PyObject *pyphase = Py |
|
|
1182 | PyObject *pyphase = PyLong_FromLong(trackedphases[i]); | |
|
1193 | 1183 | if (pyphase == NULL) |
|
1194 | 1184 | goto release; |
|
1195 | 1185 | if (PyDict_SetItem(phasesetsdict, pyphase, phasesets[i]) == |
@@ -1247,7 +1237,7 b' static PyObject *index_headrevs(indexObj' | |||
|
1247 | 1237 | if (heads == NULL) |
|
1248 | 1238 | goto bail; |
|
1249 | 1239 | if (len == 0) { |
|
1250 |
PyObject *nullid = Py |
|
|
1240 | PyObject *nullid = PyLong_FromLong(-1); | |
|
1251 | 1241 | if (nullid == NULL || PyList_Append(heads, nullid) == -1) { |
|
1252 | 1242 | Py_XDECREF(nullid); |
|
1253 | 1243 | goto bail; |
@@ -1296,7 +1286,7 b' static PyObject *index_headrevs(indexObj' | |||
|
1296 | 1286 | |
|
1297 | 1287 | if (nothead[i]) |
|
1298 | 1288 | continue; |
|
1299 |
head = Py |
|
|
1289 | head = PyLong_FromSsize_t(i); | |
|
1300 | 1290 | if (head == NULL || PyList_Append(heads, head) == -1) { |
|
1301 | 1291 | Py_XDECREF(head); |
|
1302 | 1292 | goto bail; |
@@ -1442,7 +1432,7 b' static PyObject *index_findsnapshots(ind' | |||
|
1442 | 1432 | assert(PyErr_Occurred()); |
|
1443 | 1433 | goto bail; |
|
1444 | 1434 | } |
|
1445 |
key = Py |
|
|
1435 | key = PyLong_FromSsize_t(base); | |
|
1446 | 1436 | allvalues = PyDict_GetItem(cache, key); |
|
1447 | 1437 | if (allvalues == NULL && PyErr_Occurred()) { |
|
1448 | 1438 | goto bail; |
@@ -1459,7 +1449,7 b' static PyObject *index_findsnapshots(ind' | |||
|
1459 | 1449 | goto bail; |
|
1460 | 1450 | } |
|
1461 | 1451 | } |
|
1462 |
value = Py |
|
|
1452 | value = PyLong_FromSsize_t(rev); | |
|
1463 | 1453 | if (PyList_Append(allvalues, value)) { |
|
1464 | 1454 | goto bail; |
|
1465 | 1455 | } |
@@ -1486,8 +1476,8 b' static PyObject *index_deltachain(indexO' | |||
|
1486 | 1476 | return NULL; |
|
1487 | 1477 | } |
|
1488 | 1478 | |
|
1489 |
if (Py |
|
|
1490 |
stoprev = (int)Py |
|
|
1479 | if (PyLong_Check(stoparg)) { | |
|
1480 | stoprev = (int)PyLong_AsLong(stoparg); | |
|
1491 | 1481 | if (stoprev == -1 && PyErr_Occurred()) { |
|
1492 | 1482 | return NULL; |
|
1493 | 1483 | } |
@@ -1521,7 +1511,7 b' static PyObject *index_deltachain(indexO' | |||
|
1521 | 1511 | iterrev = rev; |
|
1522 | 1512 | |
|
1523 | 1513 | while (iterrev != baserev && iterrev != stoprev) { |
|
1524 |
PyObject *value = Py |
|
|
1514 | PyObject *value = PyLong_FromLong(iterrev); | |
|
1525 | 1515 | if (value == NULL) { |
|
1526 | 1516 | goto bail; |
|
1527 | 1517 | } |
@@ -1560,7 +1550,7 b' static PyObject *index_deltachain(indexO' | |||
|
1560 | 1550 | if (iterrev == stoprev) { |
|
1561 | 1551 | stopped = 1; |
|
1562 | 1552 | } else { |
|
1563 |
PyObject *value = Py |
|
|
1553 | PyObject *value = PyLong_FromLong(iterrev); | |
|
1564 | 1554 | if (value == NULL) { |
|
1565 | 1555 | goto bail; |
|
1566 | 1556 | } |
@@ -1712,7 +1702,8 b' static PyObject *index_slicechunktodensi' | |||
|
1712 | 1702 | goto bail; |
|
1713 | 1703 | } |
|
1714 | 1704 | for (i = 0; i < num_revs; i++) { |
|
1715 | Py_ssize_t revnum = PyInt_AsLong(PyList_GET_ITEM(list_revs, i)); | |
|
1705 | Py_ssize_t revnum = | |
|
1706 | PyLong_AsLong(PyList_GET_ITEM(list_revs, i)); | |
|
1716 | 1707 | if (revnum == -1 && PyErr_Occurred()) { |
|
1717 | 1708 | goto bail; |
|
1718 | 1709 | } |
@@ -2118,7 +2109,7 b' static PyObject *ntobj_shortest(nodetree' | |||
|
2118 | 2109 | raise_revlog_error(); |
|
2119 | 2110 | return NULL; |
|
2120 | 2111 | } |
|
2121 |
return Py |
|
|
2112 | return PyLong_FromLong(length); | |
|
2122 | 2113 | } |
|
2123 | 2114 | |
|
2124 | 2115 | static void nt_dealloc(nodetree *self) |
@@ -2266,7 +2257,7 b' static PyObject *index_getitem(indexObje' | |||
|
2266 | 2257 | char *node; |
|
2267 | 2258 | int rev; |
|
2268 | 2259 | |
|
2269 |
if (Py |
|
|
2260 | if (PyLong_Check(value)) { | |
|
2270 | 2261 | long idx; |
|
2271 | 2262 | if (!pylong_to_long(value, &idx)) { |
|
2272 | 2263 | return NULL; |
@@ -2278,7 +2269,7 b' static PyObject *index_getitem(indexObje' | |||
|
2278 | 2269 | return NULL; |
|
2279 | 2270 | rev = index_find_node(self, node); |
|
2280 | 2271 | if (rev >= -1) |
|
2281 |
return Py |
|
|
2272 | return PyLong_FromLong(rev); | |
|
2282 | 2273 | if (rev == -2) |
|
2283 | 2274 | raise_revlog_error(); |
|
2284 | 2275 | return NULL; |
@@ -2377,7 +2368,7 b' static PyObject *index_shortest(indexObj' | |||
|
2377 | 2368 | raise_revlog_error(); |
|
2378 | 2369 | return NULL; |
|
2379 | 2370 | } |
|
2380 |
return Py |
|
|
2371 | return PyLong_FromLong(length); | |
|
2381 | 2372 | } |
|
2382 | 2373 | |
|
2383 | 2374 | static PyObject *index_m_get(indexObject *self, PyObject *args) |
@@ -2395,14 +2386,14 b' static PyObject *index_m_get(indexObject' | |||
|
2395 | 2386 | return NULL; |
|
2396 | 2387 | if (rev == -2) |
|
2397 | 2388 | Py_RETURN_NONE; |
|
2398 |
return Py |
|
|
2389 | return PyLong_FromLong(rev); | |
|
2399 | 2390 | } |
|
2400 | 2391 | |
|
2401 | 2392 | static int index_contains(indexObject *self, PyObject *value) |
|
2402 | 2393 | { |
|
2403 | 2394 | char *node; |
|
2404 | 2395 | |
|
2405 |
if (Py |
|
|
2396 | if (PyLong_Check(value)) { | |
|
2406 | 2397 | long rev; |
|
2407 | 2398 | if (!pylong_to_long(value, &rev)) { |
|
2408 | 2399 | return -1; |
@@ -2440,7 +2431,7 b' static PyObject *index_m_rev(indexObject' | |||
|
2440 | 2431 | return NULL; |
|
2441 | 2432 | rev = index_find_node(self, node); |
|
2442 | 2433 | if (rev >= -1) |
|
2443 |
return Py |
|
|
2434 | return PyLong_FromLong(rev); | |
|
2444 | 2435 | if (rev == -2) |
|
2445 | 2436 | raise_revlog_error(); |
|
2446 | 2437 | return NULL; |
@@ -2493,7 +2484,7 b' static PyObject *find_gca_candidates(ind' | |||
|
2493 | 2484 | if (sv < poison) { |
|
2494 | 2485 | interesting -= 1; |
|
2495 | 2486 | if (sv == allseen) { |
|
2496 |
PyObject *obj = Py |
|
|
2487 | PyObject *obj = PyLong_FromLong(v); | |
|
2497 | 2488 | if (obj == NULL) |
|
2498 | 2489 | goto bail; |
|
2499 | 2490 | if (PyList_Append(gca, obj) == -1) { |
@@ -2561,7 +2552,7 b' static PyObject *find_deepest(indexObjec' | |||
|
2561 | 2552 | } |
|
2562 | 2553 | |
|
2563 | 2554 | for (i = 0; i < revcount; i++) { |
|
2564 |
int n = (int)Py |
|
|
2555 | int n = (int)PyLong_AsLong(PyList_GET_ITEM(revs, i)); | |
|
2565 | 2556 | if (n > maxrev) |
|
2566 | 2557 | maxrev = n; |
|
2567 | 2558 | } |
@@ -2586,7 +2577,7 b' static PyObject *find_deepest(indexObjec' | |||
|
2586 | 2577 | goto bail; |
|
2587 | 2578 | |
|
2588 | 2579 | for (i = 0; i < revcount; i++) { |
|
2589 |
int n = (int)Py |
|
|
2580 | int n = (int)PyLong_AsLong(PyList_GET_ITEM(revs, i)); | |
|
2590 | 2581 | long b = 1l << i; |
|
2591 | 2582 | depth[n] = 1; |
|
2592 | 2583 | seen[n] = b; |
@@ -2716,13 +2707,13 b' static PyObject *index_commonancestorshe' | |||
|
2716 | 2707 | bitmask x; |
|
2717 | 2708 | long val; |
|
2718 | 2709 | |
|
2719 |
if (!Py |
|
|
2710 | if (!PyLong_Check(obj)) { | |
|
2720 | 2711 | PyErr_SetString(PyExc_TypeError, |
|
2721 | 2712 | "arguments must all be ints"); |
|
2722 | 2713 | Py_DECREF(obj); |
|
2723 | 2714 | goto bail; |
|
2724 | 2715 | } |
|
2725 |
val = Py |
|
|
2716 | val = PyLong_AsLong(obj); | |
|
2726 | 2717 | Py_DECREF(obj); |
|
2727 | 2718 | if (val == -1) { |
|
2728 | 2719 | ret = PyList_New(0); |
@@ -2763,7 +2754,7 b' static PyObject *index_commonancestorshe' | |||
|
2763 | 2754 | ret = PyList_New(1); |
|
2764 | 2755 | if (ret == NULL) |
|
2765 | 2756 | goto bail; |
|
2766 |
obj = Py |
|
|
2757 | obj = PyLong_FromLong(revs[0]); | |
|
2767 | 2758 | if (obj == NULL) |
|
2768 | 2759 | goto bail; |
|
2769 | 2760 | PyList_SET_ITEM(ret, 0, obj); |
@@ -2925,7 +2916,7 b' static int index_assign_subscript(indexO' | |||
|
2925 | 2916 | if (value == NULL) |
|
2926 | 2917 | return self->ntinitialized ? nt_delete_node(&self->nt, node) |
|
2927 | 2918 | : 0; |
|
2928 |
rev = Py |
|
|
2919 | rev = PyLong_AsLong(value); | |
|
2929 | 2920 | if (rev > INT_MAX || rev < 0) { |
|
2930 | 2921 | if (!PyErr_Occurred()) |
|
2931 | 2922 | PyErr_SetString(PyExc_ValueError, "rev out of range"); |
General Comments 0
You need to be logged in to leave comments.
Login now