Show More
@@ -1,7 +1,6 b'' | |||||
1 | # Files that just need to be migrated to the formatter. |
|
1 | # Files that just need to be migrated to the formatter. | |
2 | # Do not add new files here! |
|
2 | # Do not add new files here! | |
3 | mercurial/cext/base85.c |
|
3 | mercurial/cext/base85.c | |
4 | mercurial/cext/bdiff.c |
|
|||
5 | mercurial/cext/charencode.c |
|
4 | mercurial/cext/charencode.c | |
6 | mercurial/cext/charencode.h |
|
5 | mercurial/cext/charencode.h | |
7 | mercurial/cext/diffhelpers.c |
|
6 | mercurial/cext/diffhelpers.c |
@@ -19,7 +19,6 b'' | |||||
19 | #include "bitmanipulation.h" |
|
19 | #include "bitmanipulation.h" | |
20 | #include "util.h" |
|
20 | #include "util.h" | |
21 |
|
21 | |||
22 |
|
||||
23 | static PyObject *blocks(PyObject *self, PyObject *args) |
|
22 | static PyObject *blocks(PyObject *self, PyObject *args) | |
24 | { |
|
23 | { | |
25 | PyObject *sa, *sb, *rl = NULL, *m; |
|
24 | PyObject *sa, *sb, *rl = NULL, *m; | |
@@ -82,9 +81,7 b' static PyObject *bdiff(PyObject *self, P' | |||||
82 | _save = PyEval_SaveThread(); |
|
81 | _save = PyEval_SaveThread(); | |
83 |
|
82 | |||
84 | lmax = la > lb ? lb : la; |
|
83 | lmax = la > lb ? lb : la; | |
85 | for (ia = sa, ib = sb; |
|
84 | for (ia = sa, ib = sb; li < lmax && *ia == *ib; ++li, ++ia, ++ib) | |
86 | li < lmax && *ia == *ib; |
|
|||
87 | ++li, ++ia, ++ib) |
|
|||
88 | if (*ia == '\n') |
|
85 | if (*ia == '\n') | |
89 | lcommon = li + 1; |
|
86 | lcommon = li + 1; | |
90 | /* we can almost add: if (li == lmax) lcommon = li; */ |
|
87 | /* we can almost add: if (li == lmax) lcommon = li; */ | |
@@ -122,7 +119,8 b' static PyObject *bdiff(PyObject *self, P' | |||||
122 | if (h->a1 != la || h->b1 != lb) { |
|
119 | if (h->a1 != la || h->b1 != lb) { | |
123 | len = bl[h->b1].l - bl[lb].l; |
|
120 | len = bl[h->b1].l - bl[lb].l; | |
124 | putbe32((uint32_t)(al[la].l + lcommon - al->l), rb); |
|
121 | putbe32((uint32_t)(al[la].l + lcommon - al->l), rb); | |
125 |
putbe32((uint32_t)(al[h->a1].l + lcommon - al->l), |
|
122 | putbe32((uint32_t)(al[h->a1].l + lcommon - al->l), | |
|
123 | rb + 4); | |||
126 | putbe32((uint32_t)len, rb + 8); |
|
124 | putbe32((uint32_t)len, rb + 8); | |
127 | memcpy(rb + 12, bl[lb].l, len); |
|
125 | memcpy(rb + 12, bl[lb].l, len); | |
128 | rb += 12 + len; |
|
126 | rb += 12 + len; | |
@@ -167,8 +165,8 b' static PyObject *fixws(PyObject *self, P' | |||||
167 | if (c == ' ' || c == '\t' || c == '\r') { |
|
165 | if (c == ' ' || c == '\t' || c == '\r') { | |
168 | if (!allws && (wlen == 0 || w[wlen - 1] != ' ')) |
|
166 | if (!allws && (wlen == 0 || w[wlen - 1] != ' ')) | |
169 | w[wlen++] = ' '; |
|
167 | w[wlen++] = ' '; | |
170 | } else if (c == '\n' && !allws |
|
168 | } else if (c == '\n' && !allws && wlen > 0 && | |
171 |
|
|
169 | w[wlen - 1] == ' ') { | |
172 | w[wlen - 1] = '\n'; |
|
170 | w[wlen - 1] = '\n'; | |
173 | } else { |
|
171 | } else { | |
174 | w[wlen++] = c; |
|
172 | w[wlen++] = c; | |
@@ -182,25 +180,20 b' nomem:' | |||||
182 | return result ? result : PyErr_NoMemory(); |
|
180 | return result ? result : PyErr_NoMemory(); | |
183 | } |
|
181 | } | |
184 |
|
182 | |||
185 |
|
||||
186 | static char mdiff_doc[] = "Efficient binary diff."; |
|
183 | static char mdiff_doc[] = "Efficient binary diff."; | |
187 |
|
184 | |||
188 | static PyMethodDef methods[] = { |
|
185 | static PyMethodDef methods[] = { | |
189 |
|
|
186 | {"bdiff", bdiff, METH_VARARGS, "calculate a binary diff\n"}, | |
190 |
|
|
187 | {"blocks", blocks, METH_VARARGS, "find a list of matching lines\n"}, | |
191 |
|
|
188 | {"fixws", fixws, METH_VARARGS, "normalize diff whitespaces\n"}, | |
192 |
|
|
189 | {NULL, NULL}, | |
193 | }; |
|
190 | }; | |
194 |
|
191 | |||
195 | static const int version = 1; |
|
192 | static const int version = 1; | |
196 |
|
193 | |||
197 | #ifdef IS_PY3K |
|
194 | #ifdef IS_PY3K | |
198 | static struct PyModuleDef bdiff_module = { |
|
195 | static struct PyModuleDef bdiff_module = { | |
199 | PyModuleDef_HEAD_INIT, |
|
196 | PyModuleDef_HEAD_INIT, "bdiff", mdiff_doc, -1, methods, | |
200 | "bdiff", |
|
|||
201 | mdiff_doc, |
|
|||
202 | -1, |
|
|||
203 | methods |
|
|||
204 | }; |
|
197 | }; | |
205 |
|
198 | |||
206 | PyMODINIT_FUNC PyInit_bdiff(void) |
|
199 | PyMODINIT_FUNC PyInit_bdiff(void) |
General Comments 0
You need to be logged in to leave comments.
Login now