Read about our upcoming Code of Conduct on this issue

This instance was upgraded to Heptapod 0.28.0 today

Commit 82e2c5f6 authored by Pierre-Yves David's avatar Pierre-Yves David 🐙
Browse files

dirstate-item: allow mtime to be None in "parentdata"

This will be useful to filter out unreliable mtime.

Differential Revision: https://phab.mercurial-scm.org/D11782
parent c655483ea6e2
......@@ -66,6 +66,7 @@ static PyObject *dirstate_item_new(PyTypeObject *subtype, PyObject *args,
int mtime_s;
int mtime_ns;
PyObject *parentfiledata;
PyObject *mtime;
PyObject *fallback_exec;
PyObject *fallback_symlink;
static char *keywords_name[] = {
......@@ -118,10 +119,18 @@ static PyObject *dirstate_item_new(PyTypeObject *subtype, PyObject *args,
}
if (parentfiledata != Py_None) {
if (!PyArg_ParseTuple(parentfiledata, "ii(ii)", &mode, &size,
&mtime_s, &mtime_ns)) {
if (!PyArg_ParseTuple(parentfiledata, "iiO", &mode, &size,
&mtime)) {
return NULL;
}
if (mtime != Py_None) {
if (!PyArg_ParseTuple(mtime, "ii", &mtime_s,
&mtime_ns)) {
return NULL;
}
} else {
has_meaningful_mtime = 0;
}
} else {
has_meaningful_data = 0;
has_meaningful_mtime = 0;
......@@ -475,10 +484,19 @@ static PyObject *dirstate_item_set_clean(dirstateItemObject *self,
PyObject *args)
{
int size, mode, mtime_s, mtime_ns;
if (!PyArg_ParseTuple(args, "ii(ii)", &mode, &size, &mtime_s,
&mtime_ns)) {
PyObject *mtime;
mtime_s = 0;
mtime_ns = 0;
if (!PyArg_ParseTuple(args, "iiO", &mode, &size, &mtime)) {
return NULL;
}
if (mtime != Py_None) {
if (!PyArg_ParseTuple(mtime, "ii", &mtime_s, &mtime_ns)) {
return NULL;
}
} else {
self->flags &= ~dirstate_flag_has_mtime;
}
self->flags = dirstate_flag_wc_tracked | dirstate_flag_p1_tracked |
dirstate_flag_has_meaningful_data |
dirstate_flag_has_mtime;
......
......@@ -611,6 +611,7 @@ class dirstate(object):
)
if (
parentfiledata is not None
and parentfiledata[2] is not None
and parentfiledata[2] > self._lastnormaltime
):
# Remember the most recent modification timeslot for status(),
......
......@@ -130,6 +130,8 @@ class DirstateItem(object):
if parentfiledata is None:
has_meaningful_mtime = False
has_meaningful_data = False
elif parentfiledata[2] is None:
has_meaningful_mtime = False
if has_meaningful_data:
self._mode = parentfiledata[0]
self._size = parentfiledata[1]
......
......@@ -23,7 +23,7 @@ py_class!(pub class DirstateItem |py| {
p2_info: bool = false,
has_meaningful_data: bool = true,
has_meaningful_mtime: bool = true,
parentfiledata: Option<(u32, u32, (u32, u32))> = None,
parentfiledata: Option<(u32, u32, Option<(u32, u32)>)> = None,
fallback_exec: Option<bool> = None,
fallback_symlink: Option<bool> = None,
......@@ -35,7 +35,9 @@ py_class!(pub class DirstateItem |py| {
mode_size_opt = Some((mode, size))
}
if has_meaningful_mtime {
mtime_opt = Some(timestamp(py, mtime)?)
if let Some(m) = mtime {
mtime_opt = Some(timestamp(py, m)?);
}
}
}
let entry = DirstateEntry::from_v2_data(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment