web: reapply original changes after config conflict
This commit is contained in:
@@ -211,21 +211,26 @@
|
|||||||
|
|
||||||
async function reloadAndReapply() {
|
async function reloadAndReapply() {
|
||||||
if (!toolchain || !treeState) return;
|
if (!toolchain || !treeState) return;
|
||||||
const localCandidate = structuredClone(treeState.snapshot);
|
const localChanges = [...draftChanges];
|
||||||
const remote = await fetchConfigTree(workspaceId);
|
const remote = await fetchConfigTree(workspaceId);
|
||||||
baseSnapshot = structuredClone(remote.snapshot);
|
baseSnapshot = structuredClone(remote.snapshot);
|
||||||
baseRevision = remote.snapshot.revision;
|
baseRevision = remote.snapshot.revision;
|
||||||
baseDigest = remote.snapshot.digest;
|
baseDigest = remote.snapshot.digest;
|
||||||
await toolchain.setSnapshot(remote.snapshot);
|
await toolchain.setSnapshot(remote.snapshot);
|
||||||
draftChanges = await toolchain.changesBetween(remote.snapshot, localCandidate);
|
try {
|
||||||
const candidate = await toolchain.applyChanges(draftChanges);
|
const candidate = await toolchain.applyChanges(localChanges);
|
||||||
treeState = { ...remote, snapshot: candidate };
|
draftChanges = localChanges;
|
||||||
selectedPath = candidate.entries[selectedPath] ? selectedPath : Object.keys(candidate.entries).toSorted()[0] ?? "";
|
treeState = { ...remote, snapshot: candidate };
|
||||||
source = selectedPath ? candidate.entries[selectedPath].content : "";
|
selectedPath = candidate.entries[selectedPath] ? selectedPath : Object.keys(candidate.entries).toSorted()[0] ?? "";
|
||||||
conflict = false;
|
source = selectedPath ? candidate.entries[selectedPath].content : "";
|
||||||
preflightDigest = "";
|
conflict = false;
|
||||||
candidateContract = null;
|
preflightDigest = "";
|
||||||
status = "Local candidate reapplied to the latest revision. Preview again before Commit.";
|
candidateContract = null;
|
||||||
|
status = "Local changes reapplied to the latest revision. Preview again before Commit.";
|
||||||
|
} catch (error) {
|
||||||
|
conflict = true;
|
||||||
|
status = `Local changes conflict with the latest revision: ${String(error)}. Discard local changes or resolve against a fresh reload.`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createEntry() {
|
function createEntry() {
|
||||||
|
|||||||
Reference in New Issue
Block a user