printTextMerge

tcmts.cli.merge.printTextMerge · #aqxiih4x · term · runs on the server

uses tcmts.cli.style.yellow, which uses node:util

What merging text versions (mergeTexts) couldn't do, said after a merge's (or a revert's) diff.

import { keyPath } from "#codebase/tcmts/cli/diff";
import type { NameState } from "#codebase/tcmts/cli/diff";
import { bold, dim, yellow } from "#codebase/tcmts/cli/style";
import { shortHash } from "#codebase/tcmts/core/hash";

export function printTextMerge(
  r: { conflicts: string[]; lost: string[] },
  states: { ours: NameState; theirs: NameState; merged: NameState },
  labels: { ours: string; theirs: string },
): void {
  const at = (h: string, ...in_: NameState[]) =>
    [
      ...new Set(in_.flatMap((s) => [...s].filter(([, hs]) => hs.has(h)).map(([k]) => keyPath(k)))),
    ].join(", ") || shortHash(h);
  for (const h of r.conflicts)
    console.log(
      `${yellow("  kept")} ${bold(at(h, states.merged))} ${dim(`as ${labels.ours} writes it: its comments or doc changed on both sides (\`tcm edit\` it to combine them)`)}`,
    );
  for (const h of r.lost)
    console.log(
      `${yellow("  dropped")} ${bold(at(h, states.ours, states.theirs))} ${dim("a change to its comments or doc: the other side changed its code, or removed it (`tcm edit` it to write it again)")}`,
    );
}

uses

used by