Lines 28–39 at 318 (were 28–38 at 28)
2828import { byWhom } from "./history-answers.ts"; 2929import { applyMode, PLAIN, readKnownModes, writeKnownModes } from "./modes.ts"; 3030import { refusedText, screenAnswer } from "./safety.ts"; 31+import { refusalText, withoutArg, withoutHeading } from "./without.ts"; 32−/** The space to read: --draft (where "shared" means shared), else the one this agent is in. */
33+/** The space to read: --draft (where "shared" means shared), else the one this agent is in (shared, in a folder with no agent). */ 3334function space(args: Parsed, agent: string): Where { 3435 const named = str(args, "draft"); 35− if (named === undefined) return { agent };
36+ if (named === undefined) return agent === "" ? { draft: null } : { agent }; 3637 return { draft: named === "shared" ? null : named }; Lines 88–94 at 318 (were 87–93 at 28)
90− ? `Your view holds ${what}: ${spaceName(answer.draft)} at version ${answer.version}, with your unpublished changes.${missing.size > 0 ? ` ${missing.size} of them ${missing.size === 1 ? "is" : "are"} missing from this folder (abso sync --full writes them).` : ""}`
91+ ? `Your view holds ${what}: ${spaceName(answer.draft)} at version ${answer.version}, with your unpushed changes.${missing.size > 0 ? ` ${missing.size} of them ${missing.size === 1 ? "is" : "are"} missing from this folder (abso pull --full writes them).` : ""}` 9192 : `${spaceName(answer.draft)} at version ${answer.version} holds ${what}.`, 9293 ...files.map((f) => (missing.has(f) ? `${f} (missing from this folder)` : f)), Lines 142–166 at 318 (were 141–146 at 28)
141142 .filter((p) => only.length > 1 || !existsHere(root, p)) 142143 .map((p) => nothingAt(root, p)); 145+ // --agent: someone else's draft, to review it. What they've recorded, not their folder; nothing here is recorded. 146+ const other = str(args, "agent"); 147+ if (other !== undefined) { 148+ if (between || str(args, "draft") !== undefined) 149+ throw new UsageError("--agent shows that agent's unpushed changes: abso diff [file...] --agent <name>"); 150+ const answer = await api.diffOf(other); 151+ const files = pick(answer.files); 152+ const d = diffs(files); 153+ const where = `${spaceName(answer.draft)}${answer.base === null ? "" : ` (on version ${answer.base})`}`; 156+ ? `${other} has no recorded, unpushed changes${inPaths(only, "to")} in ${where}.` 157+ : `${other}'s recorded, unpushed changes${inPaths(only, "to")} in ${where}: ${totals(files)}.`; 159+ text: [head, ...d.text].join("\n"), 160+ json: { agent: other, draft: answer.draft, base: answer.base, files: d.json, unmatched: unmatched(files) }, 145165 const from = version(words[0]!); 146166 const to = version(words[1]!); Lines 180–186 at 318 (were 160–166 at 28)
161181 if (str(args, "draft") !== undefined) 162182 throw new UsageError( 163− "--draft goes with two versions (abso diff <from> <to>); abso diff alone shows your own unpublished changes",
183+ "--draft goes with two versions (abso diff <from> <to>); abso diff alone shows your own unpushed changes", 165185 // Folder-only edits count as unpublished changes too. 166186 const recorded = await recordFolder(root, api); Lines 190–197 at 318 (were 170–177 at 28)
170190 const where = `${spaceName(answer.draft)}${answer.base === null ? "" : ` (on version ${answer.base})`}`; 172192 files.length === 0 173− ? `No unpublished changes${inPaths(only, "to")} in ${where}.`
174− : `Your unpublished changes${inPaths(only, "to")} in ${where}: ${totals(files)}.`;
193+ ? `No unpushed changes${inPaths(only, "to")} in ${where}.` 194+ : `Your unpushed changes${inPaths(only, "to")} in ${where}: ${totals(files)}.`; 175195 const pre = recordedFirst(recorded); 177197 text: [...pre, head, ...notes(files), ...d.text].join("\n"), Lines 288–294 at 318 (were 268–274 at 28)
268288 if (v.drops && v.drops.length > 0) 269289 out.push(` drops ${v.drops.length === 1 ? "version" : "versions"} ${v.drops.join(", ")}`); 270290 if (v.droppedIn !== undefined) out.push(` dropped in version ${v.droppedIn}: shared no longer has these changes`); 271− if (v.originalMessage !== undefined) out.push(` amended; first published as: ${v.originalMessage}`);
291+ if (v.originalMessage !== undefined) out.push(` amended; first pushed as: ${v.originalMessage}`); Lines 426–474 at 318 (were 406–411 at 28)
406426 return { text: lines.join("\n"), json: { ...answer } }; 429+/** abso show <version>[:<file>] --without <versions>: what differs with them left out, or that file then. */ 430+async function showWithout( 436+ leave: readonly number[], 438+ if ("draft" in where && where.draft !== null) throw new UsageError("--without reads shared, not a named draft"); 439+ const colon = word.indexOf(":"); 440+ const v = version(colon >= 0 ? word.slice(0, colon) : word); 441+ const path = colon >= 0 ? fileArg(root, cwd, word.slice(colon + 1)) : undefined; 442+ const answer = await api.without(v, leave); 446+ text: refusalText(answer, (vs) => `abso show ${word} --without ${vs.join(",")}`), 447+ json: { ...answer }, 449+ if (path !== undefined) { 450+ const file = answer.files.find((f) => f.path === path); 451+ if (file === undefined) { 452+ const same = await api.fileAt(path, v, { draft: null }); 453+ if (same.text !== null) return { text: same.text, json: { ...same, without: answer.without } }; 454+ } else if (file.after !== null) return { text: file.after, json: { ...file, without: answer.without } }; 457+ text: `${path} isn't in version ${v} of shared without them.`, 458+ json: { path, version: v, without: answer.without }, 461+ const changed = pairRenames(answer.files); 462+ const d = diffs(changed); 464+ ...withoutHeading(answer), 465+ changed.length === 0 ? `No file differs from version ${v}.` : `Compared with version ${v}: ${totals(changed)}.`, 466+ `The files hash to ${answer.tree}; the same ask gives the same hash. Shared doesn't change.`, 469+ return { text: lines.join("\n"), json: { ...answer, files: d.json } }; 409472export async function runShow(args: Parsed, env: Env): Promise<Output> { 410473 if (args.positionals.length !== 1) 411474 throw new UsageError("show takes one version: abso show <version> or abso show <version>:<file>"); Lines 476–483 at 318 (were 413–418 at 28)
413476 const word = args.positionals[0]!; 414477 const colon = word.indexOf(":"); 415478 const where = space(args, config.agent); 479+ const leave = withoutArg(args); 480+ if (leave !== undefined) return showWithout(api, root, env.cwd, word, where, leave); 418483 const v = version(word.slice(0, colon)); Lines 507–513 at 318 (were 442–448 at 28)
443508 * A file's text with the draft's hunks that touch lines `from`-`to` (of the 444509 * file as it is now, as abso diff numbers them) put back as they were at the 445− * base; the other hunks stay (#37, Builder 2: drop my copy of a teammate's
510+ * base; the other hunks stay (#37: drop my copy of a teammate's 446511 * half and keep the rest). A hunk that only deleted lines touches the line 447512 * where they were. Lines 563–569 at 318 (were 498–504 at 28)
498563 // Folder-only edits go to the server first, so they are discarded with the rest. 499564 await recordFolder(root, api); 500565 if (ranged.length > 0) { 501− // Some lines of a file: put those hunks back here, then record the file (#37, Builder 2).
566+ // Some lines of a file: put those hunks back here, then record the file (#37). 502567 const diff = await api.diff(); 503568 const lines: string[] = []; 504569 for (const r of ranged) { Lines 644–655 at 318 (were 579–590 at 28)
581646 restored.length + deleted.length === 0 582− ? "Nothing to restore: no unpublished changes there."
583− : `Discarded your unpublished changes to ${plural(restored.length + deleted.length, "file")}:`,
647+ ? "Nothing to restore: no unpushed changes there." 648+ : `Discarded your unpushed changes to ${plural(restored.length + deleted.length, "file")}:`, 584649 ...restored.map((f) => ` restored ${f}`), 585650 ...deleted.map((f) => ` deleted ${f} (it is new in your draft)`), 586651 ...(untouched.length > 0 && restored.length + deleted.length > 0 587− ? [`No unpublished changes to: ${untouched.join(", ")}`]
652+ ? [`No unpushed changes to: ${untouched.join(", ")}`] 589654 ...refusedText(refused),