changeset 44366:76a96e3a2bbb

nodemap: keep track of the docket for loaded data To perform incremental update of the on disk data, we need to keep tracks of some aspect of that data. Differential Revision: https://phab.mercurial-scm.org/D7885
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 15 Jan 2020 15:49:45 +0100
parents 72c15641c8b4
children 50ad851efd9b
files mercurial/debugcommands.py mercurial/revlog.py mercurial/revlogutils/nodemap.py
diffstat 3 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Wed Jan 15 15:49:35 2020 +0100
+++ b/mercurial/debugcommands.py	Wed Jan 15 15:49:45 2020 +0100
@@ -2113,13 +2113,17 @@
     elif opts['dump_disk']:
         unfi = repo.unfiltered()
         cl = unfi.changelog
-        data = nodemap.persisted_data(cl)
-        ui.write(data)
+        nm_data = nodemap.persisted_data(cl)
+        if nm_data is not None:
+            docket, data = nm_data
+            ui.write(data)
     elif opts['check']:
         unfi = repo.unfiltered()
         cl = unfi.changelog
-        data = nodemap.persisted_data(cl)
-        return nodemap.check_data(ui, cl.index, data)
+        nm_data = nodemap.persisted_data(cl)
+        if nm_data is not None:
+            docket, data = nm_data
+            return nodemap.check_data(ui, cl.index, data)
 
 
 @command(
--- a/mercurial/revlog.py	Wed Jan 15 15:49:35 2020 +0100
+++ b/mercurial/revlog.py	Wed Jan 15 15:49:45 2020 +0100
@@ -455,6 +455,7 @@
         self._maxchainlen = None
         self._deltabothparents = True
         self.index = None
+        self._nodemap_docket = None
         # Mapping of partial identifiers to full nodes.
         self._pcache = {}
         # Mapping of revision integer to full node.
@@ -544,6 +545,9 @@
         indexdata = b''
         self._initempty = True
         try:
+            nodemap_data = nodemaputil.persisted_data(self)
+            if nodemap_data is not None:
+                self._nodemap_docket = nodemap_data[0]
             with self._indexfp() as f:
                 if (
                     mmapindexthreshold is not None
@@ -635,7 +639,7 @@
             if use_nodemap:
                 nodemap_data = nodemaputil.persisted_data(self)
                 if nodemap_data is not None:
-                    index.update_nodemap_data(nodemap_data)
+                    index.update_nodemap_data(nodemap_data[1])
         except (ValueError, IndexError):
             raise error.RevlogError(
                 _(b"index %s is corrupted") % self.indexfile
--- a/mercurial/revlogutils/nodemap.py	Wed Jan 15 15:49:35 2020 +0100
+++ b/mercurial/revlogutils/nodemap.py	Wed Jan 15 15:49:45 2020 +0100
@@ -41,7 +41,7 @@
     docket = NodeMapDocket(pdata[offset : offset + uid_size])
 
     filename = _rawdata_filepath(revlog, docket)
-    return revlog.opener.tryread(filename)
+    return docket, revlog.opener.tryread(filename)
 
 
 def setup_persistent_nodemap(tr, revlog):
@@ -93,6 +93,7 @@
     # store vfs
     with revlog.opener(revlog.nodemap_file, b'w', atomictemp=True) as fp:
         fp.write(target_docket.serialize())
+    revlog._nodemap_docket = target_docket
     # EXP-TODO: if the transaction abort, we should remove the new data and
     # reinstall the old one.