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

login
register
mail settings
Submitter adgar@google.com
Date Jan. 23, 2015, 11:53 p.m.
Message ID <38c9db6fa5d4c6ee6c60.1422057204@adgar.nyc.corp.google.com>
Download mbox | patch
Permalink /patch/7546/
State Superseded
Commit 1b3b6d629d6c1f8544db349707e47293965b94c0
Headers show

Comments

adgar@google.com - Jan. 23, 2015, 11:53 p.m.
# HG changeset patch
# User Mike Edgar <adgar@google.com>
# Date 1421878297 18000
#      Wed Jan 21 17:11:37 2015 -0500
# Node ID 38c9db6fa5d4c6ee6c607278e12daa1bc003a345
# Parent  b532b15853310060626d192942a7946bab1e5900
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 b532b1585331 -r 38c9db6fa5d4 mercurial/revlog.py
--- a/mercurial/revlog.py	Fri Jan 23 17:01:07 2015 -0500
+++ b/mercurial/revlog.py	Wed Jan 21 17:11:37 2015 -0500
@@ -1249,8 +1249,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: