##// END OF EJS Templates
parsers: allow clang-format here...
Augie Fackler -
r34863:d92dc725 default
parent child Browse files
Show More
@@ -17,7 +17,6 b' mercurial/cext/dirs.c'
17 mercurial/cext/manifest.c
17 mercurial/cext/manifest.c
18 mercurial/cext/mpatch.c
18 mercurial/cext/mpatch.c
19 mercurial/cext/osutil.c
19 mercurial/cext/osutil.c
20 mercurial/cext/parsers.c
21 mercurial/cext/pathencode.c
20 mercurial/cext/pathencode.c
22 mercurial/cext/revlog.c
21 mercurial/cext/revlog.c
23 # Vendored code that we should never format:
22 # Vendored code that we should never format:
@@ -48,10 +48,8 b' static PyObject *parse_manifest(PyObject'
48 char *str, *start, *end;
48 char *str, *start, *end;
49 int len;
49 int len;
50
50
51 if (!PyArg_ParseTuple(args, "O!O!s#:parse_manifest",
51 if (!PyArg_ParseTuple(args, "O!O!s#:parse_manifest", &PyDict_Type,
52 &PyDict_Type, &mfdict,
52 &mfdict, &PyDict_Type, &fdict, &str, &len))
53 &PyDict_Type, &fdict,
54 &str, &len))
55 goto quit;
53 goto quit;
56
54
57 start = str;
55 start = str;
@@ -65,14 +63,14 b' static PyObject *parse_manifest(PyObject'
65 zero = memchr(start, '\0', end - start);
63 zero = memchr(start, '\0', end - start);
66 if (!zero) {
64 if (!zero) {
67 PyErr_SetString(PyExc_ValueError,
65 PyErr_SetString(PyExc_ValueError,
68 "manifest entry has no separator");
66 "manifest entry has no separator");
69 goto quit;
67 goto quit;
70 }
68 }
71
69
72 newline = memchr(zero + 1, '\n', end - (zero + 1));
70 newline = memchr(zero + 1, '\n', end - (zero + 1));
73 if (!newline) {
71 if (!newline) {
74 PyErr_SetString(PyExc_ValueError,
72 PyErr_SetString(PyExc_ValueError,
75 "manifest contains trailing garbage");
73 "manifest contains trailing garbage");
76 goto quit;
74 goto quit;
77 }
75 }
78
76
@@ -88,8 +86,7 b' static PyObject *parse_manifest(PyObject'
88 goto bail;
86 goto bail;
89
87
90 if (nlen > 40) {
88 if (nlen > 40) {
91 flags = PyBytes_FromStringAndSize(zero + 41,
89 flags = PyBytes_FromStringAndSize(zero + 41, nlen - 40);
92 nlen - 40);
93 if (!flags)
90 if (!flags)
94 goto bail;
91 goto bail;
95
92
@@ -120,10 +117,10 b' quit:'
120 }
117 }
121
118
122 static inline dirstateTupleObject *make_dirstate_tuple(char state, int mode,
119 static inline dirstateTupleObject *make_dirstate_tuple(char state, int mode,
123 int size, int mtime)
120 int size, int mtime)
124 {
121 {
125 dirstateTupleObject *t = PyObject_New(dirstateTupleObject,
122 dirstateTupleObject *t =
126 &dirstateTupleType);
123 PyObject_New(dirstateTupleObject, &dirstateTupleType);
127 if (!t)
124 if (!t)
128 return NULL;
125 return NULL;
129 t->state = state;
126 t->state = state;
@@ -134,7 +131,7 b' static inline dirstateTupleObject *make_'
134 }
131 }
135
132
136 static PyObject *dirstate_tuple_new(PyTypeObject *subtype, PyObject *args,
133 static PyObject *dirstate_tuple_new(PyTypeObject *subtype, PyObject *args,
137 PyObject *kwds)
134 PyObject *kwds)
138 {
135 {
139 /* We do all the initialization here and not a tp_init function because
136 /* We do all the initialization here and not a tp_init function because
140 * dirstate_tuple is immutable. */
137 * dirstate_tuple is immutable. */
@@ -184,55 +181,55 b' static PyObject *dirstate_tuple_item(PyO'
184 }
181 }
185
182
186 static PySequenceMethods dirstate_tuple_sq = {
183 static PySequenceMethods dirstate_tuple_sq = {
187 dirstate_tuple_length, /* sq_length */
184 dirstate_tuple_length, /* sq_length */
188 0, /* sq_concat */
185 0, /* sq_concat */
189 0, /* sq_repeat */
186 0, /* sq_repeat */
190 dirstate_tuple_item, /* sq_item */
187 dirstate_tuple_item, /* sq_item */
191 0, /* sq_ass_item */
188 0, /* sq_ass_item */
192 0, /* sq_contains */
189 0, /* sq_contains */
193 0, /* sq_inplace_concat */
190 0, /* sq_inplace_concat */
194 0 /* sq_inplace_repeat */
191 0 /* sq_inplace_repeat */
195 };
192 };
196
193
197 PyTypeObject dirstateTupleType = {
194 PyTypeObject dirstateTupleType = {
198 PyVarObject_HEAD_INIT(NULL, 0) /* header */
195 PyVarObject_HEAD_INIT(NULL, 0) /* header */
199 "dirstate_tuple", /* tp_name */
196 "dirstate_tuple", /* tp_name */
200 sizeof(dirstateTupleObject),/* tp_basicsize */
197 sizeof(dirstateTupleObject), /* tp_basicsize */
201 0, /* tp_itemsize */
198 0, /* tp_itemsize */
202 (destructor)dirstate_tuple_dealloc, /* tp_dealloc */
199 (destructor)dirstate_tuple_dealloc, /* tp_dealloc */
203 0, /* tp_print */
200 0, /* tp_print */
204 0, /* tp_getattr */
201 0, /* tp_getattr */
205 0, /* tp_setattr */
202 0, /* tp_setattr */
206 0, /* tp_compare */
203 0, /* tp_compare */
207 0, /* tp_repr */
204 0, /* tp_repr */
208 0, /* tp_as_number */
205 0, /* tp_as_number */
209 &dirstate_tuple_sq, /* tp_as_sequence */
206 &dirstate_tuple_sq, /* tp_as_sequence */
210 0, /* tp_as_mapping */
207 0, /* tp_as_mapping */
211 0, /* tp_hash */
208 0, /* tp_hash */
212 0, /* tp_call */
209 0, /* tp_call */
213 0, /* tp_str */
210 0, /* tp_str */
214 0, /* tp_getattro */
211 0, /* tp_getattro */
215 0, /* tp_setattro */
212 0, /* tp_setattro */
216 0, /* tp_as_buffer */
213 0, /* tp_as_buffer */
217 Py_TPFLAGS_DEFAULT, /* tp_flags */
214 Py_TPFLAGS_DEFAULT, /* tp_flags */
218 "dirstate tuple", /* tp_doc */
215 "dirstate tuple", /* tp_doc */
219 0, /* tp_traverse */
216 0, /* tp_traverse */
220 0, /* tp_clear */
217 0, /* tp_clear */
221 0, /* tp_richcompare */
218 0, /* tp_richcompare */
222 0, /* tp_weaklistoffset */
219 0, /* tp_weaklistoffset */
223 0, /* tp_iter */
220 0, /* tp_iter */
224 0, /* tp_iternext */
221 0, /* tp_iternext */
225 0, /* tp_methods */
222 0, /* tp_methods */
226 0, /* tp_members */
223 0, /* tp_members */
227 0, /* tp_getset */
224 0, /* tp_getset */
228 0, /* tp_base */
225 0, /* tp_base */
229 0, /* tp_dict */
226 0, /* tp_dict */
230 0, /* tp_descr_get */
227 0, /* tp_descr_get */
231 0, /* tp_descr_set */
228 0, /* tp_descr_set */
232 0, /* tp_dictoffset */
229 0, /* tp_dictoffset */
233 0, /* tp_init */
230 0, /* tp_init */
234 0, /* tp_alloc */
231 0, /* tp_alloc */
235 dirstate_tuple_new, /* tp_new */
232 dirstate_tuple_new, /* tp_new */
236 };
233 };
237
234
238 static PyObject *parse_dirstate(PyObject *self, PyObject *args)
235 static PyObject *parse_dirstate(PyObject *self, PyObject *args)
@@ -244,18 +241,16 b' static PyObject *parse_dirstate(PyObject'
244 unsigned int flen, len, pos = 40;
241 unsigned int flen, len, pos = 40;
245 int readlen;
242 int readlen;
246
243
247 if (!PyArg_ParseTuple(args, "O!O!s#:parse_dirstate",
244 if (!PyArg_ParseTuple(args, "O!O!s#:parse_dirstate", &PyDict_Type,
248 &PyDict_Type, &dmap,
245 &dmap, &PyDict_Type, &cmap, &str, &readlen))
249 &PyDict_Type, &cmap,
250 &str, &readlen))
251 goto quit;
246 goto quit;
252
247
253 len = readlen;
248 len = readlen;
254
249
255 /* read parents */
250 /* read parents */
256 if (len < 40) {
251 if (len < 40) {
257 PyErr_SetString(
252 PyErr_SetString(PyExc_ValueError,
258 PyExc_ValueError, "too little data for parents");
253 "too little data for parents");
259 goto quit;
254 goto quit;
260 }
255 }
261
256
@@ -267,7 +262,7 b' static PyObject *parse_dirstate(PyObject'
267 while (pos >= 40 && pos < len) {
262 while (pos >= 40 && pos < len) {
268 if (pos + 17 > len) {
263 if (pos + 17 > len) {
269 PyErr_SetString(PyExc_ValueError,
264 PyErr_SetString(PyExc_ValueError,
270 "overflow in dirstate");
265 "overflow in dirstate");
271 goto quit;
266 goto quit;
272 }
267 }
273 cur = str + pos;
268 cur = str + pos;
@@ -280,17 +275,18 b' static PyObject *parse_dirstate(PyObject'
280 pos += 17;
275 pos += 17;
281 cur += 17;
276 cur += 17;
282 if (flen > len - pos) {
277 if (flen > len - pos) {
283 PyErr_SetString(PyExc_ValueError, "overflow in dirstate");
278 PyErr_SetString(PyExc_ValueError,
279 "overflow in dirstate");
284 goto quit;
280 goto quit;
285 }
281 }
286
282
287 entry = (PyObject *)make_dirstate_tuple(state, mode, size,
283 entry =
288 mtime);
284 (PyObject *)make_dirstate_tuple(state, mode, size, mtime);
289 cpos = memchr(cur, 0, flen);
285 cpos = memchr(cur, 0, flen);
290 if (cpos) {
286 if (cpos) {
291 fname = PyBytes_FromStringAndSize(cur, cpos - cur);
287 fname = PyBytes_FromStringAndSize(cur, cpos - cur);
292 cname = PyBytes_FromStringAndSize(cpos + 1,
288 cname = PyBytes_FromStringAndSize(
293 flen - (cpos - cur) - 1);
289 cpos + 1, flen - (cpos - cur) - 1);
294 if (!fname || !cname ||
290 if (!fname || !cname ||
295 PyDict_SetItem(cmap, fname, cname) == -1 ||
291 PyDict_SetItem(cmap, fname, cname) == -1 ||
296 PyDict_SetItem(dmap, fname, entry) == -1)
292 PyDict_SetItem(dmap, fname, entry) == -1)
@@ -298,8 +294,7 b' static PyObject *parse_dirstate(PyObject'
298 Py_DECREF(cname);
294 Py_DECREF(cname);
299 } else {
295 } else {
300 fname = PyBytes_FromStringAndSize(cur, flen);
296 fname = PyBytes_FromStringAndSize(cur, flen);
301 if (!fname ||
297 if (!fname || PyDict_SetItem(dmap, fname, entry) == -1)
302 PyDict_SetItem(dmap, fname, entry) == -1)
303 goto quit;
298 goto quit;
304 }
299 }
305 Py_DECREF(fname);
300 Py_DECREF(fname);
@@ -320,15 +315,14 b' quit:'
320
315
321 /*
316 /*
322 * Build a set of non-normal and other parent entries from the dirstate dmap
317 * Build a set of non-normal and other parent entries from the dirstate dmap
323 */
318 */
324 static PyObject *nonnormalotherparententries(PyObject *self, PyObject *args)
319 static PyObject *nonnormalotherparententries(PyObject *self, PyObject *args)
325 {
320 {
326 PyObject *dmap, *fname, *v;
321 PyObject *dmap, *fname, *v;
327 PyObject *nonnset = NULL, *otherpset = NULL, *result = NULL;
322 PyObject *nonnset = NULL, *otherpset = NULL, *result = NULL;
328 Py_ssize_t pos;
323 Py_ssize_t pos;
329
324
330 if (!PyArg_ParseTuple(args, "O!:nonnormalentries",
325 if (!PyArg_ParseTuple(args, "O!:nonnormalentries", &PyDict_Type, &dmap))
331 &PyDict_Type, &dmap))
332 goto bail;
326 goto bail;
333
327
334 nonnset = PySet_New(NULL);
328 nonnset = PySet_New(NULL);
@@ -344,7 +338,7 b' static PyObject *nonnormalotherparentent'
344 dirstateTupleObject *t;
338 dirstateTupleObject *t;
345 if (!dirstate_tuple_check(v)) {
339 if (!dirstate_tuple_check(v)) {
346 PyErr_SetString(PyExc_TypeError,
340 PyErr_SetString(PyExc_TypeError,
347 "expected a dirstate tuple");
341 "expected a dirstate tuple");
348 goto bail;
342 goto bail;
349 }
343 }
350 t = (dirstateTupleObject *)v;
344 t = (dirstateTupleObject *)v;
@@ -386,9 +380,8 b' static PyObject *pack_dirstate(PyObject '
386 char *p, *s;
380 char *p, *s;
387 int now;
381 int now;
388
382
389 if (!PyArg_ParseTuple(args, "O!O!Oi:pack_dirstate",
383 if (!PyArg_ParseTuple(args, "O!O!Oi:pack_dirstate", &PyDict_Type, &map,
390 &PyDict_Type, &map, &PyDict_Type, &copymap,
384 &PyDict_Type, &copymap, &pl, &now))
391 &pl, &now))
392 return NULL;
385 return NULL;
393
386
394 if (!PySequence_Check(pl) || PySequence_Size(pl) != 2) {
387 if (!PySequence_Check(pl) || PySequence_Size(pl) != 2) {
@@ -408,7 +401,7 b' static PyObject *pack_dirstate(PyObject '
408 if (c) {
401 if (c) {
409 if (!PyBytes_Check(c)) {
402 if (!PyBytes_Check(c)) {
410 PyErr_SetString(PyExc_TypeError,
403 PyErr_SetString(PyExc_TypeError,
411 "expected string key");
404 "expected string key");
412 goto bail;
405 goto bail;
413 }
406 }
414 nbytes += PyBytes_GET_SIZE(c) + 1;
407 nbytes += PyBytes_GET_SIZE(c) + 1;
@@ -436,7 +429,7 b' static PyObject *pack_dirstate(PyObject '
436 memcpy(p, s, l);
429 memcpy(p, s, l);
437 p += 20;
430 p += 20;
438
431
439 for (pos = 0; PyDict_Next(map, &pos, &k, &v); ) {
432 for (pos = 0; PyDict_Next(map, &pos, &k, &v);) {
440 dirstateTupleObject *tuple;
433 dirstateTupleObject *tuple;
441 char state;
434 char state;
442 int mode, size, mtime;
435 int mode, size, mtime;
@@ -446,7 +439,7 b' static PyObject *pack_dirstate(PyObject '
446
439
447 if (!dirstate_tuple_check(v)) {
440 if (!dirstate_tuple_check(v)) {
448 PyErr_SetString(PyExc_TypeError,
441 PyErr_SetString(PyExc_TypeError,
449 "expected a dirstate tuple");
442 "expected a dirstate tuple");
450 goto bail;
443 goto bail;
451 }
444 }
452 tuple = (dirstateTupleObject *)v;
445 tuple = (dirstateTupleObject *)v;
@@ -460,7 +453,7 b' static PyObject *pack_dirstate(PyObject '
460 * this. */
453 * this. */
461 mtime = -1;
454 mtime = -1;
462 mtime_unset = (PyObject *)make_dirstate_tuple(
455 mtime_unset = (PyObject *)make_dirstate_tuple(
463 state, mode, size, mtime);
456 state, mode, size, mtime);
464 if (!mtime_unset)
457 if (!mtime_unset)
465 goto bail;
458 goto bail;
466 if (PyDict_SetItem(map, k, mtime_unset) == -1)
459 if (PyDict_SetItem(map, k, mtime_unset) == -1)
@@ -491,7 +484,7 b' static PyObject *pack_dirstate(PyObject '
491 pos = p - PyBytes_AS_STRING(packobj);
484 pos = p - PyBytes_AS_STRING(packobj);
492 if (pos != nbytes) {
485 if (pos != nbytes) {
493 PyErr_Format(PyExc_SystemError, "bad dirstate size: %ld != %ld",
486 PyErr_Format(PyExc_SystemError, "bad dirstate size: %ld != %ld",
494 (long)pos, (long)nbytes);
487 (long)pos, (long)nbytes);
495 goto bail;
488 goto bail;
496 }
489 }
497
490
@@ -507,8 +500,8 b' bail:'
507 #define USING_SHA_256 2
500 #define USING_SHA_256 2
508 #define FM1_HEADER_SIZE (4 + 8 + 2 + 2 + 1 + 1 + 1)
501 #define FM1_HEADER_SIZE (4 + 8 + 2 + 2 + 1 + 1 + 1)
509
502
510 static PyObject *readshas(
503 static PyObject *readshas(const char *source, unsigned char num,
511 const char *source, unsigned char num, Py_ssize_t hashwidth)
504 Py_ssize_t hashwidth)
512 {
505 {
513 int i;
506 int i;
514 PyObject *list = PyTuple_New(num);
507 PyObject *list = PyTuple_New(num);
@@ -528,7 +521,7 b' static PyObject *readshas('
528 }
521 }
529
522
530 static PyObject *fm1readmarker(const char *databegin, const char *dataend,
523 static PyObject *fm1readmarker(const char *databegin, const char *dataend,
531 uint32_t *msize)
524 uint32_t *msize)
532 {
525 {
533 const char *data = databegin;
526 const char *data = databegin;
534 const char *meta;
527 const char *meta;
@@ -567,7 +560,7 b' static PyObject *fm1readmarker(const cha'
567 if (databegin + *msize > dataend) {
560 if (databegin + *msize > dataend) {
568 goto overflow;
561 goto overflow;
569 }
562 }
570 dataend = databegin + *msize; /* narrow down to marker size */
563 dataend = databegin + *msize; /* narrow down to marker size */
571
564
572 if (data + hashwidth > dataend) {
565 if (data + hashwidth > dataend) {
573 goto overflow;
566 goto overflow;
@@ -631,9 +624,9 b' static PyObject *fm1readmarker(const cha'
631 PyTuple_SET_ITEM(tmp, 1, right);
624 PyTuple_SET_ITEM(tmp, 1, right);
632 PyTuple_SET_ITEM(metadata, i, tmp);
625 PyTuple_SET_ITEM(metadata, i, tmp);
633 }
626 }
634 ret = Py_BuildValue("(OOHO(di)O)", prec, succs, flags,
627 ret = Py_BuildValue("(OOHO(di)O)", prec, succs, flags, metadata, mtime,
635 metadata, mtime, (int)tz * 60, parents);
628 (int)tz * 60, parents);
636 goto bail; /* return successfully */
629 goto bail; /* return successfully */
637
630
638 overflow:
631 overflow:
639 PyErr_SetString(PyExc_ValueError, "overflow in obsstore");
632 PyErr_SetString(PyExc_ValueError, "overflow in obsstore");
@@ -645,7 +638,6 b' bail:'
645 return ret;
638 return ret;
646 }
639 }
647
640
648
649 static PyObject *fm1readmarkers(PyObject *self, PyObject *args)
641 static PyObject *fm1readmarkers(PyObject *self, PyObject *args)
650 {
642 {
651 const char *data, *dataend;
643 const char *data, *dataend;
@@ -691,29 +683,28 b' PyObject *lowerencode(PyObject *self, Py'
691 PyObject *parse_index2(PyObject *self, PyObject *args);
683 PyObject *parse_index2(PyObject *self, PyObject *args);
692
684
693 static PyMethodDef methods[] = {
685 static PyMethodDef methods[] = {
694 {"pack_dirstate", pack_dirstate, METH_VARARGS, "pack a dirstate\n"},
686 {"pack_dirstate", pack_dirstate, METH_VARARGS, "pack a dirstate\n"},
695 {"nonnormalotherparententries", nonnormalotherparententries, METH_VARARGS,
687 {"nonnormalotherparententries", nonnormalotherparententries, METH_VARARGS,
696 "create a set containing non-normal and other parent entries of given "
688 "create a set containing non-normal and other parent entries of given "
697 "dirstate\n"},
689 "dirstate\n"},
698 {"parse_manifest", parse_manifest, METH_VARARGS, "parse a manifest\n"},
690 {"parse_manifest", parse_manifest, METH_VARARGS, "parse a manifest\n"},
699 {"parse_dirstate", parse_dirstate, METH_VARARGS, "parse a dirstate\n"},
691 {"parse_dirstate", parse_dirstate, METH_VARARGS, "parse a dirstate\n"},
700 {"parse_index2", parse_index2, METH_VARARGS, "parse a revlog index\n"},
692 {"parse_index2", parse_index2, METH_VARARGS, "parse a revlog index\n"},
701 {"isasciistr", isasciistr, METH_VARARGS, "check if an ASCII string\n"},
693 {"isasciistr", isasciistr, METH_VARARGS, "check if an ASCII string\n"},
702 {"asciilower", asciilower, METH_VARARGS, "lowercase an ASCII string\n"},
694 {"asciilower", asciilower, METH_VARARGS, "lowercase an ASCII string\n"},
703 {"asciiupper", asciiupper, METH_VARARGS, "uppercase an ASCII string\n"},
695 {"asciiupper", asciiupper, METH_VARARGS, "uppercase an ASCII string\n"},
704 {"dict_new_presized", dict_new_presized, METH_VARARGS,
696 {"dict_new_presized", dict_new_presized, METH_VARARGS,
705 "construct a dict with an expected size\n"},
697 "construct a dict with an expected size\n"},
706 {"make_file_foldmap", make_file_foldmap, METH_VARARGS,
698 {"make_file_foldmap", make_file_foldmap, METH_VARARGS,
707 "make file foldmap\n"},
699 "make file foldmap\n"},
708 {"jsonescapeu8fast", jsonescapeu8fast, METH_VARARGS,
700 {"jsonescapeu8fast", jsonescapeu8fast, METH_VARARGS,
709 "escape a UTF-8 byte string to JSON (fast path)\n"},
701 "escape a UTF-8 byte string to JSON (fast path)\n"},
710 {"encodedir", encodedir, METH_VARARGS, "encodedir a path\n"},
702 {"encodedir", encodedir, METH_VARARGS, "encodedir a path\n"},
711 {"pathencode", pathencode, METH_VARARGS, "fncache-encode a path\n"},
703 {"pathencode", pathencode, METH_VARARGS, "fncache-encode a path\n"},
712 {"lowerencode", lowerencode, METH_VARARGS, "lower-encode a path\n"},
704 {"lowerencode", lowerencode, METH_VARARGS, "lower-encode a path\n"},
713 {"fm1readmarkers", fm1readmarkers, METH_VARARGS,
705 {"fm1readmarkers", fm1readmarkers, METH_VARARGS,
714 "parse v1 obsolete markers\n"},
706 "parse v1 obsolete markers\n"},
715 {NULL, NULL}
707 {NULL, NULL}};
716 };
717
708
718 void dirs_module_init(PyObject *mod);
709 void dirs_module_init(PyObject *mod);
719 void manifest_module_init(PyObject *mod);
710 void manifest_module_init(PyObject *mod);
@@ -743,7 +734,7 b' static void module_init(PyObject *mod)'
743 return;
734 return;
744 Py_INCREF(&dirstateTupleType);
735 Py_INCREF(&dirstateTupleType);
745 PyModule_AddObject(mod, "dirstatetuple",
736 PyModule_AddObject(mod, "dirstatetuple",
746 (PyObject *)&dirstateTupleType);
737 (PyObject *)&dirstateTupleType);
747 }
738 }
748
739
749 static int check_python_version(void)
740 static int check_python_version(void)
@@ -762,24 +753,23 b' static int check_python_version(void)'
762 * should only occur in unusual circumstances (e.g. if sys.hexversion
753 * should only occur in unusual circumstances (e.g. if sys.hexversion
763 * is manually set to an invalid value). */
754 * is manually set to an invalid value). */
764 if ((hexversion == -1) || (hexversion >> 16 != PY_VERSION_HEX >> 16)) {
755 if ((hexversion == -1) || (hexversion >> 16 != PY_VERSION_HEX >> 16)) {
765 PyErr_Format(PyExc_ImportError, "%s: The Mercurial extension "
756 PyErr_Format(PyExc_ImportError,
766 "modules were compiled with Python " PY_VERSION ", but "
757 "%s: The Mercurial extension "
767 "Mercurial is currently using Python with sys.hexversion=%ld: "
758 "modules were compiled with Python " PY_VERSION
768 "Python %s\n at: %s", versionerrortext, hexversion,
759 ", but "
769 Py_GetVersion(), Py_GetProgramFullPath());
760 "Mercurial is currently using Python with "
761 "sys.hexversion=%ld: "
762 "Python %s\n at: %s",
763 versionerrortext, hexversion, Py_GetVersion(),
764 Py_GetProgramFullPath());
770 return -1;
765 return -1;
771 }
766 }
772 return 0;
767 return 0;
773 }
768 }
774
769
775 #ifdef IS_PY3K
770 #ifdef IS_PY3K
776 static struct PyModuleDef parsers_module = {
771 static struct PyModuleDef parsers_module = {PyModuleDef_HEAD_INIT, "parsers",
777 PyModuleDef_HEAD_INIT,
772 parsers_doc, -1, methods};
778 "parsers",
779 parsers_doc,
780 -1,
781 methods
782 };
783
773
784 PyMODINIT_FUNC PyInit_parsers(void)
774 PyMODINIT_FUNC PyInit_parsers(void)
785 {
775 {
General Comments 0
You need to be logged in to leave comments. Login now