testConflictedDefinitionsAreRederived
Both definitions of a conflicted name are re-derived against what the merge names, as all code is: the other side's uses this side's replacement for what it used, once that's re-derived itself (here against the other side's change to what it uses, with a new signature), not a version in between that nothing names.
import { okIn, tcmIn, 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 testConflictedDefinitionsAreRederived = () => { const dir = tempDir("merge candidates"); const tcm = (...args: string[]) => okIn(dir, ...args); const update = (code: string) => { fs.writeFileSync(path.join(dir, "scratch.ts"), `// tcm: namespace lib\n${code}\n`); tcm("update"); }; tcm("init"); update(`export const util = (a: number): number => a; export const save = (a: number): number => util(a) + 1; export const dispatch = (n: number): string => \`\${save(n)}\`;`); tcm("branch", "s"); tcm("switch", "s"); update(`import { util } from "#codebase/lib"; export const save = (a: number): number => util(a) + 2; export const dispatch = (n: number): string => \`\${save(n)}!\`;`); tcm("switch", "main"); update(`import { save } from "#codebase/lib"; export const util = (a: number, b = 10): number => a * b; export const dispatch = (n: number): string => \`[\${save(n)}]\`;`); tcm("switch", "s"); const merged = tcmIn(dir, "merge", "main"); assert.equal(merged.status, 1, merged.out); assert.match(merged.out, /conflict lib\.dispatch/); const todo = tcm("todo"); assert.match(todo, /conflict lib\.dispatch/); assert.doesNotMatch(todo, /unnamed version/, todo); }