Patchwork D3097: verify: allow suppressing warnings about extra files

login
register
mail settings
Submitter phabricator
Date April 5, 2018, 1:25 a.m.
Message ID <differential-rev-PHID-DREV-7dsy25suzrcrjinwonf4-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30320/
State Superseded
Headers show

Comments

phabricator - April 5, 2018, 1:25 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The verifier issues warnings when the set of files in .hg/store
  doesn't align with the set of files that are advertised via
  repo.file(f).files() for all files seen in ctx.files() changelog
  traversal.
  
  This logic is reasonable for a default implementation. But some
  stores may have extra files whose presence is harmless. Or those
  stores may not have the same transaction rollback semantics that
  unlink files as other stores.
  
  This commit adds support for disabling the warning for orphaned
  files.
  
  The simple store extension has been taught to set this flag.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/verify.py
  tests/simplestorerepo.py

CHANGE DETAILS




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

Patch

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -35,6 +35,7 @@ 
     pycompat,
     revlog,
     store,
+    verify,
 )
 
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
@@ -656,9 +657,17 @@ 
 
     return simplestore(path, vfstype)
 
+def verifierinit(orig, self, *args, **kwargs):
+    orig(self, *args, **kwargs)
+
+    # We don't care that files in the store don't align with what is
+    # advertised. So suppress these warnings.
+    self.warnorphanstorefiles = False
+
 def extsetup(ui):
     localrepo.featuresetupfuncs.add(featuresetup)
 
     extensions.wrapfunction(localrepo, 'newreporequirements',
                             newreporequirements)
     extensions.wrapfunction(store, 'store', makestore)
+    extensions.wrapfunction(verify.verifier, '__init__', verifierinit)
diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -52,6 +52,7 @@ 
         self.fncachewarned = False
         # developer config: verify.skipflags
         self.skipflags = repo.ui.configint('verify', 'skipflags')
+        self.warnorphanstorefiles = True
 
     def warn(self, msg):
         self.ui.warn(msg + "\n")
@@ -294,8 +295,9 @@ 
 
         if not dir and subdirnodes:
             ui.progress(_('checking'), None)
-            for f in sorted(storefiles):
-                self.warn(_("warning: orphan data file '%s'") % f)
+            if self.warnorphanstorefiles:
+                for f in sorted(storefiles):
+                    self.warn(_("warning: orphan data file '%s'") % f)
 
         return filenodes
 
@@ -369,8 +371,10 @@ 
                 try:
                     storefiles.remove(ff)
                 except KeyError:
-                    self.warn(_(" warning: revlog '%s' not in fncache!") % ff)
-                    self.fncachewarned = True
+                    if self.warnorphanstorefiles:
+                        self.warn(_(" warning: revlog '%s' not in fncache!") %
+                                  ff)
+                        self.fncachewarned = True
 
             self.checklog(fl, f, lr)
             seen = {}
@@ -481,7 +485,8 @@ 
                              short(node), f)
         ui.progress(_('checking'), None)
 
-        for f in sorted(storefiles):
-            self.warn(_("warning: orphan data file '%s'") % f)
+        if self.warnorphanstorefiles:
+            for f in sorted(storefiles):
+                self.warn(_("warning: orphan data file '%s'") % f)
 
         return len(files), revisions