##// END OF EJS Templates
revlog: signal which revlog index are compatible with Rust...
marmoute -
r48042:9d1a8829 default
parent child Browse files
Show More
@@ -668,7 +668,7 b' void dirs_module_init(PyObject *mod);'
668 void manifest_module_init(PyObject *mod);
668 void manifest_module_init(PyObject *mod);
669 void revlog_module_init(PyObject *mod);
669 void revlog_module_init(PyObject *mod);
670
670
671 static const int version = 19;
671 static const int version = 20;
672
672
673 static void module_init(PyObject *mod)
673 static void module_init(PyObject *mod)
674 {
674 {
@@ -101,8 +101,10 b' struct indexObjectStruct {'
101 int inlined;
101 int inlined;
102 long entry_size; /* size of index headers. Differs in v1 v.s. v2 format
102 long entry_size; /* size of index headers. Differs in v1 v.s. v2 format
103 */
103 */
104 char format_version; /* size of index headers. Differs in v1 v.s. v2
104 long rust_ext_compat; /* compatibility with being used in rust
105 format */
105 extensions */
106 char format_version; /* size of index headers. Differs in v1 v.s. v2
107 format */
106 };
108 };
107
109
108 static Py_ssize_t index_length(const indexObject *self)
110 static Py_ssize_t index_length(const indexObject *self)
@@ -2769,6 +2771,7 b' static int index_init(indexObject *self,'
2769 self->offsets = NULL;
2771 self->offsets = NULL;
2770 self->nodelen = 20;
2772 self->nodelen = 20;
2771 self->nullentry = NULL;
2773 self->nullentry = NULL;
2774 self->rust_ext_compat = 1;
2772
2775
2773 revlogv2 = NULL;
2776 revlogv2 = NULL;
2774 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|O", kwlist,
2777 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|O", kwlist,
@@ -2941,6 +2944,8 b' static PyGetSetDef index_getset[] = {'
2941 static PyMemberDef index_members[] = {
2944 static PyMemberDef index_members[] = {
2942 {"entry_size", T_LONG, offsetof(indexObject, entry_size), 0,
2945 {"entry_size", T_LONG, offsetof(indexObject, entry_size), 0,
2943 "size of an index entry"},
2946 "size of an index entry"},
2947 {"rust_ext_compat", T_LONG, offsetof(indexObject, rust_ext_compat), 0,
2948 "size of an index entry"},
2944 {NULL} /* Sentinel */
2949 {NULL} /* Sentinel */
2945 };
2950 };
2946
2951
@@ -80,7 +80,7 b' def _importfrom(pkgname, modname):'
80 ('cext', 'bdiff'): 3,
80 ('cext', 'bdiff'): 3,
81 ('cext', 'mpatch'): 1,
81 ('cext', 'mpatch'): 1,
82 ('cext', 'osutil'): 4,
82 ('cext', 'osutil'): 4,
83 ('cext', 'parsers'): 19,
83 ('cext', 'parsers'): 20,
84 }
84 }
85
85
86 # map import request to other package or module
86 # map import request to other package or module
@@ -47,6 +47,8 b' def offset_type(offset, type):'
47
47
48
48
49 class BaseIndexObject(object):
49 class BaseIndexObject(object):
50 # Can I be passed to an algorithme implemented in Rust ?
51 rust_ext_compat = 0
50 # Format of an index entry according to Python's `struct` language
52 # Format of an index entry according to Python's `struct` language
51 index_format = revlog_constants.INDEX_ENTRY_V1
53 index_format = revlog_constants.INDEX_ENTRY_V1
52 # Size of a C unsigned long long int, platform independent
54 # Size of a C unsigned long long int, platform independent
@@ -42,6 +42,7 b' def offset_type(offset, type):'
42
42
43
43
44 class revlogoldindex(list):
44 class revlogoldindex(list):
45 rust_ext_compat = 0
45 entry_size = INDEX_ENTRY_V0.size
46 entry_size = INDEX_ENTRY_V0.size
46 null_item = (
47 null_item = (
47 0,
48 0,
@@ -11,8 +11,8 b''
11 //! but this will take some time to get there.
11 //! but this will take some time to get there.
12
12
13 use cpython::{
13 use cpython::{
14 exc::ImportError, ObjectProtocol, PyClone, PyErr, PyObject, PyResult,
14 exc::ImportError, exc::TypeError, ObjectProtocol, PyClone, PyErr,
15 PyTuple, Python, PythonObject,
15 PyObject, PyResult, PyTuple, Python, PythonObject,
16 };
16 };
17 use hg::revlog::{Node, RevlogIndex};
17 use hg::revlog::{Node, RevlogIndex};
18 use hg::{Graph, GraphError, Revision, WORKING_DIRECTORY_REVISION};
18 use hg::{Graph, GraphError, Revision, WORKING_DIRECTORY_REVISION};
@@ -90,6 +90,13 b' impl Index {'
90 ),
90 ),
91 ));
91 ));
92 }
92 }
93 let compat: u64 = index.getattr(py, "rust_ext_compat")?.extract(py)?;
94 if compat == 0 {
95 return Err(PyErr::new::<TypeError, _>(
96 py,
97 "index object not compatible with Rust",
98 ));
99 }
93 Ok(Index { index, capi })
100 Ok(Index { index, capi })
94 }
101 }
95
102
@@ -300,6 +300,11 b' py_class!(pub class MixedIndex |py| {'
300 self.cindex(py).borrow().inner().getattr(py, "entry_size")?.extract::<PyInt>(py)
300 self.cindex(py).borrow().inner().getattr(py, "entry_size")?.extract::<PyInt>(py)
301 }
301 }
302
302
303 @property
304 def rust_ext_compat(&self) -> PyResult<PyInt> {
305 self.cindex(py).borrow().inner().getattr(py, "rust_ext_compat")?.extract::<PyInt>(py)
306 }
307
303 });
308 });
304
309
305 impl MixedIndex {
310 impl MixedIndex {
General Comments 0
You need to be logged in to leave comments. Login now