diff 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
line wrap: on
line diff
--- a/mercurial/mdiff.py
+++ b/mercurial/mdiff.py
@@ -122,23 +122,10 @@ def patches(a, bins):
     return m[t[1]:t[1] + t[0]]
 
 def patch(a, bin):
-    last = pos = 0
-    r = []
+    return patches(a, [bin])
 
-    c = 0
-    while pos < len(bin):
-        p1, p2, l = struct.unpack(">lll", bin[pos:pos + 12])
-        pos += 12
-        r.append(a[last:p1])
-        r.append(bin[pos:pos + l])
-        pos += l
-        last = p2
-        c += 1
-    r.append(a[last:])
-
-    return "".join(r)
-
-
-
-
-
+try:
+    import mpatch
+    patches = mpatch.patches
+except:
+    pass