Commit 76a96e3a2bb by Pierre-Yves David

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
parent 72c15641c8b
......@@ -2113,13 +2113,17 @@ def debugnodemap(ui, repo, **opts):
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(
......
......@@ -455,6 +455,7 @@ class revlog(object):
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 @@ class revlog(object):
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 @@ class revlog(object):
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
......
......@@ -41,7 +41,7 @@ def persisted_data(revlog):
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 @@ def _persist_nodemap(tr, revlog):
# 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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment