# HG changeset patch # User Augie Fackler # Date 1458420196 14400 # Node ID 6546afde350e26707960a9173a291119ff31f91c # Parent 76d7cab13f042ea56264ab431bef15236147a9bf mpatch: un-nest the move() method This helps the code read a little more clearly. diff -r 76d7cab13f04 -r 6546afde350e mercurial/pure/mpatch.py --- 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)