comparison mercurial/mdiff.py @ 72:4a6ab4d80dc4

Add an O(m + nlog n) patching extension
author mpm@selenic.com
date Mon, 16 May 2005 22:08:33 -0800
parents 47c9a869adee
children b942bbe4bb84
comparison
equal deleted inserted replaced
71:47c9a869adee 72:4a6ab4d80dc4
120 t = collect(b2, frags) 120 t = collect(b2, frags)
121 121
122 return m[t[1]:t[1] + t[0]] 122 return m[t[1]:t[1] + t[0]]
123 123
124 def patch(a, bin): 124 def patch(a, bin):
125 last = pos = 0 125 return patches(a, [bin])
126 r = []
127 126
128 c = 0 127 try:
129 while pos < len(bin): 128 import mpatch
130 p1, p2, l = struct.unpack(">lll", bin[pos:pos + 12]) 129 patches = mpatch.patches
131 pos += 12 130 except:
132 r.append(a[last:p1]) 131 pass
133 r.append(bin[pos:pos + l])
134 pos += l
135 last = p2
136 c += 1
137 r.append(a[last:])
138
139 return "".join(r)
140
141
142
143
144