See inline documentation for details.
The pushes the AMBIGUOUS_TIME implementation further down the line within the
DirstateItem only. When this cleanup is done we will be able to stop using this
representation internally.
| Alphare | |
| pulkit |
| hg-reviewers |
See inline documentation for details.
The pushes the AMBIGUOUS_TIME implementation further down the line within the
DirstateItem only. When this cleanup is done we will be able to stop using this
representation internally.
| Automatic diff as part of commit; lint not applicable. |
| Automatic diff as part of commit; unit tests not applicable. |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/cext/parsers.c (11 lines) | |||
| M | mercurial/pure/parsers.py (8 lines) |
| #define PyInt_FromSsize_t PyLong_FromSsize_t | #define PyInt_FromSsize_t PyLong_FromSsize_t | ||||
| #define PyInt_AsLong PyLong_AsLong | #define PyInt_AsLong PyLong_AsLong | ||||
| #endif | #endif | ||||
| static const char *const versionerrortext = "Python minor version mismatch"; | static const char *const versionerrortext = "Python minor version mismatch"; | ||||
| static const int dirstate_v1_from_p2 = -2; | static const int dirstate_v1_from_p2 = -2; | ||||
| static const int dirstate_v1_nonnormal = -1; | static const int dirstate_v1_nonnormal = -1; | ||||
| static const int ambiguous_time = -1; | |||||
| static PyObject *dict_new_presized(PyObject *self, PyObject *args) | static PyObject *dict_new_presized(PyObject *self, PyObject *args) | ||||
| { | { | ||||
| Py_ssize_t expected_size; | Py_ssize_t expected_size; | ||||
| if (!PyArg_ParseTuple(args, "n:make_presized_dict", &expected_size)) { | if (!PyArg_ParseTuple(args, "n:make_presized_dict", &expected_size)) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| t->state = state; | t->state = state; | ||||
| t->mode = mode; | t->mode = mode; | ||||
| t->size = size; | t->size = size; | ||||
| t->mtime = mtime; | t->mtime = mtime; | ||||
| return (PyObject *)t; | return (PyObject *)t; | ||||
| }; | }; | ||||
| /* This means the next status call will have to actually check its content | |||||
| to make sure it is correct. */ | |||||
| static PyObject *dirstate_item_set_possibly_dirty(dirstateItemObject *self) | |||||
| { | |||||
| self->mtime = ambiguous_time; | |||||
| Py_RETURN_NONE; | |||||
| } | |||||
| static PyMethodDef dirstate_item_methods[] = { | static PyMethodDef dirstate_item_methods[] = { | ||||
| {"v1_state", (PyCFunction)dirstate_item_v1_state, METH_NOARGS, | {"v1_state", (PyCFunction)dirstate_item_v1_state, METH_NOARGS, | ||||
| "return a \"state\" suitable for v1 serialization"}, | "return a \"state\" suitable for v1 serialization"}, | ||||
| {"v1_mode", (PyCFunction)dirstate_item_v1_mode, METH_NOARGS, | {"v1_mode", (PyCFunction)dirstate_item_v1_mode, METH_NOARGS, | ||||
| "return a \"mode\" suitable for v1 serialization"}, | "return a \"mode\" suitable for v1 serialization"}, | ||||
| {"v1_size", (PyCFunction)dirstate_item_v1_size, METH_NOARGS, | {"v1_size", (PyCFunction)dirstate_item_v1_size, METH_NOARGS, | ||||
| "return a \"size\" suitable for v1 serialization"}, | "return a \"size\" suitable for v1 serialization"}, | ||||
| {"v1_mtime", (PyCFunction)dirstate_item_v1_mtime, METH_NOARGS, | {"v1_mtime", (PyCFunction)dirstate_item_v1_mtime, METH_NOARGS, | ||||
| "return a \"mtime\" suitable for v1 serialization"}, | "return a \"mtime\" suitable for v1 serialization"}, | ||||
| {"need_delay", (PyCFunction)dirstate_item_need_delay, METH_O, | {"need_delay", (PyCFunction)dirstate_item_need_delay, METH_O, | ||||
| "True if the stored mtime would be ambiguous with the current time"}, | "True if the stored mtime would be ambiguous with the current time"}, | ||||
| {"from_v1_data", (PyCFunction)dirstate_item_from_v1_meth, METH_O, | {"from_v1_data", (PyCFunction)dirstate_item_from_v1_meth, METH_O, | ||||
| "build a new DirstateItem object from V1 data"}, | "build a new DirstateItem object from V1 data"}, | ||||
| {"set_possibly_dirty", (PyCFunction)dirstate_item_set_possibly_dirty, | |||||
| METH_NOARGS, "mark a file as \"possibly dirty\""}, | |||||
| {NULL} /* Sentinel */ | {NULL} /* Sentinel */ | ||||
| }; | }; | ||||
| static PyObject *dirstate_item_get_mode(dirstateItemObject *self) | static PyObject *dirstate_item_get_mode(dirstateItemObject *self) | ||||
| { | { | ||||
| return PyInt_FromLong(self->mode); | return PyInt_FromLong(self->mode); | ||||
| }; | }; | ||||
| """ | """ | ||||
| return cls( | return cls( | ||||
| state=state, | state=state, | ||||
| mode=mode, | mode=mode, | ||||
| size=size, | size=size, | ||||
| mtime=mtime, | mtime=mtime, | ||||
| ) | ) | ||||
| def set_possibly_dirty(self): | |||||
| """Mark a file as "possibly dirty" | |||||
| This means the next status call will have to actually check its content | |||||
| to make sure it is correct. | |||||
| """ | |||||
| self._mtime = AMBIGUOUS_TIME | |||||
| def __getitem__(self, idx): | def __getitem__(self, idx): | ||||
| if idx == 0 or idx == -4: | if idx == 0 or idx == -4: | ||||
| msg = b"do not use item[x], use item.state" | msg = b"do not use item[x], use item.state" | ||||
| util.nouideprecwarn(msg, b'6.0', stacklevel=2) | util.nouideprecwarn(msg, b'6.0', stacklevel=2) | ||||
| return self._state | return self._state | ||||
| elif idx == 1 or idx == -3: | elif idx == 1 or idx == -3: | ||||
| msg = b"do not use item[x], use item.mode" | msg = b"do not use item[x], use item.mode" | ||||
| util.nouideprecwarn(msg, b'6.0', stacklevel=2) | util.nouideprecwarn(msg, b'6.0', stacklevel=2) | ||||