# HG changeset patch # User Yuya Nishihara # Date 1523274579 -32400 # Node ID f5833651ad0731756f8b760cf3e534dc4254f2e4 # Parent 53021c4ef0b29fff87403b017fc81b89bb1d1d44 patch: stop using cext.diffhelpers The C implementation has a couple of memory bugs, and lacks error handling which could lead to SEGV. I could fix them one by one (and I mostly finished that), but the performance gain provided by cext.diffhelper is quite low. Besides, diffhelpers.addlines() calls back Python, linereader.readline(), from the innermost loop. $ hg export -R mozilla-central 0:100 > patch $ ls -lh patch -rw-r--r-- 184M patch $ hg init repo && hg -R repo import patch --time --bypass (cext) time: real 34.970 secs (user 32.720+0.000 sys 2.230+0.000) (pure) time: real 35.950 secs (user 33.600+0.000 sys 2.330+0.000) So, let's simply use the pure Python implementation. diff -r 53021c4ef0b2 -r f5833651ad07 mercurial/patch.py --- a/mercurial/patch.py Mon Apr 09 20:47:43 2018 +0900 +++ b/mercurial/patch.py Mon Apr 09 20:49:39 2018 +0900 @@ -33,20 +33,19 @@ mail, mdiff, pathutil, - policy, pycompat, scmutil, similar, util, vfs as vfsmod, ) +from .pure import diffhelpers from .utils import ( dateutil, procutil, stringutil, ) -diffhelpers = policy.importmod(r'diffhelpers') stringio = util.stringio gitre = re.compile(br'diff --git a/(.*) b/(.*)')