comparison 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
comparison
equal deleted inserted replaced
24119:a5a06c9c7407 24120:a450e0a2ba0a
1401 if deltabase not in self.nodemap: 1401 if deltabase not in self.nodemap:
1402 raise LookupError(deltabase, self.indexfile, 1402 raise LookupError(deltabase, self.indexfile,
1403 _('unknown delta base')) 1403 _('unknown delta base'))
1404 1404
1405 baserev = self.rev(deltabase) 1405 baserev = self.rev(deltabase)
1406
1407 if baserev != nullrev and self.iscensored(baserev):
1408 # if base is censored, delta must be full replacement in a
1409 # single patch operation
1410 hlen = struct.calcsize(">lll")
1411 oldlen = self.rawsize(baserev)
1412 newlen = len(delta) - hlen
1413 if delta[:hlen] != mdiff.replacediffheader(oldlen, newlen):
1414 raise error.CensoredBaseError(self.indexfile,
1415 self.node(baserev))
1416
1406 chain = self._addrevision(node, None, transaction, link, 1417 chain = self._addrevision(node, None, transaction, link,
1407 p1, p2, REVIDX_DEFAULT_FLAGS, 1418 p1, p2, REVIDX_DEFAULT_FLAGS,
1408 (baserev, delta), ifh, dfh) 1419 (baserev, delta), ifh, dfh)
1409 if not dfh and not self._inline: 1420 if not dfh and not self._inline:
1410 # addrevision switched from inline to conventional 1421 # addrevision switched from inline to conventional