~amirouche/mutation

2621bbede1e1b14477e1b8fcf40eda87c6905f16 — Amirouche 8 months ago 6463aa2
add 'mutation apply UID'.
1 files changed, 17 insertions(+), 1 deletions(-)

M mutation.py
M mutation.py => mutation.py +17 -1
@@ 3,8 3,8 @@
Usage:
  mutation play [--verbose] [--exclude=<globs>] [--only-deadcode-detection] [--include=<globs>] [--sampling=<s>] [--randomly-seed=<n>] [--max-workers=<n>] [<file-or-directory> ...] [-- TEST-COMMAND ...]
  mutation replay
  mutation show failed
  mutation show MUTATION
  mutation apply MUTATION
  mutation (-h | --help)
  mutation --version



@@ 983,6 983,18 @@ def mutation_show(uid):
    diff_highlight(diff)


def mutation_apply(uid):
    uid = UUID(hex=uid)
    with database_open(".") as db:
        path, diff = lexode.unpack(db[lexode.pack([1, uid])])
    diff = zstd.decompress(diff).decode("utf8")
    with open(path, 'r') as f:
        source = f.read()
    patched = patch(diff, source)
    with open(path, 'w') as f:
        f.write(patched)


def main():
    arguments = docopt(__doc__, version=__version__)



@@ 1008,6 1020,10 @@ def main():
        mutation_show(arguments["MUTATION"])
        sys.exit(0)

    if arguments.get("apply", False):
        mutation_show(arguments["MUTATION"])
        sys.exit(0)

    loop = asyncio.get_event_loop()
    loop.run_until_complete(play(loop, arguments))
    loop.close()