Patchwork [3,of,4,censor,RFC] mdiff: add helper for making deltas which replace the full text of a revision

login
register
mail settings
Submitter adgar@google.com
Date Feb. 6, 2015, 3:57 a.m.
Message ID <95ed0ff48518b8390eb0.1423195069@adgar.nyc.corp.google.com>
Download mbox | patch
Permalink /patch/7704/
State Accepted
Headers show

Comments

adgar@google.com - Feb. 6, 2015, 3:57 a.m.
# HG changeset patch
# User Mike Edgar <adgar@google.com>
# Date 1421876109 18000
#      Wed Jan 21 16:35:09 2015 -0500
# Node ID 95ed0ff48518b8390eb084e8efb9e647516a0b8d
# Parent  75e6aa3db49612a96fe768e16fd17c22f0a21ce9
mdiff: add helper for making deltas which replace the full text of a revision

This helper will be used initially for censor-aware delta generation. Deltas
which replace the full contents of the base revision are guaranteed to apply
correctly regardless of whether the delta recipient has censored the base.

For background and broader design of the censorship feature, see:
http://mercurial.selenic.com/wiki/CensorPlan
Augie Fackler - Feb. 10, 2015, 7:15 p.m.
On Thu, Feb 05, 2015 at 10:57:49PM -0500, Mike Edgar wrote:
> # HG changeset patch
> # User Mike Edgar <adgar@google.com>
> # Date 1421876109 18000
> #      Wed Jan 21 16:35:09 2015 -0500
> # Node ID 95ed0ff48518b8390eb084e8efb9e647516a0b8d
> # Parent  75e6aa3db49612a96fe768e16fd17c22f0a21ce9
> mdiff: add helper for making deltas which replace the full text of a revision
>
> This helper will be used initially for censor-aware delta generation. Deltas
> which replace the full contents of the base revision are guaranteed to apply
> correctly regardless of whether the delta recipient has censored the base.
>
> For background and broader design of the censorship feature, see:
> http://mercurial.selenic.com/wiki/CensorPlan
>
> diff -r 75e6aa3db496 -r 95ed0ff48518 mercurial/mdiff.py
> --- a/mercurial/mdiff.py	Fri Jan 23 17:01:39 2015 -0500
> +++ b/mercurial/mdiff.py	Wed Jan 21 16:35:09 2015 -0500
> @@ -367,6 +367,9 @@
>  def trivialdiffheader(length):
>      return struct.pack(">lll", 0, 0, length)
>
> +def replacediffheader(old, new):
> +    return struct.pack(">lll", 0, old, new)

it wasn't immediately obvious to me that old and new are
lengths. Maybe oldlen and newlen?

> +
>  patches = mpatch.patches
>  patchedsize = mpatch.patchedsize
>  textdiff = bdiff.bdiff
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r 75e6aa3db496 -r 95ed0ff48518 mercurial/mdiff.py
--- a/mercurial/mdiff.py	Fri Jan 23 17:01:39 2015 -0500
+++ b/mercurial/mdiff.py	Wed Jan 21 16:35:09 2015 -0500
@@ -367,6 +367,9 @@ 
 def trivialdiffheader(length):
     return struct.pack(">lll", 0, 0, length)
 
+def replacediffheader(old, new):
+    return struct.pack(">lll", 0, old, new)
+
 patches = mpatch.patches
 patchedsize = mpatch.patchedsize
 textdiff = bdiff.bdiff