Mercurial > hg
changeset 44320:671f9479af0e
nodemap: provide the on disk data to indexes who support it
Time to start defining the API and prepare the rust index support. We provide
a method to do so. We use a distinct method instead of passing them in the
constructor because we will need this method anyway later (to refresh the mmap
once we update the data on disk).
Differential Revision: https://phab.mercurial-scm.org/D7847
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 15 Jan 2020 15:49:16 +0100 |
parents | d58206b70199 |
children | f0862ee1a31e |
files | mercurial/pure/parsers.py mercurial/revlog.py |
diffstat | 2 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/pure/parsers.py Wed Jan 15 15:49:06 2020 +0100 +++ b/mercurial/pure/parsers.py Wed Jan 15 15:49:16 2020 +0100 @@ -156,6 +156,14 @@ index.""" return nodemaputil.persistent_data(self) + def update_nodemap_data(self, nm_data): + """provide full blokc of persisted binary data for a nodemap + + The data are expected to come from disk. See `nodemap_data_all` for a + produceur of such data.""" + if nm_data is not None: + nodemaputil.parse_data(nm_data) + class InlinedIndexObject(BaseIndexObject): def __init__(self, data, inline=0):
--- a/mercurial/revlog.py Wed Jan 15 15:49:06 2020 +0100 +++ b/mercurial/revlog.py Wed Jan 15 15:49:16 2020 +0100 @@ -626,6 +626,16 @@ self._io = rustrevlogio() try: d = self._io.parseindex(indexdata, self._inline) + index, _chunkcache = d + use_nodemap = ( + not self._inline + and self.nodemap_file is not None + and util.safehasattr(index, 'update_nodemap_data') + ) + if use_nodemap: + nodemap_data = nodemaputil.persisted_data(self) + if nodemap_data is not None: + index.update_nodemap_data(nodemap_data) except (ValueError, IndexError): raise error.RevlogError( _(b"index %s is corrupted") % self.indexfile