Patchwork [2,of,2,censor,RFC] revlog: _addrevision creates full-replace deltas based on censored revisions

login
register
mail settings
Submitter adgar@google.com
Date Feb. 10, 2015, 9:39 p.m.
Message ID <aec50f041bbb9c80441a.1423604385@adgar.nyc.corp.google.com>
Download mbox | patch
Permalink /patch/7778/
State Superseded
Commit 1b3b6d629d6c1f8544db349707e47293965b94c0
Headers show

Comments

adgar@google.com - Feb. 10, 2015, 9:39 p.m.
# HG changeset patch
# User Mike Edgar <adgar@google.com>
# Date 1421878297 18000
#      Wed Jan 21 17:11:37 2015 -0500
# Node ID aec50f041bbb9c80441a2f301773b76cf9772551
# Parent  78f2d6b8fe46e1eddea5758434dbb7d758ae1a1b
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

Patch

diff -r 78f2d6b8fe46 -r aec50f041bbb mercurial/revlog.py
--- a/mercurial/revlog.py	Fri Feb 06 01:38:16 2015 +0000
+++ b/mercurial/revlog.py	Wed Jan 21 17:11:37 2015 -0500
@@ -1260,8 +1260,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: