comparison mercurial/verify.py @ 47877:2174f54aab18

store: return just one filename in walk functions Various walk functions return `(revlog_type, decoded, encoded)` where decoded could be None. But no-one cares about `encoded` and expects `unencoded` to be present, except verify (because this can only happen with old repo formats). Simplify all this by either failing outright if a decoding a filename fails (instead of almost certainly failing with a type error due to treating None as a bytes), or skipping the filename but providing in an out argument for hg verify. Differential Revision: https://phab.mercurial-scm.org/D11248
author Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
date Mon, 02 Aug 2021 08:05:13 -0400
parents ab5fd39cb402
children 6000f5b25c9b
comparison
equal deleted inserted replaced
47876:517a2c1cb788 47877:2174f54aab18
393 if not dir and subdirnodes: 393 if not dir and subdirnodes:
394 self.ui.status(_(b"checking directory manifests\n")) 394 self.ui.status(_(b"checking directory manifests\n"))
395 storefiles = set() 395 storefiles = set()
396 subdirs = set() 396 subdirs = set()
397 revlogv1 = self.revlogv1 397 revlogv1 = self.revlogv1
398 for t, f, f2, size in repo.store.datafiles(): 398 undecodable = []
399 if not f: 399 for t, f, size in repo.store.datafiles(undecodable=undecodable):
400 self._err(None, _(b"cannot decode filename '%s'") % f2) 400 if (size > 0 or not revlogv1) and f.startswith(b'meta/'):
401 elif (size > 0 or not revlogv1) and f.startswith(b'meta/'):
402 storefiles.add(_normpath(f)) 401 storefiles.add(_normpath(f))
403 subdirs.add(os.path.dirname(f)) 402 subdirs.add(os.path.dirname(f))
403 for f in undecodable:
404 self._err(None, _(b"cannot decode filename '%s'") % f)
404 subdirprogress = ui.makeprogress( 405 subdirprogress = ui.makeprogress(
405 _(b'checking'), unit=_(b'manifests'), total=len(subdirs) 406 _(b'checking'), unit=_(b'manifests'), total=len(subdirs)
406 ) 407 )
407 408
408 for subdir, linkrevs in pycompat.iteritems(subdirnodes): 409 for subdir, linkrevs in pycompat.iteritems(subdirnodes):
457 revlogv1 = self.revlogv1 458 revlogv1 = self.revlogv1
458 havemf = self.havemf 459 havemf = self.havemf
459 ui.status(_(b"checking files\n")) 460 ui.status(_(b"checking files\n"))
460 461
461 storefiles = set() 462 storefiles = set()
462 for rl_type, f, f2, size in repo.store.datafiles(): 463 undecodable = []
463 if not f: 464 for t, f, size in repo.store.datafiles(undecodable=undecodable):
464 self._err(None, _(b"cannot decode filename '%s'") % f2) 465 if (size > 0 or not revlogv1) and f.startswith(b'data/'):
465 elif (size > 0 or not revlogv1) and f.startswith(b'data/'):
466 storefiles.add(_normpath(f)) 466 storefiles.add(_normpath(f))
467 for f in undecodable:
468 self._err(None, _(b"cannot decode filename '%s'") % f)
467 469
468 state = { 470 state = {
469 # TODO this assumes revlog storage for changelog. 471 # TODO this assumes revlog storage for changelog.
470 b'expectedversion': self.repo.changelog._format_version, 472 b'expectedversion': self.repo.changelog._format_version,
471 b'skipflags': self.skipflags, 473 b'skipflags': self.skipflags,