##// END OF EJS Templates
fuzz: new fuzzer for cext/manifest.c...
fuzz: new fuzzer for cext/manifest.c This is a bit messy, because lazymanifest is tightly coupled to the cpython API for performance reasons. As a result, we have to build a whole Python without pymalloc (so ASAN can help us out) and link against that. Then we have to use an embedded Python interpreter. We could manually drive the lazymanifest in C from that point, but experimentally just using PyEval_EvalCode isn't really any slower so we may as well do that and write the innermost guts of the fuzzer in Python. Leak detection is currently disabled for this fuzzer because there are a few global-lifetime things in our extensions that we more or less intentionally leak and I didn't want to take the detour to work around that for now. This should not be pushed to our repo until https://github.com/google/oss-fuzz/pull/1853 is merged, as this depends on having the Python tarball around. Differential Revision: https://phab.mercurial-scm.org/D4879

File last commit:

r39827:1dd82ecb default
r40089:8c692a6b default
Show More
simplemerge
84 lines | 2.5 KiB | text/plain | TextLexer
Alexis S. L. Carvalho
actually port simplemerge to hg...
r4363 #!/usr/bin/env python
Augie Fackler
simplemerge: update to conform with modern import conventions
r33896 from __future__ import absolute_import
Alexis S. L. Carvalho
Import 3-way merge code from bzr...
r4362
Pulkit Goyal
fancyopts: switch from fancyopts.getopt.* to getopt.*...
r30576 import getopt
Simon Heimberg
cleanup: drop unused variables and an unused import
r19378 import sys
Augie Fackler
simplemerge: update to conform with modern import conventions
r33896
import hgdemandimport
hgdemandimport.enable()
Alexis S. L. Carvalho
actually port simplemerge to hg...
r4363 from mercurial.i18n import _
Augie Fackler
simplemerge: update to conform with modern import conventions
r33896 from mercurial import (
Phil Cohen
context: add arbitraryfilectx, which can represent files outside the workdir...
r34053 context,
Augie Fackler
simplemerge: update to conform with modern import conventions
r33896 error,
fancyopts,
Pulkit Goyal
py3: use pycompat.strkwargs() in contrib/simplemerge...
r39827 pycompat,
Augie Fackler
simplemerge: update to conform with modern import conventions
r33896 simplemerge,
ui as uimod,
Yuya Nishihara
procutil: bulk-replace function calls to point to new module
r37138 )
from mercurial.utils import (
procutil,
Augie Fackler
simplemerge: update to conform with modern import conventions
r33896 )
Alexis S. L. Carvalho
Import 3-way merge code from bzr...
r4362
Pulkit Goyal
py3: add b'' prefixes in contrib/simplemerge...
r39826 options = [(b'L', b'label', [], _(b'labels to use on conflict markers')),
(b'a', b'text', None, _(b'treat all files as text')),
(b'p', b'print', None,
_(b'print results instead of overwriting LOCAL')),
(b'', b'no-minimal', None, _(b'no effect (DEPRECATED)')),
(b'h', b'help', None, _(b'display help and exit')),
(b'q', b'quiet', None, _(b'suppress output'))]
Alexis S. L. Carvalho
polish the simplemerge command; add a test
r4364
usage = _('''simplemerge [OPTS] LOCAL BASE OTHER
Simple three-way file merge utility with a minimal feature set.
Thomas Arendsen Hein
Remove trailing spaces
r5081
Alexis S. L. Carvalho
polish the simplemerge command; add a test
r4364 Apply to LOCAL the changes necessary to go from BASE to OTHER.
Thomas Arendsen Hein
Remove trailing spaces
r5081
Alexis S. L. Carvalho
polish the simplemerge command; add a test
r4364 By default, LOCAL is overwritten with the results of this operation.
''')
Matt Mackall
merge: move the bulk of simplemerge into core...
r6002 class ParseError(Exception):
"""Exception raised on errors in parsing the command line."""
Alexis S. L. Carvalho
polish the simplemerge command; add a test
r4364 def showhelp():
sys.stdout.write(usage)
Pulkit Goyal
py3: add b'' prefixes in contrib/simplemerge...
r39826 sys.stdout.write(b'\noptions:\n')
Alexis S. L. Carvalho
Import 3-way merge code from bzr...
r4362
Alexis S. L. Carvalho
polish the simplemerge command; add a test
r4364 out_opts = []
for shortopt, longopt, default, desc in options:
Pulkit Goyal
py3: add b'' prefixes in contrib/simplemerge...
r39826 out_opts.append((b'%2s%s' % (shortopt and b'-%s' % shortopt,
longopt and b' --%s' % longopt),
b'%s' % desc))
Alexis S. L. Carvalho
polish the simplemerge command; add a test
r4364 opts_len = max([len(opt[0]) for opt in out_opts])
for first, second in out_opts:
Pulkit Goyal
py3: add b'' prefixes in contrib/simplemerge...
r39826 sys.stdout.write(b' %-*s %s\n' % (opts_len, first, second))
Alexis S. L. Carvalho
polish the simplemerge command; add a test
r4364
Matt Mackall
merge: move the bulk of simplemerge into core...
r6002 try:
Patrick Mezard
tests: Windows compatibility fixes...
r7080 for fp in (sys.stdin, sys.stdout, sys.stderr):
Yuya Nishihara
procutil: bulk-replace function calls to point to new module
r37138 procutil.setbinary(fp)
Mads Kiilerich
tests: run check-code on Python files without .py extension
r19022
Matt Mackall
merge: move the bulk of simplemerge into core...
r6002 opts = {}
Alexis S. L. Carvalho
polish the simplemerge command; add a test
r4364 try:
Matt Mackall
merge: move the bulk of simplemerge into core...
r6002 args = fancyopts.fancyopts(sys.argv[1:], options, opts)
Pulkit Goyal
fancyopts: switch from fancyopts.getopt.* to getopt.*...
r30576 except getopt.GetoptError as e:
Matt Mackall
merge: move the bulk of simplemerge into core...
r6002 raise ParseError(e)
Pulkit Goyal
py3: add b'' prefixes in contrib/simplemerge...
r39826 if opts[b'help']:
Alexis S. L. Carvalho
polish the simplemerge command; add a test
r4364 showhelp()
Matt Mackall
merge: move the bulk of simplemerge into core...
r6002 sys.exit(0)
if len(args) != 3:
Pulkit Goyal
py3: add b'' prefixes in contrib/simplemerge...
r39826 raise ParseError(_(b'wrong number of arguments'))
Phil Cohen
contrib: make simplemerge script pass context-like objects...
r33904 local, base, other = args
sys.exit(simplemerge.simplemerge(uimod.ui.load(),
Phil Cohen
context: add arbitraryfilectx, which can represent files outside the workdir...
r34053 context.arbitraryfilectx(local),
context.arbitraryfilectx(base),
context.arbitraryfilectx(other),
Pulkit Goyal
py3: use pycompat.strkwargs() in contrib/simplemerge...
r39827 **pycompat.strkwargs(opts)))
FUJIWARA Katsunori
misc: use modern exception syntax...
r28047 except ParseError as e:
Pulkit Goyal
py3: add b'' prefixes in contrib/simplemerge...
r39826 sys.stdout.write(b"%s: %s\n" % (sys.argv[0], e))
Matt Mackall
merge: move the bulk of simplemerge into core...
r6002 showhelp()
sys.exit(1)
FUJIWARA Katsunori
misc: use modern exception syntax...
r28047 except error.Abort as e:
Pulkit Goyal
py3: add b'' prefixes in contrib/simplemerge...
r39826 sys.stderr.write(b"abort: %s\n" % e)
Matt Mackall
merge: move the bulk of simplemerge into core...
r6002 sys.exit(255)
except KeyboardInterrupt:
sys.exit(255)