code: def _rerun_as_results(dset, revrange, since, branch, onto, message):
      """Represent the rerun as result records.
  
      In the standard case, the information in these results will be used to
      actually re-execute the commands.
      """
  
      try:
          results = _revrange_as_results(dset, revrange)
      except ValueError as exc:
          ce = CapturedException(exc)
          yield get_status_dict(
              "run", status="error", message=str(ce), exception=ce
          )
          return
  
      ds_repo = dset.repo
      # Drop any leading commits that don't have a run command. These would be
      # skipped anyways.
      results = list(dropwhile(lambda r: "run_info" not in r, results))
      if not results:
          yield get_status_dict(
              "run",
              status="impossible",
              ds=dset,
              message=("No run commits found in range %s", revrange),
          )
          return
  
      if onto is not None and onto.strip() == "":
          onto = results[0]["commit"] + "^"
  
      if onto and not ds_repo.commit_exists(onto):
          yield get_status_dict(
              "run",
              ds=dset,
              status="error",
              message=(
                  "Revision specified for --onto (%s) does not exist.",
                  onto,
              ),
          )
          return
  
      start_point = onto or "HEAD"
      if branch or onto:
          yield get_status_dict(
              "run",
              ds=dset,
              # Resolve this to the full hexsha so downstream code gets a
              # predictable form.
              commit=ds_repo.get_hexsha(start_point),
              branch=branch,
              rerun_action="checkout",
              status="ok",
          )
  
      def skip_or_pick(hexsha, result, msg):
          result["rerun_action"] = "skip-or-pick"
          shortrev = ds_repo.get_hexsha(hexsha, short=True)
          result["message"] = (
              "%s %s; %s",
              shortrev,
              msg,
              "skipping or cherry picking",
          )
  
      for res in results:
          hexsha = res["commit"]
          if "run_info" in res:
              rerun_dsid = res["run_info"].get("dsid")
              if rerun_dsid is not None and rerun_dsid != dset.id:
                  skip_or_pick(
                      hexsha, res, "was ran from a different dataset"
                  )
                  res["status"] = "impossible"
              else:
                  res["rerun_action"] = "run"
                  res["diff"] = diff_revision(dset, hexsha)
                  # This is the overriding message, if any, passed to this rerun.
                  res["rerun_message"] = message
          else:
              if len(res["parents"]) > 1:
                  res["rerun_action"] = "merge"
              else:
                  skip_or_pick(hexsha, res, "does not have a command")
          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 2 for calling a global function with example usage: _rerun_as_results(dset, revrange, since, branch, onto, message) without return types