diff mercurial/verify.py @ 32288:a2ab9ebcd85b

verify: add a config option to skip certain flag processors Previously, "hg verify" verifies everything, which could be undesirable when there are expensive flag processor contents. This patch adds a "verify.skipflags" developer config. A flag processor will be skipped if (flag & verify.skipflags) == 0. In the LFS usecase, that means "hg verify --config verify.skipflags=8192" will not download all LFS blobs, which could be too large to be stored locally. Note: "renamed" is also skipped since its default implementation may call filelog.data() which will trigger the flag processor.
author Jun Wu <quark@fb.com>
date Sun, 14 May 2017 09:38:06 -0700
parents 8a137ef6e5da
children 0407a51b9d8c
line wrap: on
line diff
--- a/mercurial/verify.py	Mon May 15 09:35:27 2017 -0700
+++ b/mercurial/verify.py	Sun May 14 09:38:06 2017 -0700
@@ -49,6 +49,8 @@
         self.lrugetctx = util.lrucachefunc(repo.changectx)
         self.refersmf = False
         self.fncachewarned = False
+        # developer config: verify.skipflags
+        self.skipflags = repo.ui.configint('verify', 'skipflags')
 
     def warn(self, msg):
         self.ui.warn(msg + "\n")
@@ -427,8 +429,12 @@
                 #  2. hash check: depending on flag processor, we may need to
                 #     use either "text" (external), or "rawtext" (in revlog).
                 try:
-                    fl.read(n) # side effect: read content and do checkhash
-                    rp = fl.renamed(n)
+                    skipflags = self.skipflags
+                    if skipflags:
+                        skipflags &= fl.flags(i)
+                    if not skipflags:
+                        fl.read(n) # side effect: read content and do checkhash
+                        rp = fl.renamed(n)
                     # the "L1 == L2" check
                     l1 = fl.rawsize(i)
                     l2 = len(fl.revision(n, raw=True))