Mercurial > hg
annotate contrib/fuzz/revlog_corpus.py @ 47643:11f834e7177d
pyoxidizer: add hooks to inject extra python packages and install files
We need this type of hook to inject our internal extension and resource files
at Google. Presumably this could be useful to others, so instead of trying to
carry an internal patch we've done this in a modular way that should be of
value upstream.
I'm extremely puzzled by the behavior of glob() on Windows, and I'll
be filing at least one (probably two) bugs upstream about it.
Differential Revision: https://phab.mercurial-scm.org/D11092
author | Augie Fackler <augie@google.com> |
---|---|
date | Mon, 12 Jul 2021 15:56:25 -0400 |
parents | ba84a1ae4ae5 |
children | 6000f5b25c9b |
rev | line source |
---|---|
43808
54a6846ba96f
fuzz: remove debug prints from revlog_corpus.py
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1 from __future__ import absolute_import |
41014
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 import argparse |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 import os |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 import zipfile |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 ap = argparse.ArgumentParser() |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 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
|
9 args = ap.parse_args() |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41014
diff
changeset
|
11 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
|
12 # typically a standalone index |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 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
|
14 # 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
|
15 contributing = os.path.join( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41014
diff
changeset
|
16 reporoot, '.hg', 'store', 'data', 'contrib', 'fuzz', 'mpatch.cc.i' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41014
diff
changeset
|
17 ) |
41014
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 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
|
20 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
|
21 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
|
22 zf.writestr("00changelog.i", f.read()) |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 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
|
24 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
|
25 zf.writestr("contributing.i", f.read()) |