Mercurial > hg-stable
comparison mercurial/patch.py @ 37568:f5833651ad07
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.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 09 Apr 2018 20:49:39 +0900 |
parents | 51d5e1ff0613 |
children | c4c8d0d1267f |
comparison
equal
deleted
inserted
replaced
37567:53021c4ef0b2 | 37568:f5833651ad07 |
---|---|
31 encoding, | 31 encoding, |
32 error, | 32 error, |
33 mail, | 33 mail, |
34 mdiff, | 34 mdiff, |
35 pathutil, | 35 pathutil, |
36 policy, | |
37 pycompat, | 36 pycompat, |
38 scmutil, | 37 scmutil, |
39 similar, | 38 similar, |
40 util, | 39 util, |
41 vfs as vfsmod, | 40 vfs as vfsmod, |
42 ) | 41 ) |
42 from .pure import diffhelpers | |
43 from .utils import ( | 43 from .utils import ( |
44 dateutil, | 44 dateutil, |
45 procutil, | 45 procutil, |
46 stringutil, | 46 stringutil, |
47 ) | 47 ) |
48 | 48 |
49 diffhelpers = policy.importmod(r'diffhelpers') | |
50 stringio = util.stringio | 49 stringio = util.stringio |
51 | 50 |
52 gitre = re.compile(br'diff --git a/(.*) b/(.*)') | 51 gitre = re.compile(br'diff --git a/(.*) b/(.*)') |
53 tabsplitter = re.compile(br'(\t+|[^\t]+)') | 52 tabsplitter = re.compile(br'(\t+|[^\t]+)') |
54 _nonwordre = re.compile(br'([^a-zA-Z0-9_\x80-\xff])') | 53 _nonwordre = re.compile(br'([^a-zA-Z0-9_\x80-\xff])') |