annotate contrib/fuzz/revlog_corpus.py @ 49070:137a93125902

rhg: refactor to pass argv down, instead of caling args_os() This refactoring makes it easy to patch some command-line preprocessing into rhg. We use this to support using rhg as a shebang interpreter, for example. Differential Revision: https://phab.mercurial-scm.org/D12543
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Tue, 12 Apr 2022 20:01:49 +0100
parents 6000f5b25c9b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
41014
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
1 import argparse
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
2 import os
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
3 import zipfile
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
4
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
5 ap = argparse.ArgumentParser()
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
6 ap.add_argument("out", metavar="some.zip", type=str, nargs=1)
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
7 args = ap.parse_args()
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
8
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41014
diff changeset
9 reporoot = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..'))
41014
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
10 # typically a standalone index
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
11 changelog = os.path.join(reporoot, '.hg', 'store', '00changelog.i')
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
12 # an inline revlog with only a few revisions
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
13 contributing = os.path.join(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41014
diff changeset
14 reporoot, '.hg', 'store', 'data', 'contrib', 'fuzz', 'mpatch.cc.i'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41014
diff changeset
15 )
41014
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
16
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
17 with zipfile.ZipFile(args.out[0], "w", zipfile.ZIP_STORED) as zf:
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
18 if os.path.exists(changelog):
43836
ba84a1ae4ae5 fuzz: fix test-fuzz-targets.t to run with python3
Kyle Lippincott <spectral@google.com>
parents: 43808
diff changeset
19 with open(changelog, 'rb') as f:
41014
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
20 zf.writestr("00changelog.i", f.read())
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
21 if os.path.exists(contributing):
43836
ba84a1ae4ae5 fuzz: fix test-fuzz-targets.t to run with python3
Kyle Lippincott <spectral@google.com>
parents: 43808
diff changeset
22 with open(contributing, 'rb') as f:
41014
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
23 zf.writestr("contributing.i", f.read())