Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revlog.py @ 24120:a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
To ensure interoperability when clones disagree about which file nodes are
censored, a restriction is made on deltas based on censored nodes. Any such
delta must replace the full text of the base in a single patch.
If the recipient of a delta considers the base to be censored and the delta
is not in the expected form, the recipient must reject it, as it can't know
if the source has also censored the base.
For background and broader design of the censorship feature, see:
http://mercurial.selenic.com/wiki/CensorPlan
author | Mike Edgar <adgar@google.com> |
---|---|
date | Fri, 06 Feb 2015 00:55:29 +0000 |
parents | 76f6ae06ddf5 |
children | da14b8eba806 |
line wrap: on
line diff
--- a/mercurial/revlog.py Wed Jan 21 16:35:09 2015 -0500 +++ b/mercurial/revlog.py Fri Feb 06 00:55:29 2015 +0000 @@ -1403,6 +1403,17 @@ _('unknown delta base')) baserev = self.rev(deltabase) + + if baserev != nullrev and self.iscensored(baserev): + # if base is censored, delta must be full replacement in a + # single patch operation + hlen = struct.calcsize(">lll") + oldlen = self.rawsize(baserev) + newlen = len(delta) - hlen + if delta[:hlen] != mdiff.replacediffheader(oldlen, newlen): + raise error.CensoredBaseError(self.indexfile, + self.node(baserev)) + chain = self._addrevision(node, None, transaction, link, p1, p2, REVIDX_DEFAULT_FLAGS, (baserev, delta), ifh, dfh)