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

login
register
mail settings
Submitter adgar@google.com
Date Feb. 10, 2015, 11:16 p.m.
Message ID <4819c113f384392de5d0.1423610163@adgar.nyc.corp.google.com>
Download mbox | patch
Permalink /patch/7780/
State Accepted
Headers show

Comments

adgar@google.com - Feb. 10, 2015, 11:16 p.m.
# HG changeset patch
# User Mike Edgar <adgar@google.com>
# Date 1421878297 18000
#      Wed Jan 21 17:11:37 2015 -0500
# Node ID 4819c113f384392de5d0116d328d26edfb142e75
# Parent  3a1c2083548586a5ad0afe0cfaca2d070984ce61
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
Augie Fackler - Feb. 11, 2015, 2:42 p.m.
On Feb 10, 2015, at 6:16 PM, Mike Edgar <adgar@google.com> wrote:

> # HG changeset patch
> # User Mike Edgar <adgar@google.com>
> # Date 1421878297 18000
> #      Wed Jan 21 17:11:37 2015 -0500
> # Node ID 4819c113f384392de5d0116d328d26edfb142e75
> # Parent  3a1c2083548586a5ad0afe0cfaca2d070984ce61
> revlog: _addrevision creates full-replace deltas based on censored revisions

Queued these, thanks.

> 
> 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
> 
> diff -r 3a1c20835485 -r 4819c113f384 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
> @@ -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:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r 3a1c20835485 -r 4819c113f384 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
@@ -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: