class_docstr: Re-execute previous `datalad run` commands.
  
  This will unlock any dataset content that is on record to have
  been modified by the command in the specified revision.  It will
  then re-execute the command in the recorded path (if it was inside
  the dataset). Afterwards, all modifications will be saved.
  
  *Report mode*
  
  || REFLOW >>
  When called with [CMD: --report CMD][PY: report=True PY], this command
  reports information about what would be re-executed as a series of records.
  There will be a record for each revision in the specified revision range.
  Each of these will have one of the following "rerun_action" values:
  << REFLOW ||
  
    - run: the revision has a recorded command that would be re-executed
    - skip-or-pick: the revision does not have a recorded command and would
      be either skipped or cherry picked
    - merge: the revision is a merge commit and a corresponding merge would
      be made
  
  The decision to skip rather than cherry pick a revision is based on whether
  the revision would be reachable from HEAD at the time of execution.
  
  In addition, when a starting point other than HEAD is specified, there is a
  rerun_action value "checkout", in which case the record includes
  information about the revision the would be checked out before rerunning
  any commands.
  
  .. note::
    Currently the "onto" feature only sets the working tree of the current
    dataset to a previous state. The working trees of any subdatasets remain
    unchanged.
class_docstr_tok: ["Re-execute","previous","`","datalad","run","`","commands",".","This","will","unlock","any","dataset","content","that","is","on","record","to","have","been","modified","by","the","command","in","the","specified","revision",".","It","will","then","re-execute","the","command","in","the","recorded","path","(","if","it","was","inside","the","dataset",")",".","Afterwards",",","all","modifications","will","be","saved",".","*","Report","mode","*","||","REFLOW",">",">","When","called","with","[","CMD",":","--","report","CMD","]","[","PY",":","report=True","PY","]",",","this","command","reports","information","about","what","would","be","re-executed","as","a","series","of","records",".","There","will","be","a","record","for","each","revision","in","the","specified","revision","range",".","Each","of","these","will","have","one","of","the","following","``","rerun_action","''","values",":","<","<","REFLOW","||","-","run",":","the","revision","has","a","recorded","command","that","would","be","re-executed","-","skip-or-pick",":","the","revision","does","not","have","a","recorded","command","and","would","be","either","skipped","or","cherry","picked","-","merge",":","the","revision","is","a","merge","commit","and","a","corresponding","merge","would","be","made","The","decision","to","skip","rather","than","cherry","pick","a","revision","is","based","on","whether","the","revision","would","be","reachable","from","HEAD","at","the","time","of","execution",".","In","addition",",","when","a","starting","point","other","than","HEAD","is","specified",",","there","is","a","rerun_action","value","``","checkout","''",",","in","which","case","the","record","includes","information","about","the","revision","the","would","be","checked","out","before","rerunning","any","commands",".","..","note",":",":","Currently","the","``","onto","''","feature","only","sets","the","working","tree","of","the","current","dataset","to","a","previous","state",".","The","working","trees","of","any","subdatasets","remain","unchanged","."]
code: def __call__(
      revision=None,
      *,
      since=None,
      dataset=None,
      branch=None,
      message=None,
      onto=None,
      script=None,
      report=False,
      assume_ready=None,
      explicit=False,
      jobs=None,
  ):
      ds = require_dataset(
          dataset, check_installed=True, purpose="rerun a command"
      )
      ds_repo = ds.repo
  
      lgr.debug("rerunning command output underneath %s", ds)
  
      if script is None and not (report or explicit) and ds_repo.dirty:
          yield get_status_dict(
              "run",
              ds=ds,
              status="impossible",
              message=(
                  "clean dataset required to detect changes from command; "
                  "use `datalad status` to inspect unsaved changes"
              ),
          )
          return
  
      if not ds_repo.get_hexsha():
          yield get_status_dict(
              "run",
              ds=ds,
              status="impossible",
              message="cannot rerun command, nothing recorded",
          )
          return
  
      # ATTN: Use get_corresponding_branch() rather than is_managed_branch()
      # for compatibility with a plain GitRepo.
      if (
          onto is not None or branch is not None
      ) and ds_repo.get_corresponding_branch():
          yield get_status_dict(
              "run",
              ds=ds,
              status="impossible",
              message=(
                  "--%s is incompatible with adjusted branch",
                  "branch" if onto is None else "onto",
              ),
          )
          return
  
      if branch and branch in ds_repo.get_branches():
          yield get_status_dict(
              "run",
              ds=ds,
              status="error",
              message="branch '{}' already exists".format(branch),
          )
          return
  
      if revision is None:
          revision = (
              ds_repo.get_corresponding_branch()
              or ds_repo.get_active_branch()
              or "HEAD"
          )
  
      if not ds_repo.commit_exists(revision + "^"):
          # Only a single commit is reachable from `revision`.  In
          # this case, --since has no effect on the range construction.
          revrange = revision
      elif since is None:
          revrange = "{rev}^..{rev}".format(rev=revision)
      elif since.strip() == "":
          revrange = revision
      else:
          revrange = "{}..{}".format(since, revision)
  
      results = _rerun_as_results(
          ds, revrange, since, branch, onto, message
      )
      if script:
          handler = _get_script_handler(script, since, revision)
      elif report:
          handler = _report
      else:
          handler = partial(
              _rerun,
              assume_ready=assume_ready,
              explicit=explicit,
              jobs=jobs,
          )
  
      for res in handler(ds, results):
          yield res
  
imports: import json
  import logging
  import os.path
  import re
  import sys
  from copy import copy
  from functools import partial
  from itertools import dropwhile
  from datalad.consts import PRE_INIT_COMMIT_SHA
  from datalad.core.local.run import _format_cmd_shorty, assume_ready_opt, format_command, run_command
  from datalad.distribution.dataset import EnsureDataset, datasetmethod, require_dataset
  from datalad.interface.base import Interface, build_doc, eval_results
  from datalad.interface.results import get_status_dict
  from datalad.interface.common_opts import jobs_opt
  from datalad.support.constraints import EnsureNone, EnsureStr
  from datalad.support.exceptions import CapturedException
  from datalad.support.json_py import load_stream
  from datalad.support.param import Parameter
label_desc: Use image node_id 1 for calling the Rerun obj's underlying member method code with example usage: obj.__call__(revision) without return types