Patchwork D10981: dirstate-entry: add a `mtime` property

login
register
mail settings
Submitter phabricator
Date July 4, 2021, 9:55 p.m.
Message ID <differential-rev-PHID-DREV-ozpe4bbciveb3dzlzdkp-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49294/
State Superseded
Headers show

Comments

phabricator - July 4, 2021, 9:55 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is clearer than "tuple" indexing.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10981

AFFECTED FILES
  mercurial/cext/parsers.c
  mercurial/dirstate.py
  mercurial/pure/parsers.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -80,6 +80,10 @@ 
         return self._size
 
     @property
+    def mtime(self):
+        return self._mtime
+
+    @property
     def state(self):
         """
         States are:
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -1310,7 +1310,7 @@ 
             t = dget(fn)
             mode = t.mode
             size = t.size
-            time = t[3]
+            time = t.mtime
 
             if not st and t.tracked:
                 dadd(fn)
diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -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},