comparison mercurial/verify.py @ 39842:97986c9c69d3

verify: start to abstract file verification Currently, the file storage interface has a handful of attributes that are exclusively or near-exclusively used by repo verification code. In order to support verification on non-revlog/alternate storage backends, we'll need to abstract verification so it can be performed in a storage-agnostic way. This commit starts that process. We establish a new verifyintegrity() method on revlogs and expose it to the file storage interface. Most of verify.verifier.checklog() has been ported to this new method. We need a way to represent verification problems. So we invent an interface to represent a verification problem, invent a revlog type to implement that interface, and use it. The arguments to verifyintegrity() will almost certainly change in the future, once more functionality is ported from the verify code. And the "revlogv1" version check is very hacky. (The code in verify is actually buggy because it is comparing the full 32-bit header integer instead of just the revlog version short. I'll likely fix this in a subsequent commit.) Differential Revision: https://phab.mercurial-scm.org/D4701
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 19 Sep 2018 11:17:28 -0700
parents b63dee7bd0d9
children e6d3d39cc1c7
comparison
equal deleted inserted replaced
39841:39f51064e9f5 39842:97986c9c69d3
339 if not f: 339 if not f:
340 self.err(None, _("cannot decode filename '%s'") % f2) 340 self.err(None, _("cannot decode filename '%s'") % f2)
341 elif (size > 0 or not revlogv1) and f.startswith('data/'): 341 elif (size > 0 or not revlogv1) and f.startswith('data/'):
342 storefiles.add(_normpath(f)) 342 storefiles.add(_normpath(f))
343 343
344 state = {
345 'revlogv1': self.revlogv1,
346 }
347
344 files = sorted(set(filenodes) | set(filelinkrevs)) 348 files = sorted(set(filenodes) | set(filelinkrevs))
345 revisions = 0 349 revisions = 0
346 progress = ui.makeprogress(_('checking'), unit=_('files'), 350 progress = ui.makeprogress(_('checking'), unit=_('files'),
347 total=len(files)) 351 total=len(files))
348 for i, f in enumerate(files): 352 for i, f in enumerate(files):
371 if self.warnorphanstorefiles: 375 if self.warnorphanstorefiles:
372 self.warn(_(" warning: revlog '%s' not in fncache!") % 376 self.warn(_(" warning: revlog '%s' not in fncache!") %
373 ff) 377 ff)
374 self.fncachewarned = True 378 self.fncachewarned = True
375 379
376 self.checklog(fl, f, lr) 380 if not len(fl) and (self.havecl or self.havemf):
381 self.err(lr, _("empty or missing %s") % f)
382 else:
383 for problem in fl.verifyintegrity(state):
384 if problem.warning:
385 self.warn(problem.warning)
386 elif problem.error:
387 self.err(lr, problem.error, f)
388 else:
389 raise error.ProgrammingError(
390 'problem instance does not set warning or error '
391 'attribute: %s' % problem.msg)
392
377 seen = {} 393 seen = {}
378 rp = None 394 rp = None
379 for i in fl: 395 for i in fl:
380 revisions += 1 396 revisions += 1
381 n = fl.node(i) 397 n = fl.node(i)