Mercurial > hg-stable
changeset 50175:85746485a4dd
dirstate: factor the identity getting/setting code in the dirstate map
We are doing the same things twice and we will add more logic in the next
changesets. So lets start factoring things out now.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 21 Feb 2023 15:10:12 +0100 |
parents | eedbf8256263 |
children | ec769cbc1fa2 |
files | mercurial/dirstatemap.py |
diffstat | 1 files changed, 11 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dirstatemap.py Wed Feb 22 00:53:51 2023 +0100 +++ b/mercurial/dirstatemap.py Tue Feb 21 15:10:12 2023 +0100 @@ -58,6 +58,15 @@ # for consistent view between _pl() and _read() invocations self._pendingmode = None + def _set_identity(self): + self.identity = self._get_current_identity() + + def _get_current_identity(self): + try: + return util.cachestat(self._opener.join(self._filename)) + except FileNotFoundError: + return None + def preload(self): """Loads the underlying data, if it's not already loaded""" self._map @@ -263,10 +272,7 @@ def read(self): # ignore HG_PENDING because identity is used only for writing - try: - self.identity = util.cachestat(self._opener.join(self._filename)) - except FileNotFoundError: - self.identity = None + self._set_identity() if self._use_dirstate_v2: if not self.docket.uuid: @@ -529,12 +535,7 @@ Fills the Dirstatemap when called. """ # ignore HG_PENDING because identity is used only for writing - try: - self.identity = util.cachestat( - self._opener.join(self._filename) - ) - except FileNotFoundError: - self.identity = None + self._set_identity() if self._use_dirstate_v2: if self.docket.uuid: