[Updated] D8528: dirstate: make sure the dirstate is loaded before the changelog (issue6303)

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Fri May 15 19:30:33 UTC 2020


Closed by commit rHG35b255e474d9: dirstate: make sure the dirstate is loaded before the changelog (issue6303) (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8528?vs=21390&id=21392

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8528/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8528

AFFECTED FILES
  mercurial/dirstate.py
  mercurial/localrepo.py
  tests/test-static-http.t

CHANGE DETAILS

diff --git a/tests/test-static-http.t b/tests/test-static-http.t
--- a/tests/test-static-http.t
+++ b/tests/test-static-http.t
@@ -233,6 +233,7 @@
   /.hg/cache/hgtagsfnodes1
   /.hg/cache/rbc-names-v1
   /.hg/cache/rbc-revs-v1
+  /.hg/dirstate
   /.hg/requires
   /.hg/store/00changelog.i
   /.hg/store/00manifest.i
@@ -250,6 +251,7 @@
   /remote-with-names/.hg/cache/rbc-names-v1
   /remote-with-names/.hg/cache/rbc-revs-v1
   /remote-with-names/.hg/cache/tags2-served
+  /remote-with-names/.hg/dirstate
   /remote-with-names/.hg/localtags
   /remote-with-names/.hg/requires
   /remote-with-names/.hg/store/00changelog.i
@@ -266,6 +268,7 @@
   /remote/.hg/cache/rbc-names-v1
   /remote/.hg/cache/rbc-revs-v1
   /remote/.hg/cache/tags2-served
+  /remote/.hg/dirstate
   /remote/.hg/localtags
   /remote/.hg/requires
   /remote/.hg/store/00changelog.i
@@ -278,6 +281,7 @@
   /remote/.hg/store/data/~2ehgtags.i (py37 !)
   /remotempty/.hg/bookmarks
   /remotempty/.hg/bookmarks.current
+  /remotempty/.hg/dirstate
   /remotempty/.hg/requires
   /remotempty/.hg/store/00changelog.i
   /remotempty/.hg/store/00manifest.i
@@ -286,6 +290,7 @@
   /sub/.hg/cache/hgtagsfnodes1
   /sub/.hg/cache/rbc-names-v1
   /sub/.hg/cache/rbc-revs-v1
+  /sub/.hg/dirstate
   /sub/.hg/requires
   /sub/.hg/store/00changelog.i
   /sub/.hg/store/00manifest.i
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1450,6 +1450,8 @@
 
     @storecache(b'00changelog.i')
     def changelog(self):
+        # load dirstate before changelog to avoid race see issue6303
+        self.dirstate.prefetch_parents()
         return self.store.changelog(txnutil.mayhavepending(self.root))
 
     @storecache(b'00manifest.i')
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -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.



To: marmoute, #hg-reviewers
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200515/106d3e4c/attachment-0002.html>


More information about the Mercurial-patches mailing list