changeset 44340:6ecc34b31137

nodemap: update the index with the newly written data (when appropriate) If we are to use mmap to read the nodemap data, and if the python code is responsible for the IO, we need to refresh the mmap after each write and provide it back to the index. We start this dance without the mmap first. Differential Revision: https://phab.mercurial-scm.org/D7893
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 15 Jan 2020 15:51:01 +0100
parents c7eebdb15139
children 77bb38be00ea
files mercurial/revlogutils/nodemap.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlogutils/nodemap.py	Wed Jan 15 15:50:52 2020 +0100
+++ b/mercurial/revlogutils/nodemap.py	Wed Jan 15 15:51:01 2020 +0100
@@ -100,6 +100,8 @@
             with revlog.opener(datafile, b'r+') as fd:
                 fd.seek(target_docket.data_length)
                 fd.write(data)
+                fd.seek(0)
+                new_data = fd.read(target_docket.data_length + len(data))
             target_docket.data_length += len(data)
             target_docket.data_unused += data_changed_count
 
@@ -113,6 +115,7 @@
             data = persistent_data(revlog.index)
         # EXP-TODO: if this is a cache, this should use a cache vfs, not a
         # store vfs
+        new_data = data
         with revlog.opener(datafile, b'w') as fd:
             fd.write(data)
         target_docket.data_length = len(data)
@@ -122,6 +125,9 @@
     with revlog.opener(revlog.nodemap_file, b'w', atomictemp=True) as fp:
         fp.write(target_docket.serialize())
     revlog._nodemap_docket = target_docket
+    if util.safehasattr(revlog.index, "update_nodemap_data"):
+        revlog.index.update_nodemap_data(target_docket, new_data)
+
     # EXP-TODO: if the transaction abort, we should remove the new data and
     # reinstall the old one.