Show More
@@ -610,37 +610,37 b' static PyObject *pack_dirstate(PyObject ' | |||
|
610 | 610 | /* Figure out how much we need to allocate. */ |
|
611 | 611 | for (nbytes = 40, pos = 0; PyDict_Next(map, &pos, &k, &v);) { |
|
612 | 612 | PyObject *c; |
|
613 |
if (!Py |
|
|
613 | if (!PyBytes_Check(k)) { | |
|
614 | 614 | PyErr_SetString(PyExc_TypeError, "expected string key"); |
|
615 | 615 | goto bail; |
|
616 | 616 | } |
|
617 |
nbytes += Py |
|
|
617 | nbytes += PyBytes_GET_SIZE(k) + 17; | |
|
618 | 618 | c = PyDict_GetItem(copymap, k); |
|
619 | 619 | if (c) { |
|
620 |
if (!Py |
|
|
620 | if (!PyBytes_Check(c)) { | |
|
621 | 621 | PyErr_SetString(PyExc_TypeError, |
|
622 | 622 | "expected string key"); |
|
623 | 623 | goto bail; |
|
624 | 624 | } |
|
625 |
nbytes += Py |
|
|
625 | nbytes += PyBytes_GET_SIZE(c) + 1; | |
|
626 | 626 | } |
|
627 | 627 | } |
|
628 | 628 | |
|
629 |
packobj = Py |
|
|
629 | packobj = PyBytes_FromStringAndSize(NULL, nbytes); | |
|
630 | 630 | if (packobj == NULL) |
|
631 | 631 | goto bail; |
|
632 | 632 | |
|
633 |
p = Py |
|
|
633 | p = PyBytes_AS_STRING(packobj); | |
|
634 | 634 | |
|
635 | 635 | pn = PySequence_ITEM(pl, 0); |
|
636 |
if (Py |
|
|
636 | if (PyBytes_AsStringAndSize(pn, &s, &l) == -1 || l != 20) { | |
|
637 | 637 | PyErr_SetString(PyExc_TypeError, "expected a 20-byte hash"); |
|
638 | 638 | goto bail; |
|
639 | 639 | } |
|
640 | 640 | memcpy(p, s, l); |
|
641 | 641 | p += 20; |
|
642 | 642 | pn = PySequence_ITEM(pl, 1); |
|
643 |
if (Py |
|
|
643 | if (PyBytes_AsStringAndSize(pn, &s, &l) == -1 || l != 20) { | |
|
644 | 644 | PyErr_SetString(PyExc_TypeError, "expected a 20-byte hash"); |
|
645 | 645 | goto bail; |
|
646 | 646 | } |
@@ -685,21 +685,21 b' static PyObject *pack_dirstate(PyObject ' | |||
|
685 | 685 | putbe32((uint32_t)mtime, p + 8); |
|
686 | 686 | t = p + 12; |
|
687 | 687 | p += 16; |
|
688 |
len = Py |
|
|
689 |
memcpy(p, Py |
|
|
688 | len = PyBytes_GET_SIZE(k); | |
|
689 | memcpy(p, PyBytes_AS_STRING(k), len); | |
|
690 | 690 | p += len; |
|
691 | 691 | o = PyDict_GetItem(copymap, k); |
|
692 | 692 | if (o) { |
|
693 | 693 | *p++ = '\0'; |
|
694 |
l = Py |
|
|
695 |
memcpy(p, Py |
|
|
694 | l = PyBytes_GET_SIZE(o); | |
|
695 | memcpy(p, PyBytes_AS_STRING(o), l); | |
|
696 | 696 | p += l; |
|
697 | 697 | len += l + 1; |
|
698 | 698 | } |
|
699 | 699 | putbe32((uint32_t)len, t); |
|
700 | 700 | } |
|
701 | 701 | |
|
702 |
pos = p - Py |
|
|
702 | pos = p - PyBytes_AS_STRING(packobj); | |
|
703 | 703 | if (pos != nbytes) { |
|
704 | 704 | PyErr_Format(PyExc_SystemError, "bad dirstate size: %ld != %ld", |
|
705 | 705 | (long)pos, (long)nbytes); |
@@ -796,7 +796,7 b' static const char *index_deref(indexObje' | |||
|
796 | 796 | return self->offsets[pos]; |
|
797 | 797 | } |
|
798 | 798 | |
|
799 |
return Py |
|
|
799 | return PyBytes_AS_STRING(self->data) + pos * v1_hdrsize; | |
|
800 | 800 | } |
|
801 | 801 | |
|
802 | 802 | static inline int index_get_parents(indexObject *self, Py_ssize_t rev, |
@@ -926,7 +926,7 b' static const char *index_node(indexObjec' | |||
|
926 | 926 | PyObject *tuple, *str; |
|
927 | 927 | tuple = PyList_GET_ITEM(self->added, pos - self->length + 1); |
|
928 | 928 | str = PyTuple_GetItem(tuple, 7); |
|
929 |
return str ? Py |
|
|
929 | return str ? PyBytes_AS_STRING(str) : NULL; | |
|
930 | 930 | } |
|
931 | 931 | |
|
932 | 932 | data = index_deref(self, pos); |
@@ -937,7 +937,7 b' static int nt_insert(indexObject *self, ' | |||
|
937 | 937 | |
|
938 | 938 | static int node_check(PyObject *obj, char **node, Py_ssize_t *nodelen) |
|
939 | 939 | { |
|
940 |
if (Py |
|
|
940 | if (PyBytes_AsStringAndSize(obj, node, nodelen) == -1) | |
|
941 | 941 | return -1; |
|
942 | 942 | if (*nodelen == 20) |
|
943 | 943 | return 0; |
@@ -1825,7 +1825,7 b' static PyObject *index_partialmatch(inde' | |||
|
1825 | 1825 | case -2: |
|
1826 | 1826 | Py_RETURN_NONE; |
|
1827 | 1827 | case -1: |
|
1828 |
return Py |
|
|
1828 | return PyBytes_FromStringAndSize(nullid, 20); | |
|
1829 | 1829 | } |
|
1830 | 1830 | |
|
1831 | 1831 | fullnode = index_node(self, rev); |
@@ -1834,7 +1834,7 b' static PyObject *index_partialmatch(inde' | |||
|
1834 | 1834 | "could not access rev %d", rev); |
|
1835 | 1835 | return NULL; |
|
1836 | 1836 | } |
|
1837 |
return Py |
|
|
1837 | return PyBytes_FromStringAndSize(fullnode, 20); | |
|
1838 | 1838 | } |
|
1839 | 1839 | |
|
1840 | 1840 | static PyObject *index_m_get(indexObject *self, PyObject *args) |
@@ -2247,7 +2247,7 b' static void nt_invalidate_added(indexObj' | |||
|
2247 | 2247 | PyObject *tuple = PyList_GET_ITEM(self->added, i); |
|
2248 | 2248 | PyObject *node = PyTuple_GET_ITEM(tuple, 7); |
|
2249 | 2249 | |
|
2250 |
nt_insert(self, Py |
|
|
2250 | nt_insert(self, PyBytes_AS_STRING(node), -1); | |
|
2251 | 2251 | } |
|
2252 | 2252 | |
|
2253 | 2253 | if (start == 0) |
@@ -2372,9 +2372,9 b' static int index_assign_subscript(indexO' | |||
|
2372 | 2372 | */ |
|
2373 | 2373 | static Py_ssize_t inline_scan(indexObject *self, const char **offsets) |
|
2374 | 2374 | { |
|
2375 |
const char *data = Py |
|
|
2375 | const char *data = PyBytes_AS_STRING(self->data); | |
|
2376 | 2376 | Py_ssize_t pos = 0; |
|
2377 |
Py_ssize_t end = Py |
|
|
2377 | Py_ssize_t end = PyBytes_GET_SIZE(self->data); | |
|
2378 | 2378 | long incr = v1_hdrsize; |
|
2379 | 2379 | Py_ssize_t len = 0; |
|
2380 | 2380 | |
@@ -2416,11 +2416,11 b' static int index_init(indexObject *self,' | |||
|
2416 | 2416 | |
|
2417 | 2417 | if (!PyArg_ParseTuple(args, "OO", &data_obj, &inlined_obj)) |
|
2418 | 2418 | return -1; |
|
2419 |
if (!Py |
|
|
2419 | if (!PyBytes_Check(data_obj)) { | |
|
2420 | 2420 | PyErr_SetString(PyExc_TypeError, "data is not a string"); |
|
2421 | 2421 | return -1; |
|
2422 | 2422 | } |
|
2423 |
size = Py |
|
|
2423 | size = PyBytes_GET_SIZE(data_obj); | |
|
2424 | 2424 | |
|
2425 | 2425 | self->inlined = inlined_obj && PyObject_IsTrue(inlined_obj); |
|
2426 | 2426 | self->data = data_obj; |
@@ -2613,7 +2613,7 b' static PyObject *readshas(' | |||
|
2613 | 2613 | return NULL; |
|
2614 | 2614 | } |
|
2615 | 2615 | for (i = 0; i < num; i++) { |
|
2616 |
PyObject *hash = Py |
|
|
2616 | PyObject *hash = PyBytes_FromStringAndSize(source, hashwidth); | |
|
2617 | 2617 | if (hash == NULL) { |
|
2618 | 2618 | Py_DECREF(list); |
|
2619 | 2619 | return NULL; |
@@ -2669,7 +2669,7 b' static PyObject *fm1readmarker(const cha' | |||
|
2669 | 2669 | if (data + hashwidth > dataend) { |
|
2670 | 2670 | goto overflow; |
|
2671 | 2671 | } |
|
2672 |
prec = Py |
|
|
2672 | prec = PyBytes_FromStringAndSize(data, hashwidth); | |
|
2673 | 2673 | data += hashwidth; |
|
2674 | 2674 | if (prec == NULL) { |
|
2675 | 2675 | goto bail; |
@@ -2712,9 +2712,9 b' static PyObject *fm1readmarker(const cha' | |||
|
2712 | 2712 | if (meta + leftsize + rightsize > dataend) { |
|
2713 | 2713 | goto overflow; |
|
2714 | 2714 | } |
|
2715 |
left = Py |
|
|
2715 | left = PyBytes_FromStringAndSize(meta, leftsize); | |
|
2716 | 2716 | meta += leftsize; |
|
2717 |
right = Py |
|
|
2717 | right = PyBytes_FromStringAndSize(meta, rightsize); | |
|
2718 | 2718 | meta += rightsize; |
|
2719 | 2719 | tmp = PyTuple_New(2); |
|
2720 | 2720 | if (!left || !right || !tmp) { |
General Comments 0
You need to be logged in to leave comments.
Login now