contrib/fuzz/revlog_corpus.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Thu, 07 Mar 2024 04:15:23 +0100
changeset 51536 718f28ea3af4
parent 48875 6000f5b25c9b
permissions -rw-r--r--
branchcache: add a "pure topological head" fast path In a narrow but actually quick common case, all topological heads are all on the same branch and all open. In this case, computing the branch map is very simple. We can quickly detect situation where this situation will not change. So we update the V3 format to be able to express this situation and upgrade the update code to detect we remains in that mode. The branch cache is populated with the actual value when the branch map is accessed, but the update_disk method can do the update without needing to populate it.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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())