# HG changeset patch # User Augie Fackler # Date 1446657258 18000 # Node ID d1c741644d252c6260e46f4ebeba99aebe07375a # Parent 5f88e092f82c891697ba447fff0c56b5c8e7843d verify: add a hook that can let extensions manipulate file lists Without a hook of this nature, narrowhg[0] clones always result in 'hg verify' reporting terrible damage to the entire repository history. With this hook, we can ignore files that aren't supposed to be in the clone, and then get an accurate report of any damage present (or not) in the repo. 0: https://bitbucket.org/Google/narrowhg diff -r 5f88e092f82c -r d1c741644d25 mercurial/verify.py --- a/mercurial/verify.py Tue Nov 10 17:16:59 2015 -0800 +++ b/mercurial/verify.py Wed Nov 04 12:14:18 2015 -0500 @@ -35,6 +35,17 @@ f = f.replace('//', '/') return f +def _validpath(repo, path): + """Returns False if a path should NOT be treated as part of a repo. + + For all in-core cases, this returns True, as we have no way for a + path to be mentioned in the history but not actually be + relevant. For narrow clones, this is important because many + filelogs will be missing, and changelog entries may mention + modified files that are outside the narrow scope. + """ + return True + def _verify(repo): repo = repo.unfiltered() mflinkrevs = {} @@ -154,7 +165,8 @@ mflinkrevs.setdefault(changes[0], []).append(i) refersmf = True for f in changes[3]: - filelinkrevs.setdefault(_normpath(f), []).append(i) + if _validpath(repo, f): + filelinkrevs.setdefault(_normpath(f), []).append(i) except Exception as inst: refersmf = True exc(i, _("unpacking changeset %s") % short(n), inst) @@ -181,7 +193,9 @@ if not f: err(lr, _("file without name in manifest")) elif f != "/dev/null": # ignore this in very old repos - filenodes.setdefault(_normpath(f), {}).setdefault(fn, lr) + if _validpath(repo, f): + filenodes.setdefault( + _normpath(f), {}).setdefault(fn, lr) except Exception as inst: exc(lr, _("reading manifest delta %s") % short(n), inst) ui.progress(_('checking'), None)