changeset 44071:34e8305f02bd

lfs: add a switch to `hg verify` to ignore the content of blobs Trying to validate the fulltext of an external revision causes missing blobs to be downloaded and cached. Since the downloads aren't batch prefetched[1] and aren't compressed, this can be expensive both in terms of time and space. I made this a tri-state instead of a simple bool because there's an existing (undocumented) config to handle this, and it would be weird if `hg verify` were to suddenly start ignoring that config but an `hg recover` initiated verify honors it. Since this uses the same config setting, it too will skip rename verification (which requires fulltext, but not for LFS). [1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2018-April/116118.html Differential Revision: https://phab.mercurial-scm.org/D7708
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 20 Dec 2019 01:11:35 -0500
parents 451d22174b5f
children 1a6dd50cd0db
files hgext/lfs/__init__.py tests/test-lfs.t
diffstat 2 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/lfs/__init__.py	Wed Jan 08 14:37:54 2020 -0500
+++ b/hgext/lfs/__init__.py	Fri Dec 20 01:11:35 2019 -0500
@@ -402,3 +402,24 @@
     revs = opts.get('rev', [])
     pointers = wrapper.extractpointers(repo, scmutil.revrange(repo, revs))
     wrapper.uploadblobs(repo, pointers)
+
+
+@eh.wrapcommand(
+    b'verify', opts=[(b'', b'no-lfs', None, _(b'skip all lfs blob content'))]
+)
+def verify(orig, ui, repo, **opts):
+    skipflags = repo.ui.configint(b'verify', b'skipflags')
+    no_lfs = opts.pop('no_lfs')
+
+    if skipflags:
+        # --lfs overrides the config bit, if set.
+        if no_lfs is False:
+            skipflags &= ~repository.REVISION_FLAG_EXTSTORED
+    else:
+        skipflags = 0
+
+    if no_lfs is True:
+        skipflags |= repository.REVISION_FLAG_EXTSTORED
+
+    with ui.configoverride({(b'verify', b'skipflags'): skipflags}):
+        return orig(ui, repo, **opts)
--- a/tests/test-lfs.t	Wed Jan 08 14:37:54 2020 -0500
+++ b/tests/test-lfs.t	Fri Dec 20 01:11:35 2019 -0500
@@ -796,6 +796,27 @@
   $ test -f fromcorrupt/.hg/store/lfs/objects/66/100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
   [1]
 
+Verify will not try to download lfs blobs, if told not to process lfs content
+
+  $ hg -R fromcorrupt --config lfs.usercache=emptycache verify -v --no-lfs
+  repository uses revlog format 1
+  checking changesets
+  checking manifests
+  crosschecking files in changesets and manifests
+  checking files
+  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
+
+  $ hg -R fromcorrupt --config lfs.usercache=emptycache verify -v \
+  >                   --config verify.skipflags=8192
+  repository uses revlog format 1
+  checking changesets
+  checking manifests
+  crosschecking files in changesets and manifests
+  checking files
+  checked 5 changesets with 10 changes to 4 files
+
 Verify will copy/link all lfs objects into the local store that aren't already
 present.  Bypass the corrupted usercache to show that verify works when fed by
 the (uncorrupted) remote store.