contrib/fuzz/revlog_corpus.py
author Pulkit Goyal <7895pulkit@gmail.com>
Mon, 18 Jan 2021 21:37:20 +0530
changeset 46332 25be21ec6c65
parent 43854 ba84a1ae4ae5
child 48966 6000f5b25c9b
permissions -rw-r--r--
share: rework config options to be much clearer and easier Recently I implemented various boolean configs which control how to behave when there is a share-safe mismatch between source and share repository. Mismatch means that source supports share-safe where as share does not or vice versa. However, while discussion and documentation we realized that it's too complicated and there are some combinations of values which makes no sense. We decided to introduce a config option with 4 possible values which makes controlling and understanding things easier. The config option `share.safe-mismatch.source-{not-}safe` can have following 4 values: * abort (default): error out if there is mismatch * allow: allow to work with respecting share source configuration * {up|down}grade-abort: try to {up|down}grade, if it fails, abort * {up|down}grade-allow: try to {up|down}grade, if it fails, continue in allow mode I am not sure if I can explain 3 config options which I deleted right now in just 5 lines which is a sign of how complex they became. No test changes demonstrate that functionality is same, only names have changed. Differential Revision: https://phab.mercurial-scm.org/D9785
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43826
54a6846ba96f fuzz: remove debug prints from revlog_corpus.py
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
     1
from __future__ import absolute_import
41024
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: 41024
diff changeset
    11
reporoot = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..'))
41024
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: 41024
diff changeset
    16
    reporoot, '.hg', 'store', 'data', 'contrib', 'fuzz', 'mpatch.cc.i'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41024
diff changeset
    17
)
41024
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):
43854
ba84a1ae4ae5 fuzz: fix test-fuzz-targets.t to run with python3
Kyle Lippincott <spectral@google.com>
parents: 43826
diff changeset
    21
        with open(changelog, 'rb') as f:
41024
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):
43854
ba84a1ae4ae5 fuzz: fix test-fuzz-targets.t to run with python3
Kyle Lippincott <spectral@google.com>
parents: 43826
diff changeset
    24
        with open(contributing, 'rb') as f:
41024
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())