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
--- a/mercurial/cext/parsers.c Wed Nov 17 02:58:44 2021 +0100
+++ b/mercurial/cext/parsers.c Wed Nov 17 10:26:48 2021 +0100
@@ -66,6 +66,7 @@
int mtime_s;
int mtime_ns;
PyObject *parentfiledata;
+ PyObject *mtime;
PyObject *fallback_exec;
PyObject *fallback_symlink;
static char *keywords_name[] = {
@@ -118,10 +119,18 @@
}
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 @@
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;
--- a/mercurial/dirstate.py Wed Nov 17 02:58:44 2021 +0100
+++ b/mercurial/dirstate.py Wed Nov 17 10:26:48 2021 +0100
@@ -611,6 +611,7 @@
)
if (
parentfiledata is not None
+ and parentfiledata[2] is not None
and parentfiledata[2] > self._lastnormaltime
):
# Remember the most recent modification timeslot for status(),
--- a/mercurial/pure/parsers.py Wed Nov 17 02:58:44 2021 +0100
+++ b/mercurial/pure/parsers.py Wed Nov 17 10:26:48 2021 +0100
@@ -130,6 +130,8 @@
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]
--- a/rust/hg-cpython/src/dirstate/item.rs Wed Nov 17 02:58:44 2021 +0100
+++ b/rust/hg-cpython/src/dirstate/item.rs Wed Nov 17 10:26:48 2021 +0100
@@ -23,7 +23,7 @@
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 @@
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(