Mercurial > hg
changeset 37417:76d2115cb817
verify: allow suppressing warnings about extra files
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.
Differential Revision: https://phab.mercurial-scm.org/D3097
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 04 Apr 2018 14:11:43 -0700 |
parents | 7542e97c7867 |
children | afd7b0afe4a6 |
files | mercurial/verify.py tests/simplestorerepo.py |
diffstat | 2 files changed, 20 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/verify.py Wed Apr 04 14:04:18 2018 -0700 +++ b/mercurial/verify.py Wed Apr 04 14:11:43 2018 -0700 @@ -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
--- a/tests/simplestorerepo.py Wed Apr 04 14:04:18 2018 -0700 +++ b/tests/simplestorerepo.py Wed Apr 04 14:11:43 2018 -0700 @@ -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)