diff mercurial/changelog.py @ 47239:682f09857d69

revlogv2: delay the update of the changelog docket to transaction end This prevent external reader to see the transaction content before it is commited. However this also prevent the hooks to see the transaction content. We will fix this in later changesets. We have to temporarily suppress the error output of the command ran during the transaction as they sometimes get confused about unknown working directory and sometimes issue message on std-err in unspecified order. Differential Revision: https://phab.mercurial-scm.org/D10629
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 03 May 2021 12:35:02 +0200
parents 616b8f412676
children 4f38ada3fc26
line wrap: on
line diff
--- a/mercurial/changelog.py	Mon May 03 12:34:52 2021 +0200
+++ b/mercurial/changelog.py	Mon May 03 12:35:02 2021 +0200
@@ -443,12 +443,13 @@
         self._filteredrevs = val
         self._filteredrevs_hashcache = {}
 
+    def _write_docket(self, tr):
+        if not self._delayed:
+            super(changelog, self)._write_docket(tr)
+
     def delayupdate(self, tr):
         """delay visibility of index updates to other readers"""
-        if self._docket is not None:
-            return
-
-        if not self._delayed:
+        if self._docket is None and not self._delayed:
             if len(self) == 0:
                 self._divert = True
                 if self._realopener.exists(self._indexfile + b'.a'):
@@ -468,7 +469,9 @@
         self._delayed = False
         self.opener = self._realopener
         # move redirected index data back into place
-        if self._divert:
+        if self._docket is not None:
+            self._write_docket(tr)
+        elif self._divert:
             assert not self._delaybuf
             tmpname = self._indexfile + b".a"
             nfile = self.opener.open(tmpname)