Show More
@@ -56,10 +56,10 b' static PyObject *nodeof(line *l) {' | |||||
56 | } |
|
56 | } | |
57 | if (l->hash_suffix != '\0') { |
|
57 | if (l->hash_suffix != '\0') { | |
58 | char newhash[21]; |
|
58 | char newhash[21]; | |
59 |
memcpy(newhash, Py |
|
59 | memcpy(newhash, PyBytes_AsString(hash), 20); | |
60 | Py_DECREF(hash); |
|
60 | Py_DECREF(hash); | |
61 | newhash[20] = l->hash_suffix; |
|
61 | newhash[20] = l->hash_suffix; | |
62 |
hash = Py |
|
62 | hash = PyBytes_FromStringAndSize(newhash, 21); | |
63 | } |
|
63 | } | |
64 | return hash; |
|
64 | return hash; | |
65 | } |
|
65 | } | |
@@ -79,7 +79,7 b' static PyObject *hashflags(line *l)' | |||||
79 |
|
79 | |||
80 | if (!hash) |
|
80 | if (!hash) | |
81 | return NULL; |
|
81 | return NULL; | |
82 |
flags = Py |
|
82 | flags = PyBytes_FromStringAndSize(s + hplen - 1, flen); | |
83 | if (!flags) { |
|
83 | if (!flags) { | |
84 | Py_DECREF(hash); |
|
84 | Py_DECREF(hash); | |
85 | return NULL; |
|
85 | return NULL; | |
@@ -144,7 +144,7 b' static int lazymanifest_init(lazymanifes' | |||||
144 | if (!PyArg_ParseTuple(args, "S", &pydata)) { |
|
144 | if (!PyArg_ParseTuple(args, "S", &pydata)) { | |
145 | return -1; |
|
145 | return -1; | |
146 | } |
|
146 | } | |
147 |
err = Py |
|
147 | err = PyBytes_AsStringAndSize(pydata, &data, &len); | |
148 |
|
148 | |||
149 | self->dirty = false; |
|
149 | self->dirty = false; | |
150 | if (err == -1) |
|
150 | if (err == -1) | |
@@ -238,10 +238,10 b' static PyObject *lmiter_iterentriesnext(' | |||||
238 | goto done; |
|
238 | goto done; | |
239 | } |
|
239 | } | |
240 | pl = pathlen(l); |
|
240 | pl = pathlen(l); | |
241 |
path = Py |
|
241 | path = PyBytes_FromStringAndSize(l->start, pl); | |
242 | hash = nodeof(l); |
|
242 | hash = nodeof(l); | |
243 | consumed = pl + 41; |
|
243 | consumed = pl + 41; | |
244 |
flags = Py |
|
244 | flags = PyBytes_FromStringAndSize(l->start + consumed, | |
245 | l->len - consumed - 1); |
|
245 | l->len - consumed - 1); | |
246 | if (!path || !hash || !flags) { |
|
246 | if (!path || !hash || !flags) { | |
247 | goto done; |
|
247 | goto done; | |
@@ -300,7 +300,7 b' static PyObject *lmiter_iterkeysnext(PyO' | |||||
300 | return NULL; |
|
300 | return NULL; | |
301 | } |
|
301 | } | |
302 | pl = pathlen(l); |
|
302 | pl = pathlen(l); | |
303 |
return Py |
|
303 | return PyBytes_FromStringAndSize(l->start, pl); | |
304 | } |
|
304 | } | |
305 |
|
305 | |||
306 | #ifdef IS_PY3K |
|
306 | #ifdef IS_PY3K | |
@@ -398,12 +398,12 b' static PyObject *lazymanifest_getitem(la' | |||||
398 | { |
|
398 | { | |
399 | line needle; |
|
399 | line needle; | |
400 | line *hit; |
|
400 | line *hit; | |
401 |
if (!Py |
|
401 | if (!PyBytes_Check(key)) { | |
402 | PyErr_Format(PyExc_TypeError, |
|
402 | PyErr_Format(PyExc_TypeError, | |
403 | "getitem: manifest keys must be a string."); |
|
403 | "getitem: manifest keys must be a string."); | |
404 | return NULL; |
|
404 | return NULL; | |
405 | } |
|
405 | } | |
406 |
needle.start = Py |
|
406 | needle.start = PyBytes_AsString(key); | |
407 | hit = bsearch(&needle, self->lines, self->numlines, sizeof(line), |
|
407 | hit = bsearch(&needle, self->lines, self->numlines, sizeof(line), | |
408 | &linecmp); |
|
408 | &linecmp); | |
409 | if (!hit || hit->deleted) { |
|
409 | if (!hit || hit->deleted) { | |
@@ -417,12 +417,12 b' static int lazymanifest_delitem(lazymani' | |||||
417 | { |
|
417 | { | |
418 | line needle; |
|
418 | line needle; | |
419 | line *hit; |
|
419 | line *hit; | |
420 |
if (!Py |
|
420 | if (!PyBytes_Check(key)) { | |
421 | PyErr_Format(PyExc_TypeError, |
|
421 | PyErr_Format(PyExc_TypeError, | |
422 | "delitem: manifest keys must be a string."); |
|
422 | "delitem: manifest keys must be a string."); | |
423 | return -1; |
|
423 | return -1; | |
424 | } |
|
424 | } | |
425 |
needle.start = Py |
|
425 | needle.start = PyBytes_AsString(key); | |
426 | hit = bsearch(&needle, self->lines, self->numlines, sizeof(line), |
|
426 | hit = bsearch(&needle, self->lines, self->numlines, sizeof(line), | |
427 | &linecmp); |
|
427 | &linecmp); | |
428 | if (!hit || hit->deleted) { |
|
428 | if (!hit || hit->deleted) { | |
@@ -486,7 +486,7 b' static int lazymanifest_setitem(' | |||||
486 | char *dest; |
|
486 | char *dest; | |
487 | int i; |
|
487 | int i; | |
488 | line new; |
|
488 | line new; | |
489 |
if (!Py |
|
489 | if (!PyBytes_Check(key)) { | |
490 | PyErr_Format(PyExc_TypeError, |
|
490 | PyErr_Format(PyExc_TypeError, | |
491 | "setitem: manifest keys must be a string."); |
|
491 | "setitem: manifest keys must be a string."); | |
492 | return -1; |
|
492 | return -1; | |
@@ -499,17 +499,17 b' static int lazymanifest_setitem(' | |||||
499 | "Manifest values must be a tuple of (node, flags)."); |
|
499 | "Manifest values must be a tuple of (node, flags)."); | |
500 | return -1; |
|
500 | return -1; | |
501 | } |
|
501 | } | |
502 |
if (Py |
|
502 | if (PyBytes_AsStringAndSize(key, &path, &plen) == -1) { | |
503 | return -1; |
|
503 | return -1; | |
504 | } |
|
504 | } | |
505 |
|
505 | |||
506 | pyhash = PyTuple_GetItem(value, 0); |
|
506 | pyhash = PyTuple_GetItem(value, 0); | |
507 |
if (!Py |
|
507 | if (!PyBytes_Check(pyhash)) { | |
508 | PyErr_Format(PyExc_TypeError, |
|
508 | PyErr_Format(PyExc_TypeError, | |
509 | "node must be a 20-byte string"); |
|
509 | "node must be a 20-byte string"); | |
510 | return -1; |
|
510 | return -1; | |
511 | } |
|
511 | } | |
512 |
hlen = Py |
|
512 | hlen = PyBytes_Size(pyhash); | |
513 | /* Some parts of the codebase try and set 21 or 22 |
|
513 | /* Some parts of the codebase try and set 21 or 22 | |
514 | * byte "hash" values in order to perturb things for |
|
514 | * byte "hash" values in order to perturb things for | |
515 | * status. We have to preserve at least the 21st |
|
515 | * status. We have to preserve at least the 21st | |
@@ -521,15 +521,15 b' static int lazymanifest_setitem(' | |||||
521 | "node must be a 20-byte string"); |
|
521 | "node must be a 20-byte string"); | |
522 | return -1; |
|
522 | return -1; | |
523 | } |
|
523 | } | |
524 |
hash = Py |
|
524 | hash = PyBytes_AsString(pyhash); | |
525 |
|
525 | |||
526 | pyflags = PyTuple_GetItem(value, 1); |
|
526 | pyflags = PyTuple_GetItem(value, 1); | |
527 |
if (!Py |
|
527 | if (!PyBytes_Check(pyflags) || PyBytes_Size(pyflags) > 1) { | |
528 | PyErr_Format(PyExc_TypeError, |
|
528 | PyErr_Format(PyExc_TypeError, | |
529 | "flags must a 0 or 1 byte string"); |
|
529 | "flags must a 0 or 1 byte string"); | |
530 | return -1; |
|
530 | return -1; | |
531 | } |
|
531 | } | |
532 |
if (Py |
|
532 | if (PyBytes_AsStringAndSize(pyflags, &flags, &flen) == -1) { | |
533 | return -1; |
|
533 | return -1; | |
534 | } |
|
534 | } | |
535 | /* one null byte and one newline */ |
|
535 | /* one null byte and one newline */ | |
@@ -574,12 +574,12 b' static int lazymanifest_contains(lazyman' | |||||
574 | { |
|
574 | { | |
575 | line needle; |
|
575 | line needle; | |
576 | line *hit; |
|
576 | line *hit; | |
577 |
if (!Py |
|
577 | if (!PyBytes_Check(key)) { | |
578 | /* Our keys are always strings, so if the contains |
|
578 | /* Our keys are always strings, so if the contains | |
579 | * check is for a non-string, just return false. */ |
|
579 | * check is for a non-string, just return false. */ | |
580 | return 0; |
|
580 | return 0; | |
581 | } |
|
581 | } | |
582 |
needle.start = Py |
|
582 | needle.start = PyBytes_AsString(key); | |
583 | hit = bsearch(&needle, self->lines, self->numlines, sizeof(line), |
|
583 | hit = bsearch(&needle, self->lines, self->numlines, sizeof(line), | |
584 | &linecmp); |
|
584 | &linecmp); | |
585 | if (!hit || hit->deleted) { |
|
585 | if (!hit || hit->deleted) { | |
@@ -619,10 +619,10 b' static int compact(lazymanifest *self) {' | |||||
619 | need += self->lines[i].len; |
|
619 | need += self->lines[i].len; | |
620 | } |
|
620 | } | |
621 | } |
|
621 | } | |
622 |
pydata = Py |
|
622 | pydata = PyBytes_FromStringAndSize(NULL, need); | |
623 | if (!pydata) |
|
623 | if (!pydata) | |
624 | return -1; |
|
624 | return -1; | |
625 |
data = Py |
|
625 | data = PyBytes_AsString(pydata); | |
626 | if (!data) { |
|
626 | if (!data) { | |
627 | return -1; |
|
627 | return -1; | |
628 | } |
|
628 | } | |
@@ -757,7 +757,7 b' static PyObject *lazymanifest_diff(lazym' | |||||
757 | return NULL; |
|
757 | return NULL; | |
758 | } |
|
758 | } | |
759 | listclean = (!pyclean) ? false : PyObject_IsTrue(pyclean); |
|
759 | listclean = (!pyclean) ? false : PyObject_IsTrue(pyclean); | |
760 |
es = Py |
|
760 | es = PyBytes_FromString(""); | |
761 | if (!es) { |
|
761 | if (!es) { | |
762 | goto nomem; |
|
762 | goto nomem; | |
763 | } |
|
763 | } | |
@@ -797,8 +797,8 b' static PyObject *lazymanifest_diff(lazym' | |||||
797 | result = linecmp(left, right); |
|
797 | result = linecmp(left, right); | |
798 | } |
|
798 | } | |
799 | key = result <= 0 ? |
|
799 | key = result <= 0 ? | |
800 |
Py |
|
800 | PyBytes_FromString(left->start) : | |
801 |
Py |
|
801 | PyBytes_FromString(right->start); | |
802 | if (!key) |
|
802 | if (!key) | |
803 | goto nomem; |
|
803 | goto nomem; | |
804 | if (result < 0) { |
|
804 | if (result < 0) { |
General Comments 0
You need to be logged in to leave comments.
Login now