contrib/fuzz/mpatch_corpus.py
changeset 38248 99ab72b867b7
parent 38247 06e2fc08f6f0
child 38303 1fb2510cf8c8
equal deleted inserted replaced
38247:06e2fc08f6f0 38248:99ab72b867b7
     1 from __future__ import absolute_import
     1 from __future__ import absolute_import, print_function
     2 
     2 
     3 import argparse
     3 import argparse
     4 import struct
     4 import struct
     5 import zipfile
     5 import zipfile
       
     6 
       
     7 from mercurial import (
       
     8     hg,
       
     9     ui as uimod,
       
    10 )
     6 
    11 
     7 ap = argparse.ArgumentParser()
    12 ap = argparse.ArgumentParser()
     8 ap.add_argument("out", metavar="some.zip", type=str, nargs=1)
    13 ap.add_argument("out", metavar="some.zip", type=str, nargs=1)
     9 args = ap.parse_args()
    14 args = ap.parse_args()
    10 
    15 
    57     zf.writestr(
    62     zf.writestr(
    58         "one_delta_ends_late",
    63         "one_delta_ends_late",
    59         str(corpus('a', [delta([deltafrag(0, 20, 'b')])]))
    64         str(corpus('a', [delta([deltafrag(0, 20, 'b')])]))
    60     )
    65     )
    61 
    66 
       
    67     try:
       
    68         # Generated from repo data
       
    69         r = hg.repository(uimod.ui(), '../..')
       
    70         fl = r.file('mercurial/manifest.py')
       
    71         rl = getattr(fl, '_revlog', fl)
       
    72         bins = rl._chunks(rl._deltachain(10)[0])
       
    73         zf.writestr('manifest_py_rev_10',
       
    74                     str(corpus(bins[0], bins[1:])))
       
    75     except: # skip this, so no re-raises
       
    76         print('skipping seed file from repo data')
    62     # Automatically discovered by running the fuzzer
    77     # Automatically discovered by running the fuzzer
    63     zf.writestr(
    78     zf.writestr(
    64         "mpatch_decode_old_overread", "\x02\x00\x00\x00\x02\x00\x00\x00"
    79         "mpatch_decode_old_overread", "\x02\x00\x00\x00\x02\x00\x00\x00"
    65     )
    80     )
    66     zf.writestr(
    81     zf.writestr(