[PATCH] localrepo: add optional validation (defaults to off) for incoming changes
Augie Fackler
durin42 at gmail.com
Thu Feb 11 16:37:28 CST 2010
On Feb 9, 2010, at 6:19 PM, Benoit Boissinot wrote:
> On Tue, Feb 09, 2010 at 05:58:08PM -0600, Augie Fackler wrote:
>> # HG changeset patch
>> # User Augie Fackler <durin42 at gmail.com>
>> # Date 1265758800 21600
>> # Node ID e24ff7e571d125a5c2517959b8e30321b32c587f
>> # Parent 2d30d66a89ad29f471aa6918fc46121a4bc3fbe8
>> localrepo: add optional validation (defaults to off) for incoming
>> changes
>>
>> This verifies that all manifests are present for incoming changes,
>> and all files for those manifests are also present. This is a simple
>> first-pass, and could be better, but seems like a valuable thing to
>> have, as I've seen pushes in the past that propagated revlog
>> corruption.
>>
>> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
>> --- a/mercurial/localrepo.py
>> +++ b/mercurial/localrepo.py
>> @@ -2005,6 +2005,16 @@
>> # be empty during the pull
>> self.manifest.addgroup(chunkiter, revmap, trp)
>>
>> + needfiles = {}
>> + if self.ui.configbool('repo', 'validate',
>> default=False):
>> + # validate incoming csets have their manifests
>> + for cset in xrange(clstart, clend):
>> + mfest =
>> self.changelog.read(self.changelog.node(cset))[0]
>> + mfest = self.manifest.read(mfest)
>
> readdelta() here
>
>> + for f, needs in needfiles.iteritems():
>> + fl = self.file(f)
>> + for n in needs:
>> + try:
>> + fl.rev(n)
>> + except error.LookupError:
>> + raise util.Abort(
>> + _('missing file data for %s:%s - run
>> hg verify') %
>> + (f, hex(n)))
>
> Maybe you could check that fl doesn't have any orphan revs too (and
> that
> there aren't any orphan filelog).
We could, but that feels less valuable to me - specifically, that
won't cause the server to accept revisions that it can't give back,
where a missing file node actually causes things to break
catastrophically if the user can't run strip or do some other kind of
repair.
>
> Cheers,
>
> Benoit
>
> --
> :wq
More information about the Mercurial-devel
mailing list