mercurial/pure/mpatch.py
changeset 14065 8f7132fa5e59
parent 11122 2114e44b08f6
child 16683 525fdb738975
--- a/mercurial/pure/mpatch.py	Sat Apr 30 13:59:14 2011 +0200
+++ b/mercurial/pure/mpatch.py	Sat Apr 30 15:05:34 2011 +0200
@@ -56,9 +56,9 @@
 
     def pull(dst, src, l): # pull l bytes from src
         while l:
-            f = src.pop(0)
+            f = src.pop()
             if f[0] > l: # do we need to split?
-                src.insert(0, (f[0] - l, f[1] + l))
+                src.append((f[0] - l, f[1] + l))
                 dst.append((l, f[1]))
                 return
             dst.append(f)
@@ -66,7 +66,7 @@
 
     def collect(buf, list):
         start = buf
-        for l, p in list:
+        for l, p in reversed(list):
             move(buf, p, l)
             buf += l
         return (buf - start, start)
@@ -88,7 +88,7 @@
             new.append((l, pos + 12))        # what got added
             pos += l + 12
             last = p2
-        frags = new + frags                    # what was left at the end
+        frags.extend(reversed(new))                    # what was left at the end
 
     t = collect(b2, frags)