Skip to content
Snippets Groups Projects
Commit 80dc1d45 authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

dirstate-entry: introduce dedicated accessors for v1 serialization

In the spirit of changing the content and storage of the dirstate entry, we add
new method that the code doing v1 serialisation can use.

Adding such method to the C object is quite trivial.

Differential Revision: https://phab.mercurial-scm.org/D10951
parent 67d11b0f
No related branches found
No related tags found
No related merge requests found
......@@ -118,6 +118,38 @@
0 /* sq_inplace_repeat */
};
static PyObject *dirstatetuple_v1_state(dirstateTupleObject *self)
{
return PyBytes_FromStringAndSize(&self->state, 1);
};
static PyObject *dirstatetuple_v1_mode(dirstateTupleObject *self)
{
return PyInt_FromLong(self->mode);
};
static PyObject *dirstatetuple_v1_size(dirstateTupleObject *self)
{
return PyInt_FromLong(self->size);
};
static PyObject *dirstatetuple_v1_mtime(dirstateTupleObject *self)
{
return PyInt_FromLong(self->mtime);
};
static PyMethodDef dirstatetuple_methods[] = {
{"v1_state", (PyCFunction)dirstatetuple_v1_state, METH_NOARGS,
"return a \"state\" suitable for v1 serialization"},
{"v1_mode", (PyCFunction)dirstatetuple_v1_mode, METH_NOARGS,
"return a \"mode\" suitable for v1 serialization"},
{"v1_size", (PyCFunction)dirstatetuple_v1_size, METH_NOARGS,
"return a \"size\" suitable for v1 serialization"},
{"v1_mtime", (PyCFunction)dirstatetuple_v1_mtime, METH_NOARGS,
"return a \"mtime\" suitable for v1 serialization"},
{NULL} /* Sentinel */
};
PyTypeObject dirstateTupleType = {
PyVarObject_HEAD_INIT(NULL, 0) /* header */
"dirstate_tuple", /* tp_name */
......@@ -146,7 +178,7 @@
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
dirstatetuple_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
......
......@@ -64,6 +64,22 @@
else:
raise IndexError(idx)
def v1_state(self):
"""return a "state" suitable for v1 serialization"""
return self._state
def v1_mode(self):
"""return a "mode" suitable for v1 serialization"""
return self._mode
def v1_size(self):
"""return a "size" suitable for v1 serialization"""
return self._size
def v1_mtime(self):
"""return a "mtime" suitable for v1 serialization"""
return self._mtime
def gettype(q):
return int(q & 0xFFFF)
......@@ -450,7 +466,14 @@
if f in copymap:
f = b"%s\0%s" % (f, copymap[f])
e = _pack(b">cllll", e[0], e[1], e[2], e[3], len(f))
e = _pack(
b">cllll",
e.v1_state(),
e.v1_mode(),
e.v1_size(),
e.v1_mtime(),
len(f),
)
write(e)
write(f)
return cs.getvalue()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment