This is similar to bdiff.blocks, but uses xdiff as the backend.
The indent heuristic is turned on by default since it has little overhead
and improves diff quality significantly.
indygreg | |
durin42 |
hg-reviewers |
This is similar to bdiff.blocks, but uses xdiff as the backend.
The indent heuristic is turned on by default since it has little overhead
and improves diff quality significantly.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
mercurial/cext/bdiff.c | ||
---|---|---|
266 | Calling PyList_Append() in tight loops can be a bit slow. It is faster to allocate an array of PyObject and then allocate a PyList of final size and call PyList_SET_ITEM to populate it. But we can optimize this later: this is definitely the easiest first implementation. | |
290 | Does our C standard level allow to declare variables after non-declarations in blocks? | |
310 | This exception type is nonsensical. But it is what blocks() uses. So not worth worrying about. |
mercurial/cext/bdiff.c | ||
---|---|---|
266 | Ideally, xdiff could return how many lines the input string has. So we can preallocate. But it's not in the current xdiff API. |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/cext/bdiff.c (63 lines) | |||
M | mercurial/policy.py (2 lines) | |||
M | setup.py (23 lines) |
raise ImportError(r'cannot import name %s' % modname) | raise ImportError(r'cannot import name %s' % modname) | ||||
# force import; fakelocals[modname] may be replaced with the real module | # force import; fakelocals[modname] may be replaced with the real module | ||||
getattr(mod, r'__doc__', None) | getattr(mod, r'__doc__', None) | ||||
return fakelocals[modname] | return fakelocals[modname] | ||||
# keep in sync with "version" in C modules | # keep in sync with "version" in C modules | ||||
_cextversions = { | _cextversions = { | ||||
(r'cext', r'base85'): 1, | (r'cext', r'base85'): 1, | ||||
(r'cext', r'bdiff'): 2, | (r'cext', r'bdiff'): 3, | ||||
(r'cext', r'diffhelpers'): 1, | (r'cext', r'diffhelpers'): 1, | ||||
(r'cext', r'mpatch'): 1, | (r'cext', r'mpatch'): 1, | ||||
(r'cext', r'osutil'): 3, | (r'cext', r'osutil'): 3, | ||||
(r'cext', r'parsers'): 4, | (r'cext', r'parsers'): 4, | ||||
} | } | ||||
# map import request to other package or module | # map import request to other package or module | ||||
_modredirects = { | _modredirects = { |
'''), | '''), | ||||
]: | ]: | ||||
if re.search(plat, sys.platform) and cancompile(new_compiler(), code): | if re.search(plat, sys.platform) and cancompile(new_compiler(), code): | ||||
osutil_cflags.append('-DHAVE_%s' % macro) | osutil_cflags.append('-DHAVE_%s' % macro) | ||||
if sys.platform == 'darwin': | if sys.platform == 'darwin': | ||||
osutil_ldflags += ['-framework', 'ApplicationServices'] | osutil_ldflags += ['-framework', 'ApplicationServices'] | ||||
xdiff_srcs = [ | |||||
'mercurial/thirdparty/xdiff/xdiffi.c', | |||||
'mercurial/thirdparty/xdiff/xemit.c', | |||||
'mercurial/thirdparty/xdiff/xmerge.c', | |||||
'mercurial/thirdparty/xdiff/xprepare.c', | |||||
'mercurial/thirdparty/xdiff/xutils.c', | |||||
] | |||||
xdiff_headers = [ | |||||
'mercurial/thirdparty/xdiff/xdiff.h', | |||||
'mercurial/thirdparty/xdiff/xdiffi.h', | |||||
'mercurial/thirdparty/xdiff/xemit.h', | |||||
'mercurial/thirdparty/xdiff/xinclude.h', | |||||
'mercurial/thirdparty/xdiff/xmacros.h', | |||||
'mercurial/thirdparty/xdiff/xprepare.h', | |||||
'mercurial/thirdparty/xdiff/xtypes.h', | |||||
'mercurial/thirdparty/xdiff/xutils.h', | |||||
] | |||||
extmodules = [ | extmodules = [ | ||||
Extension('mercurial.cext.base85', ['mercurial/cext/base85.c'], | Extension('mercurial.cext.base85', ['mercurial/cext/base85.c'], | ||||
include_dirs=common_include_dirs, | include_dirs=common_include_dirs, | ||||
depends=common_depends), | depends=common_depends), | ||||
Extension('mercurial.cext.bdiff', ['mercurial/bdiff.c', | Extension('mercurial.cext.bdiff', ['mercurial/bdiff.c', | ||||
'mercurial/cext/bdiff.c'], | 'mercurial/cext/bdiff.c'] + xdiff_srcs, | ||||
include_dirs=common_include_dirs, | include_dirs=common_include_dirs, | ||||
depends=common_depends + ['mercurial/bdiff.h']), | depends=common_depends + ['mercurial/bdiff.h'] + xdiff_headers), | ||||
Extension('mercurial.cext.diffhelpers', ['mercurial/cext/diffhelpers.c'], | Extension('mercurial.cext.diffhelpers', ['mercurial/cext/diffhelpers.c'], | ||||
include_dirs=common_include_dirs, | include_dirs=common_include_dirs, | ||||
depends=common_depends), | depends=common_depends), | ||||
Extension('mercurial.cext.mpatch', ['mercurial/mpatch.c', | Extension('mercurial.cext.mpatch', ['mercurial/mpatch.c', | ||||
'mercurial/cext/mpatch.c'], | 'mercurial/cext/mpatch.c'], | ||||
include_dirs=common_include_dirs, | include_dirs=common_include_dirs, | ||||
depends=common_depends), | depends=common_depends), | ||||
Extension('mercurial.cext.parsers', ['mercurial/cext/charencode.c', | Extension('mercurial.cext.parsers', ['mercurial/cext/charencode.c', |
Calling PyList_Append() in tight loops can be a bit slow. It is faster to allocate an array of PyObject and then allocate a PyList of final size and call PyList_SET_ITEM to populate it. But we can optimize this later: this is definitely the easiest first implementation.