Mercurial > public > mercurial-scm > hg
diff mercurial/patch.py @ 24341:616c01b69898
record: change interface of the filtering function
This way filtering functions accept chunks and return chunks
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Thu, 12 Mar 2015 17:51:37 -0700 |
parents | 6ddc86eedc3b |
children | 31edcea517c1 |
line wrap: on
line diff
--- a/mercurial/patch.py Thu Mar 12 23:15:06 2015 -0400 +++ b/mercurial/patch.py Thu Mar 12 17:51:37 2015 -0700 @@ -15,6 +15,7 @@ from i18n import _ from node import hex, short +import cStringIO import base85, mdiff, scmutil, util, diffhelpers, copies, encoding, error gitre = re.compile('diff --git a/(.*) b/(.*)') @@ -1352,7 +1353,7 @@ return s return s[:i] -def parsepatch(fp): +def parsepatch(originalchunks): """patch -> [] of headers -> [] of hunks """ class parser(object): """patch parsing state machine""" @@ -1421,6 +1422,9 @@ } p = parser() + fp = cStringIO.StringIO() + fp.write(''.join(originalchunks)) + fp.seek(0) state = 'context' for newstate, data in scanpatch(fp): @@ -1430,6 +1434,7 @@ raise PatchError('unhandled transition: %s -> %s' % (state, newstate)) state = newstate + del fp return p.finished() def pathtransform(path, strip, prefix):