comparison mercurial/mdiff.py @ 120:bae6f0328f63

Add a function to return the new text from a binary diff
author mpm@selenic.com
date Fri, 20 May 2005 17:42:29 -0800
parents b942bbe4bb84
children 8913e13196e1
comparison
equal deleted inserted replaced
119:c7a66f9752a4 120:bae6f0328f63
50 if o == 'equal': continue 50 if o == 'equal': continue
51 s = "".join(b[s:t]) 51 s = "".join(b[s:t])
52 bin.append(struct.pack(">lll", p[m], p[n], len(s)) + s) 52 bin.append(struct.pack(">lll", p[m], p[n], len(s)) + s)
53 53
54 return "".join(bin) 54 return "".join(bin)
55
56 def patchtext(bin):
57 pos = 0
58 t = []
59 while pos < len(bin):
60 p1, p2, l = struct.unpack(">lll", bin[pos:pos + 12])
61 pos += 12
62 t.append(bin[pos:pos + l])
63 pos += l
64 return "".join(t)
55 65
56 # This attempts to apply a series of patches in time proportional to 66 # This attempts to apply a series of patches in time proportional to
57 # the total size of the patches, rather than patches * len(text). This 67 # the total size of the patches, rather than patches * len(text). This
58 # means rather than shuffling strings around, we shuffle around 68 # means rather than shuffling strings around, we shuffle around
59 # pointers to fragments with fragment lists. 69 # pointers to fragments with fragment lists.