Mercurial > hg
comparison mercurial/cext/parsers.c @ 42303:e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
This allows for Python code to call `parse/pack_dirstate` transparently.
These bindings are heavy given the relatively simple task, as they are bound
to implementation details of both the C and Python code. They will be slimmed
down in future patches and eventually completely removed once more of the
dirstate code has been refactored/rewritten in Rust.
Both functions emulate the mutate-on-loop style of the Python and C
implementations by looping over changed items in the compatibility layer,
instead of at the core functions.
Differential Revision: https://phab.mercurial-scm.org/D6349
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 06 May 2019 22:50:34 +0200 |
parents | 509a0477b3a6 |
children | d8e55c0c642c |
comparison
equal
deleted
inserted
replaced
42302:d1786c1d34fa | 42303:e240bec26626 |
---|---|
669 | 669 |
670 static const int version = 12; | 670 static const int version = 12; |
671 | 671 |
672 static void module_init(PyObject *mod) | 672 static void module_init(PyObject *mod) |
673 { | 673 { |
674 PyObject *capsule = NULL; | |
674 PyModule_AddIntConstant(mod, "version", version); | 675 PyModule_AddIntConstant(mod, "version", version); |
675 | 676 |
676 /* This module constant has two purposes. First, it lets us unit test | 677 /* This module constant has two purposes. First, it lets us unit test |
677 * the ImportError raised without hard-coding any error text. This | 678 * the ImportError raised without hard-coding any error text. This |
678 * means we can change the text in the future without breaking tests, | 679 * means we can change the text in the future without breaking tests, |
684 PyModule_AddStringConstant(mod, "versionerrortext", versionerrortext); | 685 PyModule_AddStringConstant(mod, "versionerrortext", versionerrortext); |
685 | 686 |
686 dirs_module_init(mod); | 687 dirs_module_init(mod); |
687 manifest_module_init(mod); | 688 manifest_module_init(mod); |
688 revlog_module_init(mod); | 689 revlog_module_init(mod); |
690 | |
691 capsule = PyCapsule_New( | |
692 make_dirstate_tuple, | |
693 "mercurial.cext.parsers.make_dirstate_tuple_CAPI", NULL); | |
694 if (capsule != NULL) | |
695 PyModule_AddObject(mod, "make_dirstate_tuple_CAPI", capsule); | |
689 | 696 |
690 if (PyType_Ready(&dirstateTupleType) < 0) { | 697 if (PyType_Ready(&dirstateTupleType) < 0) { |
691 return; | 698 return; |
692 } | 699 } |
693 Py_INCREF(&dirstateTupleType); | 700 Py_INCREF(&dirstateTupleType); |