Show More
@@ -2,7 +2,6 b'' | |||||
2 | # Do not add new files here! |
|
2 | # Do not add new files here! | |
3 | mercurial/cext/dirs.c |
|
3 | mercurial/cext/dirs.c | |
4 | mercurial/cext/manifest.c |
|
4 | mercurial/cext/manifest.c | |
5 | mercurial/cext/mpatch.c |
|
|||
6 | mercurial/cext/osutil.c |
|
5 | mercurial/cext/osutil.c | |
7 | mercurial/cext/revlog.c |
|
6 | mercurial/cext/revlog.c | |
8 | # Vendored code that we should never format: |
|
7 | # Vendored code that we should never format: |
@@ -55,10 +55,10 b' struct mpatch_flist *cpygetitem(void *bi' | |||||
55 | ssize_t blen; |
|
55 | ssize_t blen; | |
56 | int r; |
|
56 | int r; | |
57 |
|
57 | |||
58 | PyObject *tmp = PyList_GetItem((PyObject*)bins, pos); |
|
58 | PyObject *tmp = PyList_GetItem((PyObject *)bins, pos); | |
59 | if (!tmp) |
|
59 | if (!tmp) | |
60 | return NULL; |
|
60 | return NULL; | |
61 | if (PyObject_AsCharBuffer(tmp, &buffer, (Py_ssize_t*)&blen)) |
|
61 | if (PyObject_AsCharBuffer(tmp, &buffer, (Py_ssize_t *)&blen)) | |
62 | return NULL; |
|
62 | return NULL; | |
63 | if ((r = mpatch_decode(buffer, blen, &res)) < 0) { |
|
63 | if ((r = mpatch_decode(buffer, blen, &res)) < 0) { | |
64 | if (!PyErr_Occurred()) |
|
64 | if (!PyErr_Occurred()) | |
@@ -68,8 +68,7 b' struct mpatch_flist *cpygetitem(void *bi' | |||||
68 | return res; |
|
68 | return res; | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | static PyObject * |
|
71 | static PyObject *patches(PyObject *self, PyObject *args) | |
72 | patches(PyObject *self, PyObject *args) |
|
|||
73 | { |
|
72 | { | |
74 | PyObject *text, *bins, *result; |
|
73 | PyObject *text, *bins, *result; | |
75 | struct mpatch_flist *patch; |
|
74 | struct mpatch_flist *patch; | |
@@ -123,8 +122,7 b' cleanup:' | |||||
123 | } |
|
122 | } | |
124 |
|
123 | |||
125 | /* calculate size of a patched file directly */ |
|
124 | /* calculate size of a patched file directly */ | |
126 | static PyObject * |
|
125 | static PyObject *patchedsize(PyObject *self, PyObject *args) | |
127 | patchedsize(PyObject *self, PyObject *args) |
|
|||
128 | { |
|
126 | { | |
129 | long orig, start, end, len, outlen = 0, last = 0, pos = 0; |
|
127 | long orig, start, end, len, outlen = 0, last = 0, pos = 0; | |
130 | Py_ssize_t patchlen; |
|
128 | Py_ssize_t patchlen; | |
@@ -147,7 +145,8 b' patchedsize(PyObject *self, PyObject *ar' | |||||
147 |
|
145 | |||
148 | if (pos != patchlen) { |
|
146 | if (pos != patchlen) { | |
149 | if (!PyErr_Occurred()) |
|
147 | if (!PyErr_Occurred()) | |
150 |
PyErr_SetString(mpatch_Error, |
|
148 | PyErr_SetString(mpatch_Error, | |
|
149 | "patch cannot be decoded"); | |||
151 | return NULL; |
|
150 | return NULL; | |
152 | } |
|
151 | } | |
153 |
|
152 | |||
@@ -156,20 +155,16 b' patchedsize(PyObject *self, PyObject *ar' | |||||
156 | } |
|
155 | } | |
157 |
|
156 | |||
158 | static PyMethodDef methods[] = { |
|
157 | static PyMethodDef methods[] = { | |
159 |
|
|
158 | {"patches", patches, METH_VARARGS, "apply a series of patches\n"}, | |
160 |
|
|
159 | {"patchedsize", patchedsize, METH_VARARGS, "calculed patched size\n"}, | |
161 |
|
|
160 | {NULL, NULL}, | |
162 | }; |
|
161 | }; | |
163 |
|
162 | |||
164 | static const int version = 1; |
|
163 | static const int version = 1; | |
165 |
|
164 | |||
166 | #ifdef IS_PY3K |
|
165 | #ifdef IS_PY3K | |
167 | static struct PyModuleDef mpatch_module = { |
|
166 | static struct PyModuleDef mpatch_module = { | |
168 | PyModuleDef_HEAD_INIT, |
|
167 | PyModuleDef_HEAD_INIT, "mpatch", mpatch_doc, -1, methods, | |
169 | "mpatch", |
|
|||
170 | mpatch_doc, |
|
|||
171 | -1, |
|
|||
172 | methods |
|
|||
173 | }; |
|
168 | }; | |
174 |
|
169 | |||
175 | PyMODINIT_FUNC PyInit_mpatch(void) |
|
170 | PyMODINIT_FUNC PyInit_mpatch(void) | |
@@ -180,8 +175,8 b' PyMODINIT_FUNC PyInit_mpatch(void)' | |||||
180 | if (m == NULL) |
|
175 | if (m == NULL) | |
181 | return NULL; |
|
176 | return NULL; | |
182 |
|
177 | |||
183 | mpatch_Error = PyErr_NewException("mercurial.cext.mpatch.mpatchError", |
|
178 | mpatch_Error = | |
184 | NULL, NULL); |
|
179 | PyErr_NewException("mercurial.cext.mpatch.mpatchError", NULL, NULL); | |
185 | Py_INCREF(mpatch_Error); |
|
180 | Py_INCREF(mpatch_Error); | |
186 | PyModule_AddObject(m, "mpatchError", mpatch_Error); |
|
181 | PyModule_AddObject(m, "mpatchError", mpatch_Error); | |
187 | PyModule_AddIntConstant(m, "version", version); |
|
182 | PyModule_AddIntConstant(m, "version", version); | |
@@ -189,13 +184,12 b' PyMODINIT_FUNC PyInit_mpatch(void)' | |||||
189 | return m; |
|
184 | return m; | |
190 | } |
|
185 | } | |
191 | #else |
|
186 | #else | |
192 | PyMODINIT_FUNC |
|
187 | PyMODINIT_FUNC initmpatch(void) | |
193 | initmpatch(void) |
|
|||
194 | { |
|
188 | { | |
195 | PyObject *m; |
|
189 | PyObject *m; | |
196 | m = Py_InitModule3("mpatch", methods, mpatch_doc); |
|
190 | m = Py_InitModule3("mpatch", methods, mpatch_doc); | |
197 | mpatch_Error = PyErr_NewException("mercurial.cext.mpatch.mpatchError", |
|
191 | mpatch_Error = | |
198 | NULL, NULL); |
|
192 | PyErr_NewException("mercurial.cext.mpatch.mpatchError", NULL, NULL); | |
199 | PyModule_AddIntConstant(m, "version", version); |
|
193 | PyModule_AddIntConstant(m, "version", version); | |
200 | } |
|
194 | } | |
201 | #endif |
|
195 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now