diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c --- a/mercurial/cext/parsers.c +++ b/mercurial/cext/parsers.c @@ -710,7 +710,7 @@ void manifest_module_init(PyObject *mod); void revlog_module_init(PyObject *mod); -static const int version = 4; +static const int version = 5; static void module_init(PyObject *mod) { diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c +++ b/mercurial/cext/revlog.c @@ -28,6 +28,20 @@ #define PyInt_AsLong PyLong_AsLong #endif +PyObject *get_index_entry_type(void) { + PyObject *mod, *obj; + + mod = PyImport_ImportModule("mercurial.pure.parsers"); + if (!mod) { + return NULL; + } + + obj = PyObject_GetAttrString(mod, "IndexV1Entry"); + Py_DECREF(mod); + + return obj; +} + /* * A base-16 trie for fast node->rev mapping. * @@ -54,6 +68,7 @@ typedef struct { PyObject_HEAD /* Type-specific fields go here. */ + PyObject *entrytype; /* mercurial.pure.parsers.IndexV1Entry type */ PyObject *nullentry; /* Represents an empty/unknown index value */ PyObject *data; /* raw bytes of index */ Py_buffer buf; /* buffer of data */ @@ -1862,6 +1877,7 @@ Py_ssize_t size; /* Initialize before argument-checking to avoid index_dealloc() crash. */ + self->entrytype = NULL; self->nullentry = NULL; self->raw_length = 0; self->added = NULL; @@ -1874,6 +1890,11 @@ self->nt = NULL; self->offsets = NULL; + self->entrytype = get_index_entry_type(); + if (!self->entrytype) { + return -1; + } + self->nullentry = Py_BuildValue("iiiiiiis#", 0, 0, 0, -1, -1, -1, -1, nullid, 20); if (!self->nullentry) { @@ -1937,6 +1958,7 @@ } Py_XDECREF(self->data); Py_XDECREF(self->added); + Py_XDECREF(self->entrytype); Py_XDECREF(self->nullentry); PyObject_Del(self); } @@ -2079,9 +2101,18 @@ void revlog_module_init(PyObject *mod) { + PyObject *index_entry_type; + indexType.tp_new = PyType_GenericNew; if (PyType_Ready(&indexType) < 0) return; Py_INCREF(&indexType); PyModule_AddObject(mod, "index", (PyObject *)&indexType); + + index_entry_type = get_index_entry_type(); + if (!index_entry_type) { + return; + } + + PyModule_AddObject(mod, "IndexV1Entry", index_entry_type); } diff --git a/mercurial/policy.py b/mercurial/policy.py --- a/mercurial/policy.py +++ b/mercurial/policy.py @@ -75,7 +75,7 @@ (r'cext', r'diffhelpers'): 1, (r'cext', r'mpatch'): 1, (r'cext', r'osutil'): 3, - (r'cext', r'parsers'): 4, + (r'cext', r'parsers'): 5, } # map import request to other package or module