mpatch: un-nest the move() method
This helps the code read a little more clearly.
--- a/mercurial/pure/mpatch.py Sat Mar 19 16:37:30 2016 -0400
+++ b/mercurial/pure/mpatch.py Sat Mar 19 16:43:16 2016 -0400
@@ -32,6 +32,16 @@
dst.append(f)
l -= f[0]
+def _move(m, dest, src, count):
+ """move count bytes from src to dest
+
+ The file pointer is left at the end of dest.
+ """
+ m.seek(src)
+ buf = m.read(count)
+ m.seek(dest)
+ m.write(buf)
+
def patches(a, bins):
if not bins:
return a
@@ -46,15 +56,6 @@
return a
m = StringIO()
- def move(dest, src, count):
- """move count bytes from src to dest
-
- The file pointer is left at the end of dest.
- """
- m.seek(src)
- buf = m.read(count)
- m.seek(dest)
- m.write(buf)
# load our original text
m.write(a)
@@ -68,7 +69,7 @@
def collect(buf, list):
start = buf
for l, p in reversed(list):
- move(buf, p, l)
+ _move(m, buf, p, l)
buf += l
return (buf - start, start)