dirstate: use `cachestat` object for dirstatemap identity
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 22 Feb 2023 00:53:51 +0100
changeset 50125 eedbf8256263
parent 50124 18149ecb5122
child 50126 85746485a4dd
dirstate: use `cachestat` object for dirstatemap identity There is a class dedicated to this kind of cache check, let us use it. We will generalize this code in the next changesets, but we do the "behavior changing" pass on our own.
mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py	Tue Feb 21 22:17:33 2023 +0100
+++ b/mercurial/dirstatemap.py	Wed Feb 22 00:53:51 2023 +0100
@@ -263,9 +263,10 @@
 
     def read(self):
         # ignore HG_PENDING because identity is used only for writing
-        self.identity = util.filestat.frompath(
-            self._opener.join(self._filename)
-        )
+        try:
+            self.identity = util.cachestat(self._opener.join(self._filename))
+        except FileNotFoundError:
+            self.identity = None
 
         if self._use_dirstate_v2:
             if not self.docket.uuid:
@@ -528,9 +529,12 @@
             Fills the Dirstatemap when called.
             """
             # ignore HG_PENDING because identity is used only for writing
-            self.identity = util.filestat.frompath(
-                self._opener.join(self._filename)
-            )
+            try:
+                self.identity = util.cachestat(
+                    self._opener.join(self._filename)
+                )
+            except FileNotFoundError:
+                self.identity = None
 
             if self._use_dirstate_v2:
                 if self.docket.uuid: