# HG changeset patch # User Pierre-Yves David # Date 1676988612 -3600 # Node ID 342c3c4640b787794ae9e68a6323d42483a59a07 # Parent 3ddff85fa2c81553d7182669d0cd272fb1c84133 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. diff -r 3ddff85fa2c8 -r 342c3c4640b7 mercurial/dirstatemap.py --- 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: