testRevertUndoesOneLanding
A branch landed with --no-fast-forward is one history entry, though main could have fast-forwarded; tcm revert
undoes it whole, and nothing done on main since.
import { okIn, tempDir } from "#codebase/tcmts/cli/test/e2e/harness"; import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; export const testRevertUndoesOneLanding = () => { const dir = tempDir("revert"); const tcm = (...args: string[]) => okIn(dir, ...args); const scratch = (text: string) => fs.writeFileSync(path.join(dir, "scratch.ts"), text); tcm("init"); scratch( `// tcm: namespace lib\nexport const square = (x: number): number => x * x;\nexport const label = "squares";\n`, ); tcm("add"); tcm("branch", "feature"); tcm("switch", "feature"); scratch( `// tcm: namespace lib\nexport const square = (x: number): number => x ** 2;\nexport const cube = (x: number): number => x ** 3;\n`, ); tcm("update"); scratch(`// tcm: namespace lib\nexport const half = (x: number): number => x / 2;\n`); tcm("add"); // landed as one entry, with both histories in it tcm("switch", "main"); assert.match(tcm("merge", "feature", "--no-fast-forward"), /merged feature into main/); assert.match(tcm("history", "1"), /merge feature\s+merged #?[a-z2-7]+/); assert.match(tcm("ls", "lib"), /lib\.cube[\s\S]*lib\.half/); // later work on main, then the landing undone: only what it changed goes back scratch(`// tcm: namespace lib\nexport const label = "powers";\n`); tcm("update"); assert.match(tcm("revert", "1"), /reverted #?[a-z2-7]+ \(merge feature\)[\s\S]*reverted cleanly/); const ls = tcm("ls", "lib"); assert.doesNotMatch(ls, /lib\.cube|lib\.half/); assert.match(tcm("view", "lib.square"), /x \* x/); assert.match(tcm("view", "lib.label"), /powers/); // a new entry on top: the landing is still in the history assert.match(tcm("history", "3"), /revert #[a-z2-7]+[\s\S]*update[\s\S]*merge feature/); }