diff mercurial/dirstate.py @ 44826:35b255e474d9 stable

dirstate: make sure the dirstate is loaded before the changelog (issue6303) Before this change, it was possible for the changelog to be loaded before the dirstate. If a transaction happens betwen the changelog and dirstate reading, the dirstate can up end poitning toward a revision not existing in the (olded) changelog. This lead to a warning. With this revision, we preload the dirstate parent before reading the changelog. This has a negligible performance impact on performance for all case we are tracking. Differential Revision: https://phab.mercurial-scm.org/D8528
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 11 May 2020 13:08:02 +0200
parents 18e36ff8b414
children fd3b94f1712d
line wrap: on
line diff
--- a/mercurial/dirstate.py	Mon May 11 16:44:11 2020 +0200
+++ b/mercurial/dirstate.py	Mon May 11 13:08:02 2020 +0200
@@ -103,6 +103,13 @@
         # raises an exception).
         self._cwd
 
+    def prefetch_parents(self):
+        """make sure the parents are loaded
+
+        Used to avoid a race condition.
+        """
+        self._pl
+
     @contextlib.contextmanager
     def parentchange(self):
         '''Context manager for handling dirstate parents.