Patchwork D7885: nodemap: keep track of the docket for loaded data

login
register
mail settings
Submitter phabricator
Date Jan. 31, 2020, 11:02 p.m.
Message ID <bcc47e51d9c32166175f6c38ee1b99e5@localhost.localdomain>
Download mbox | patch
Permalink /patch/44843/
State Not Applicable
Headers show

Comments

phabricator - Jan. 31, 2020, 11:02 p.m.
marmoute updated this revision to Diff 19794.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7885?vs=19766&id=19794

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7885/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7885

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/revlog.py
  mercurial/revlogutils/nodemap.py

CHANGE DETAILS




To: marmoute, indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -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.
 
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -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
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2112,13 +2112,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(