Mercurial > hg
changeset 24123:eb2d41c6ec37
revlog: _addrevision creates full-replace deltas based on censored revisions
A delta against a censored revision is either received through exchange and
written blindly to a revlog, or it is created by the revlog itself. This
change ensures the latter process creates deltas which fully replace all
data in a censored base using a single patch operation.
Recipients of a delta against a censored base will verify that the delta is in
this full-replace format. Other recipients will use the delta as normal.
For background and broader design of the censorship feature, see:
http://mercurial.selenic.com/wiki/CensorPlan
author | Mike Edgar <adgar@google.com> |
---|---|
date | Wed, 21 Jan 2015 17:11:37 -0500 |
parents | da14b8eba806 |
children | 042d95beeee8 |
files | mercurial/revlog.py |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlog.py Fri Feb 06 01:38:16 2015 +0000 +++ b/mercurial/revlog.py Wed Jan 21 17:11:37 2015 -0500 @@ -1261,8 +1261,14 @@ delta = cachedelta[1] else: t = buildtext() - ptext = self.revision(self.node(rev)) - delta = mdiff.textdiff(ptext, t) + if self.iscensored(rev): + # deltas based on a censored revision must replace the + # full content in one patch, so delta works everywhere + header = mdiff.replacediffheader(self.rawsize(rev), len(t)) + delta = header + t + else: + ptext = self.revision(self.node(rev)) + delta = mdiff.textdiff(ptext, t) data = self.compress(delta) l = len(data[1]) + len(data[0]) if basecache[0] == rev: