lfs: don't skip locally available blobs when verifying
authorMatt Harbison <matt_harbison@yahoo.com>
Sun, 22 Dec 2019 23:50:19 -0500
changeset 44072 1a6dd50cd0db
parent 44071 34e8305f02bd
child 44073 b9e174d4ed11
lfs: don't skip locally available blobs when verifying The `skipflags` config was introduced in a2ab9ebcd85b, which specifically calls out downloading and storing all blobs as potentially too expensive. But I don't see any reason to skip blobs that are already available locally. Hashing the blob is the only way to indirectly verify the rawdata content stored in the revlog. (The note in that commit about skipping renamed is still correct, but the reason given about needing fulltext isn't.) Differential Revision: https://phab.mercurial-scm.org/D7712
hgext/lfs/__init__.py
hgext/lfs/wrapper.py
tests/test-lfs.t
--- a/hgext/lfs/__init__.py	Fri Dec 20 01:11:35 2019 -0500
+++ b/hgext/lfs/__init__.py	Sun Dec 22 23:50:19 2019 -0500
@@ -405,7 +405,8 @@
 
 
 @eh.wrapcommand(
-    b'verify', opts=[(b'', b'no-lfs', None, _(b'skip all lfs blob content'))]
+    b'verify',
+    opts=[(b'', b'no-lfs', None, _(b'skip missing lfs blob content'))],
 )
 def verify(orig, ui, repo, **opts):
     skipflags = repo.ui.configint(b'verify', b'skipflags')
--- a/hgext/lfs/wrapper.py	Fri Dec 20 01:11:35 2019 -0500
+++ b/hgext/lfs/wrapper.py	Sun Dec 22 23:50:19 2019 -0500
@@ -225,6 +225,21 @@
     return orig(self, rev)
 
 
+@eh.wrapfunction(revlog, b'_verify_revision')
+def _verify_revision(orig, rl, skipflags, state, node):
+    if _islfs(rl, node=node):
+        rawtext = rl.rawdata(node)
+        metadata = pointer.deserialize(rawtext)
+
+        # Don't skip blobs that are stored locally, as local verification is
+        # relatively cheap and there's no other way to verify the raw data in
+        # the revlog.
+        if rl.opener.lfslocalblobstore.has(metadata.oid()):
+            skipflags &= ~revlog.REVIDX_EXTSTORED
+
+    orig(rl, skipflags, state, node)
+
+
 @eh.wrapfunction(context.basefilectx, b'cmp')
 def filectxcmp(orig, self, fctx):
     """returns True if text is different than fctx"""
--- a/tests/test-lfs.t	Fri Dec 20 01:11:35 2019 -0500
+++ b/tests/test-lfs.t	Sun Dec 22 23:50:19 2019 -0500
@@ -804,6 +804,7 @@
   checking manifests
   crosschecking files in changesets and manifests
   checking files
+  lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
   checked 5 changesets with 10 changes to 4 files
 
 Verify will not try to download lfs blobs, if told not to by the config option
@@ -815,6 +816,7 @@
   checking manifests
   crosschecking files in changesets and manifests
   checking files
+  lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
   checked 5 changesets with 10 changes to 4 files
 
 Verify will copy/link all lfs objects into the local store that aren't already