changeset 50241:342c3c4640b7 stable

dirstate: factor the identity setting code in the dirstate map We need it in more locations, so let us start factoring thing out first to make sure the same code is called everywhere. This bears some similarity with 85746485a4dd on default, but at a smaller scope and for a different purpose.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 21 Feb 2023 15:10:12 +0100
parents 3ddff85fa2c8
children 379a78001d8e
files mercurial/dirstatemap.py
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstatemap.py	Wed Mar 01 00:07:26 2023 +0100
+++ b/mercurial/dirstatemap.py	Tue Feb 21 15:10:12 2023 +0100
@@ -76,6 +76,11 @@
         # for consistent view between _pl() and _read() invocations
         self._pendingmode = None
 
+    def _set_identity(self):
+        # ignore HG_PENDING because identity is used only for writing
+        file_path = self._opener.join(self._filename)
+        self.identity = util.filestat.frompath(file_path)
+
     def preload(self):
         """Loads the underlying data, if it's not already loaded"""
         self._map
@@ -295,9 +300,7 @@
 
     def read(self):
         # ignore HG_PENDING because identity is used only for writing
-        self.identity = util.filestat.frompath(
-            self._opener.join(self._filename)
-        )
+        self._set_identity()
 
         testing.wait_on_cfg(self._ui, b'dirstate.pre-read-file')
         if self._use_dirstate_v2:
@@ -563,9 +566,7 @@
             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)
-            )
+            self._set_identity()
 
             testing.wait_on_cfg(self._ui, b'dirstate.pre-read-file')
             if self._use_dirstate_v2: