# HG changeset patch # User Pierre-Yves David # Date 2020-01-15 14:48:19 # Node ID 7f4f7ef3133e994be4cf1b4329185998be3d5ec1 # Parent 6f9e8e142cea259aa3e74b69f763b67930ce38c6 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 diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py --- a/mercurial/pure/parsers.py +++ b/mercurial/pure/parsers.py @@ -149,6 +149,13 @@ class PersistentNodeMapIndexObject(Index 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): diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py --- a/mercurial/revlogutils/nodemap.py +++ b/mercurial/revlogutils/nodemap.py @@ -15,7 +15,7 @@ import struct from .. import ( error, node as nodemod, - pycompat, + util, ) @@ -69,7 +69,10 @@ def _persist_nodemap(tr, revlog): 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)