##// END OF EJS Templates
mpatch: move collect() to module level...
Augie Fackler -
r28589:c4c7be9f default
parent child Browse files
Show More
@@ -42,6 +42,13 b' def _move(m, dest, src, count):'
42 42 m.seek(dest)
43 43 m.write(buf)
44 44
45 def _collect(m, buf, list):
46 start = buf
47 for l, p in reversed(list):
48 _move(m, buf, p, l)
49 buf += l
50 return (buf - start, start)
51
45 52 def patches(a, bins):
46 53 if not bins:
47 54 return a
@@ -66,18 +73,11 b' def patches(a, bins):'
66 73 m.seek(pos)
67 74 for p in bins: m.write(p)
68 75
69 def collect(buf, list):
70 start = buf
71 for l, p in reversed(list):
72 _move(m, buf, p, l)
73 buf += l
74 return (buf - start, start)
75
76 76 for plen in plens:
77 77 # if our list gets too long, execute it
78 78 if len(frags) > 128:
79 79 b2, b1 = b1, b2
80 frags = [collect(b1, frags)]
80 frags = [_collect(m, b1, frags)]
81 81
82 82 new = []
83 83 end = pos + plen
@@ -92,7 +92,7 b' def patches(a, bins):'
92 92 last = p2
93 93 frags.extend(reversed(new)) # what was left at the end
94 94
95 t = collect(b2, frags)
95 t = _collect(m, b2, frags)
96 96
97 97 m.seek(t[1])
98 98 return m.read(t[0])
General Comments 0
You need to be logged in to leave comments. Login now