entryChanges

tcmts.cli.changes.entryChanges · #jtf5rzmv · term · runs anywhere

What a history entry changed (from the entry before it on its branch).

import { namesChanged, stateAt } from "#codebase/tcmts/cli/changes";
import type { NameChange, NamesFrom } from "#codebase/tcmts/cli/changes";
import type { Codebase } from "#codebase/tcmts/cli/codebase";

export function entryChanges(
  cb: Codebase,
  hash: string,
  viewUri: (hash: string, names: NamesFrom) => string,
): NameChange[] {
  const c = cb.store.causal(hash);
  if (!c?.parents.length) return [];
  const parent = c.parents[0]!;
  return namesChanged(cb, stateAt(cb, parent), stateAt(cb, hash), (h, side) =>
    viewUri(h, { at: side === "before" ? parent : hash }),
  );
}

uses

used by