D7710: revlog: split the content verification of a node into a separate method

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Mon Dec 23 07:48:07 UTC 2019


mharbison72 created this revision.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This will be used by LFS to tune what is skipped.
  
  In the future, this could also be used by LFS to indicate which nodes tagged
  with `skipread` are simply in need of a blob fetch, so that they can be done in
  a batch later.  (Currently, `skipread` also indicates censored data and errors.)
  Additionally, it could be used to cache the sha1 hash value for each blob so
  that large blobs don't need to be re-read and re-hashed if they are used by
  multiple nodes.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -148,6 +148,16 @@
     return int(int(offset) << 16 | type)
 
 
+def _verify_revision(rl, skipflags, state, node):
+    """Verify the integrity of the given revlog ``node`` while providing a hook
+    point for extensions to influence the operation."""
+    if skipflags:
+        state[b'skipread'].add(node)
+    else:
+        # Side-effect: read content and verify hash.
+        rl.revision(node)
+
+
 @attr.s(slots=True, frozen=True)
 class _revisioninfo(object):
     """Information about a revision that allows building its fulltext
@@ -2914,11 +2924,7 @@
                 if skipflags:
                     skipflags &= self.flags(rev)
 
-                if skipflags:
-                    state[b'skipread'].add(node)
-                else:
-                    # Side-effect: read content and verify hash.
-                    self.revision(node)
+                _verify_revision(self, skipflags, state, node)
 
                 l1 = self.rawsize(rev)
                 l2 = len(self.rawdata(node))



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


More information about the Mercurial-devel mailing list