nodemap: add a optional `nodemap_add_full` method on indexes
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 15 Jan 2020 15:48:19 +0100
changeset 44357 7f4f7ef3133e
parent 44356 6f9e8e142cea
child 44358 7762a295fd4d
nodemap: add a optional `nodemap_add_full` method on indexes This method can be used to obtains persistent data for a full nodemap. The end goal is for some index implementation to managed the nodemap serialization them selves (eg: the rust implementation) Differential Revision: https://phab.mercurial-scm.org/D7841
mercurial/pure/parsers.py
mercurial/revlogutils/nodemap.py
--- a/mercurial/pure/parsers.py	Wed Jan 15 15:48:09 2020 +0100
+++ b/mercurial/pure/parsers.py	Wed Jan 15 15:48:19 2020 +0100
@@ -149,6 +149,13 @@
     through the dedicated `devel.persistent-nodemap` config.
     """
 
+    def nodemap_data_all(self):
+        """Return bytes containing a full serialization of a nodemap
+
+        The nodemap should be valid for the full set of revisions in the
+        index."""
+        return nodemaputil.persistent_data(self)
+
 
 class InlinedIndexObject(BaseIndexObject):
     def __init__(self, data, inline=0):
--- a/mercurial/revlogutils/nodemap.py	Wed Jan 15 15:48:09 2020 +0100
+++ b/mercurial/revlogutils/nodemap.py	Wed Jan 15 15:48:19 2020 +0100
@@ -15,7 +15,7 @@
 from .. import (
     error,
     node as nodemod,
-    pycompat,
+    util,
 )
 
 
@@ -69,7 +69,10 @@
     if revlog.nodemap_file is None:
         msg = "calling persist nodemap on a revlog without the feature enableb"
         raise error.ProgrammingError(msg)
-    data = persistent_data(revlog.index)
+    if util.safehasattr(revlog.index, "nodemap_data_all"):
+        data = revlog.index.nodemap_data_all()
+    else:
+        data = persistent_data(revlog.index)
     uid = _make_uid()
     datafile = _rawdata_filepath(revlog, uid)
     olds = _other_rawdata_filepath(revlog, uid)