changeset 47538:77fce401a2bb

dirstate-entry: add a `mtime` property This is clearer than "tuple" indexing. Differential Revision: https://phab.mercurial-scm.org/D10981
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 04 Jul 2021 02:37:38 +0200
parents 0e5800c88eb4
children 84391ddf4c78
files mercurial/cext/parsers.c mercurial/dirstate.py mercurial/pure/parsers.py
diffstat 3 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cext/parsers.c	Sun Jul 04 02:34:24 2021 +0200
+++ b/mercurial/cext/parsers.c	Sun Jul 04 02:37:38 2021 +0200
@@ -179,6 +179,11 @@
 	return PyInt_FromLong(self->size);
 };
 
+static PyObject *dirstatetuple_get_mtime(dirstateTupleObject *self)
+{
+	return PyInt_FromLong(self->mtime);
+};
+
 static PyObject *dirstatetuple_get_state(dirstateTupleObject *self)
 {
 	return PyBytes_FromStringAndSize(&self->state, 1);
@@ -250,6 +255,7 @@
 static PyGetSetDef dirstatetuple_getset[] = {
     {"mode", (getter)dirstatetuple_get_mode, NULL, "mode", NULL},
     {"size", (getter)dirstatetuple_get_size, NULL, "size", NULL},
+    {"mtime", (getter)dirstatetuple_get_mtime, NULL, "mtime", NULL},
     {"state", (getter)dirstatetuple_get_state, NULL, "state", NULL},
     {"tracked", (getter)dirstatetuple_get_tracked, NULL, "tracked", NULL},
     {"added", (getter)dirstatetuple_get_added, NULL, "added", NULL},
--- a/mercurial/dirstate.py	Sun Jul 04 02:34:24 2021 +0200
+++ b/mercurial/dirstate.py	Sun Jul 04 02:37:38 2021 +0200
@@ -1309,7 +1309,7 @@
             t = dget(fn)
             mode = t.mode
             size = t.size
-            time = t[3]
+            time = t.mtime
 
             if not st and t.tracked:
                 dadd(fn)
--- a/mercurial/pure/parsers.py	Sun Jul 04 02:34:24 2021 +0200
+++ b/mercurial/pure/parsers.py	Sun Jul 04 02:37:38 2021 +0200
@@ -80,6 +80,10 @@
         return self._size
 
     @property
+    def mtime(self):
+        return self._mtime
+
+    @property
     def state(self):
         """
         States are: