Mercurial > hg
annotate contrib/fuzz/revlog_corpus.py @ 45100:d50d922ca02b
debuginstall: don't translate encoding messages
While Microsoft trained us to read mojibake text, it doesn't make sense
to print mojibake messages when debugging the exact issue.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 09 Jul 2020 19:16:52 +0900 |
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()) |