Mercurial > hg
annotate contrib/fuzz/revlog_corpus.py @ 42580:eb7bd7d64a9d
merge with stable
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 09 Jul 2019 10:09:46 -0400 |
parents | c06f0ef9a5ba |
children | 2372284d9457 |
rev | line source |
---|---|
41014
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 from __future__ import absolute_import, print_function |
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 |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 reporoot = os.path.normpath(os.path.join(os.path.dirname(__file__), |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
12 '..', '..')) |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 # typically a standalone index |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
14 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
|
15 # 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
|
16 contributing = os.path.join( |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 reporoot, '.hg', 'store', 'data', 'contrib', 'fuzz', 'mpatch.cc.i') |
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 print(changelog, os.path.exists(changelog)) |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 print(contributing, os.path.exists(contributing)) |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 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
|
23 if os.path.exists(changelog): |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 with open(changelog) as f: |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 zf.writestr("00changelog.i", f.read()) |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
26 if os.path.exists(contributing): |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
27 with open(contributing) as f: |
c06f0ef9a5ba
fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 zf.writestr("contributing.i", f.read()) |