Mercurial > public > mercurial-scm > hg-stable
diff mercurial/dirstatemap.py @ 49703:dbe09fb038fc stable
rhg: remember the inode of .hg/dirstate
This allows us to detect changes of `.hg/dirstate`, which is either the
full dirstate (in dirstate-v1) or the docket file (v2) without relying on
data inside the file. It only works on UNIX systems.
This fixes a race condition for dirstate-v1 (as demonstrated by
the test changes) and adds a confortable layer of sanity for dirstate-v2.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Wed, 01 Mar 2023 16:48:09 +0100 |
parents | 6cce0afc1454 |
children | a6b8b1ab9116 |
line wrap: on
line diff
--- a/mercurial/dirstatemap.py Tue Feb 28 17:58:15 2023 +0100 +++ b/mercurial/dirstatemap.py Wed Mar 01 16:48:09 2023 +0100 @@ -570,6 +570,12 @@ testing.wait_on_cfg(self._ui, b'dirstate.pre-read-file') if self._use_dirstate_v2: self.docket # load the data if needed + inode = ( + self.identity.stat.st_ino + if self.identity is not None + and self.identity.stat is not None + else None + ) testing.wait_on_cfg(self._ui, b'dirstate.post-docket-read-file') if not self.docket.uuid: data = b'' @@ -581,12 +587,19 @@ self.docket.data_size, self.docket.tree_metadata, self.docket.uuid, + inode, ) parents = self.docket.parents else: self._set_identity() + inode = ( + self.identity.stat.st_ino + if self.identity is not None + and self.identity.stat is not None + else None + ) self._map, parents = rustmod.DirstateMap.new_v1( - self._readdirstatefile() + self._readdirstatefile(), inode ) if parents and not self._dirtyparents: