# HG changeset patch # User mpm@selenic.com # Date 2005-05-21 01:42:29 # Node ID bae6f0328f635e856ceb196d381209dc66e586bb # Parent c7a66f9752a49487ff5f34ffad9705be02468616 Add a function to return the new text from a binary diff diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py --- a/mercurial/mdiff.py +++ b/mercurial/mdiff.py @@ -53,6 +53,16 @@ def diff(a, b, sorted=0): return "".join(bin) +def patchtext(bin): + pos = 0 + t = [] + while pos < len(bin): + p1, p2, l = struct.unpack(">lll", bin[pos:pos + 12]) + pos += 12 + t.append(bin[pos:pos + l]) + pos += l + return "".join(t) + # This attempts to apply a series of patches in time proportional to # the total size of the patches, rather than patches * len(text). This # means rather than shuffling strings around, we shuffle around