Show More
@@ -77,7 +77,7 b' static PyObject *b85encode(PyObject *sel' | |||||
77 |
|
77 | |||
78 | static PyObject *b85decode(PyObject *self, PyObject *args) |
|
78 | static PyObject *b85decode(PyObject *self, PyObject *args) | |
79 | { |
|
79 | { | |
80 | PyObject *out; |
|
80 | PyObject *out = NULL; | |
81 | const char *text; |
|
81 | const char *text; | |
82 | char *dst; |
|
82 | char *dst; | |
83 | Py_ssize_t len, i, j, olen, cap; |
|
83 | Py_ssize_t len, i, j, olen, cap; | |
@@ -104,27 +104,33 b' static PyObject *b85decode(PyObject *sel' | |||||
104 | cap = 4; |
|
104 | cap = 4; | |
105 | for (j = 0; j < cap; i++, j++) { |
|
105 | for (j = 0; j < cap; i++, j++) { | |
106 | c = b85dec[(int)*text++] - 1; |
|
106 | c = b85dec[(int)*text++] - 1; | |
107 | if (c < 0) |
|
107 | if (c < 0) { | |
108 |
|
|
108 | PyErr_Format( | |
109 | PyExc_ValueError, |
|
109 | PyExc_ValueError, | |
110 | "bad base85 character at position %d", |
|
110 | "bad base85 character at position %d", | |
111 | (int)i); |
|
111 | (int)i); | |
|
112 | goto bail; | |||
|
113 | } | |||
112 | acc = acc * 85 + c; |
|
114 | acc = acc * 85 + c; | |
113 | } |
|
115 | } | |
114 | if (i++ < len) { |
|
116 | if (i++ < len) { | |
115 | c = b85dec[(int)*text++] - 1; |
|
117 | c = b85dec[(int)*text++] - 1; | |
116 | if (c < 0) |
|
118 | if (c < 0) { | |
117 |
|
|
119 | PyErr_Format( | |
118 | PyExc_ValueError, |
|
120 | PyExc_ValueError, | |
119 | "bad base85 character at position %d", |
|
121 | "bad base85 character at position %d", | |
120 | (int)i); |
|
122 | (int)i); | |
|
123 | goto bail; | |||
|
124 | } | |||
121 | /* overflow detection: 0xffffffff == "|NsC0", |
|
125 | /* overflow detection: 0xffffffff == "|NsC0", | |
122 | * "|NsC" == 0x03030303 */ |
|
126 | * "|NsC" == 0x03030303 */ | |
123 | if (acc > 0x03030303 || (acc *= 85) > 0xffffffff - c) |
|
127 | if (acc > 0x03030303 || (acc *= 85) > 0xffffffff - c) { | |
124 |
|
|
128 | PyErr_Format( | |
125 | PyExc_ValueError, |
|
129 | PyExc_ValueError, | |
126 | "bad base85 sequence at position %d", |
|
130 | "bad base85 sequence at position %d", | |
127 | (int)i); |
|
131 | (int)i); | |
|
132 | goto bail; | |||
|
133 | } | |||
128 | acc += c; |
|
134 | acc += c; | |
129 | } |
|
135 | } | |
130 |
|
136 | |||
@@ -141,6 +147,9 b' static PyObject *b85decode(PyObject *sel' | |||||
141 | } |
|
147 | } | |
142 |
|
148 | |||
143 | return out; |
|
149 | return out; | |
|
150 | bail: | |||
|
151 | Py_XDECREF(out); | |||
|
152 | return NULL; | |||
144 | } |
|
153 | } | |
145 |
|
154 | |||
146 | static char base85_doc[] = "Base85 Data Encoding"; |
|
155 | static char base85_doc[] = "Base85 Data Encoding"; |
@@ -256,13 +256,12 b' static int hunk_consumer(int64_t a1, int' | |||||
256 | { |
|
256 | { | |
257 | PyObject *rl = (PyObject *)priv; |
|
257 | PyObject *rl = (PyObject *)priv; | |
258 | PyObject *m = Py_BuildValue("LLLL", a1, a2, b1, b2); |
|
258 | PyObject *m = Py_BuildValue("LLLL", a1, a2, b1, b2); | |
|
259 | int r; | |||
259 | if (!m) |
|
260 | if (!m) | |
260 | return -1; |
|
261 | return -1; | |
261 |
|
|
262 | r = PyList_Append(rl, m); | |
262 |
|
|
263 | Py_DECREF(m); | |
263 |
|
|
264 | return r; | |
264 | } |
|
|||
265 | return 0; |
|
|||
266 | } |
|
265 | } | |
267 |
|
266 | |||
268 | static PyObject *xdiffblocks(PyObject *self, PyObject *args) |
|
267 | static PyObject *xdiffblocks(PyObject *self, PyObject *args) |
@@ -725,22 +725,20 b' static lazymanifest *lazymanifest_filter' | |||||
725 | copy->maxlines = self->maxlines; |
|
725 | copy->maxlines = self->maxlines; | |
726 | copy->numlines = 0; |
|
726 | copy->numlines = 0; | |
727 | copy->pydata = self->pydata; |
|
727 | copy->pydata = self->pydata; | |
728 |
Py_INCREF( |
|
728 | Py_INCREF(copy->pydata); | |
729 | for (i = 0; i < self->numlines; i++) { |
|
729 | for (i = 0; i < self->numlines; i++) { | |
730 | PyObject *arglist = NULL, *result = NULL; |
|
730 | PyObject *arglist = NULL, *result = NULL; | |
731 | arglist = Py_BuildValue(PY23("(s)", "(y)"), |
|
731 | arglist = Py_BuildValue(PY23("(s)", "(y)"), | |
732 | self->lines[i].start); |
|
732 | self->lines[i].start); | |
733 | if (!arglist) { |
|
733 | if (!arglist) { | |
734 | return NULL; |
|
734 | goto bail; | |
735 | } |
|
735 | } | |
736 | result = PyObject_CallObject(matchfn, arglist); |
|
736 | result = PyObject_CallObject(matchfn, arglist); | |
737 | Py_DECREF(arglist); |
|
737 | Py_DECREF(arglist); | |
738 | /* if the callback raised an exception, just let it |
|
738 | /* if the callback raised an exception, just let it | |
739 | * through and give up */ |
|
739 | * through and give up */ | |
740 | if (!result) { |
|
740 | if (!result) { | |
741 | free(copy->lines); |
|
741 | goto bail; | |
742 | Py_DECREF(self->pydata); |
|
|||
743 | return NULL; |
|
|||
744 | } |
|
742 | } | |
745 | if (PyObject_IsTrue(result)) { |
|
743 | if (PyObject_IsTrue(result)) { | |
746 | assert(!(self->lines[i].from_malloc)); |
|
744 | assert(!(self->lines[i].from_malloc)); | |
@@ -752,6 +750,7 b' static lazymanifest *lazymanifest_filter' | |||||
752 | return copy; |
|
750 | return copy; | |
753 | nomem: |
|
751 | nomem: | |
754 | PyErr_NoMemory(); |
|
752 | PyErr_NoMemory(); | |
|
753 | bail: | |||
755 | Py_XDECREF(copy); |
|
754 | Py_XDECREF(copy); | |
756 | return NULL; |
|
755 | return NULL; | |
757 | } |
|
756 | } |
@@ -382,12 +382,12 b' static PyObject *pack_dirstate(PyObject ' | |||||
382 | char *p, *s; |
|
382 | char *p, *s; | |
383 | int now; |
|
383 | int now; | |
384 |
|
384 | |||
385 | if (!PyArg_ParseTuple(args, "O!O!Oi:pack_dirstate", &PyDict_Type, &map, |
|
385 | if (!PyArg_ParseTuple(args, "O!O!O!i:pack_dirstate", &PyDict_Type, &map, | |
386 | &PyDict_Type, ©map, &pl, &now)) |
|
386 | &PyDict_Type, ©map, &PyTuple_Type, &pl, &now)) | |
387 | return NULL; |
|
387 | return NULL; | |
388 |
|
388 | |||
389 |
if ( |
|
389 | if (PyTuple_Size(pl) != 2) { | |
390 |
PyErr_SetString(PyExc_TypeError, "expected 2-element |
|
390 | PyErr_SetString(PyExc_TypeError, "expected 2-element tuple"); | |
391 | return NULL; |
|
391 | return NULL; | |
392 | } |
|
392 | } | |
393 |
|
393 | |||
@@ -416,14 +416,14 b' static PyObject *pack_dirstate(PyObject ' | |||||
416 |
|
416 | |||
417 | p = PyBytes_AS_STRING(packobj); |
|
417 | p = PyBytes_AS_STRING(packobj); | |
418 |
|
418 | |||
419 |
pn = Py |
|
419 | pn = PyTuple_GET_ITEM(pl, 0); | |
420 | if (PyBytes_AsStringAndSize(pn, &s, &l) == -1 || l != 20) { |
|
420 | if (PyBytes_AsStringAndSize(pn, &s, &l) == -1 || l != 20) { | |
421 | PyErr_SetString(PyExc_TypeError, "expected a 20-byte hash"); |
|
421 | PyErr_SetString(PyExc_TypeError, "expected a 20-byte hash"); | |
422 | goto bail; |
|
422 | goto bail; | |
423 | } |
|
423 | } | |
424 | memcpy(p, s, l); |
|
424 | memcpy(p, s, l); | |
425 | p += 20; |
|
425 | p += 20; | |
426 |
pn = Py |
|
426 | pn = PyTuple_GET_ITEM(pl, 1); | |
427 | if (PyBytes_AsStringAndSize(pn, &s, &l) == -1 || l != 20) { |
|
427 | if (PyBytes_AsStringAndSize(pn, &s, &l) == -1 || l != 20) { | |
428 | PyErr_SetString(PyExc_TypeError, "expected a 20-byte hash"); |
|
428 | PyErr_SetString(PyExc_TypeError, "expected a 20-byte hash"); | |
429 | goto bail; |
|
429 | goto bail; | |
@@ -713,7 +713,7 b' void dirs_module_init(PyObject *mod);' | |||||
713 | void manifest_module_init(PyObject *mod); |
|
713 | void manifest_module_init(PyObject *mod); | |
714 | void revlog_module_init(PyObject *mod); |
|
714 | void revlog_module_init(PyObject *mod); | |
715 |
|
715 | |||
716 |
static const int version = |
|
716 | static const int version = 11; | |
717 |
|
717 | |||
718 | static void module_init(PyObject *mod) |
|
718 | static void module_init(PyObject *mod) | |
719 | { |
|
719 | { |
@@ -1405,9 +1405,9 b' class dirstatemap(object):' | |||||
1405 |
|
1405 | |||
1406 | l = len(st) |
|
1406 | l = len(st) | |
1407 | if l == 40: |
|
1407 | if l == 40: | |
1408 | self._parents = st[:20], st[20:40] |
|
1408 | self._parents = (st[:20], st[20:40]) | |
1409 | elif l == 0: |
|
1409 | elif l == 0: | |
1410 |
self._parents = |
|
1410 | self._parents = (nullid, nullid) | |
1411 | else: |
|
1411 | else: | |
1412 | raise error.Abort(_('working directory state appears ' |
|
1412 | raise error.Abort(_('working directory state appears ' | |
1413 | 'damaged!')) |
|
1413 | 'damaged!')) |
@@ -69,7 +69,7 b' def _importfrom(pkgname, modname):' | |||||
69 | (r'cext', r'bdiff'): 3, |
|
69 | (r'cext', r'bdiff'): 3, | |
70 | (r'cext', r'mpatch'): 1, |
|
70 | (r'cext', r'mpatch'): 1, | |
71 | (r'cext', r'osutil'): 4, |
|
71 | (r'cext', r'osutil'): 4, | |
72 |
(r'cext', r'parsers'): |
|
72 | (r'cext', r'parsers'): 11, | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | # map import request to other package or module |
|
75 | # map import request to other package or module |
General Comments 0
You need to be logged in to leave comments.
Login now