hasWork
Whether branch has work into doesn't: a name it changed since the two parted (its code, or how it reads) that
into doesn't have as it does. Its history being part of into's says no at once; a branch landed with
--squash isn't (its entries stay its own), but what it changed is there.
import type { Codebase } from "#codebase/tcmts/cli/codebase"; export function hasWork(cb: Codebase, branch: string, into: string): boolean { const head = cb.store.head(branch); const target = cb.store.head(into); if (cb.store.isAncestor(head, target)) return false; const named = (causal: string) => { const by = new Map<string, string[]>(); for (const n of cb.store.namespaceRows(cb.store.causal(causal)!.namespace)) by.set(n.path, [...(by.get(n.path) ?? []), `${n.hash}:${n.text ?? ""}`]); return new Map([...by].map(([path, hs]) => [path, hs.sort().join(" ")])); }; const mine = named(head); const base = named(cb.store.mergeBase(head, target)); const theirs = named(target); return [...new Set([...mine.keys(), ...base.keys()])].some( (path) => mine.get(path) !== base.get(path) && mine.get(path) !== theirs.get(path), ); }