Skip to main content

Module revert

Module revert 

Expand description

Undoing somebody else’s work: a contiguous run of changes, addressed by what it is rather than by where it sits on a local stack.

UndoLog only holds actions this process handled — a peer’s change re-baselines without pushing — so “undo what the agent just did” finds nothing there. A run is addressed instead by content-addressed HistoryEntryId, so a peer that only ever received those changes can undo them. The inverse is written forward through write_patches, never cut out of the graph, so the original keeps its author and the undo is itself undoable.

Not wholesale: a revert takes back the run’s own change and leaves everybody else’s alone. In text it removes exactly the characters the run inserted and puts back exactly the ones it deleted, wherever they are now ([text]), so somebody typing elsewhere in the same text keeps their words. A value somebody else set since (a field, a mark, a text they rewrote inside the run’s own words, a container they wrote in) keeps their value: that part is left alone and reported in RevertOutcome::kept. Nothing here refuses: what is kept was overwritten, and taking the run back means leaving the newer value standing.

Structs§

ChangeRun
A contiguous run of changes, addressed by its first and last change.
KeptSlot
A slot the revert declined to touch, and why.
RevertOutcome
What a revert did, and what it deliberately did not do.

Enums§

RevertError
Why a run could not be addressed at all — distinct from “addressed it and chose to keep some of it”, which is RevertOutcome::kept.
Slot
A place in the document a change wrote to, at the granularity where two writers collide.

Functions§

changes_of_entries
The changes entries name, each with the actor whose work it is, newest first: what revert_changes takes. An entry is a History row, so it names every change of a person’s typing it stands for (super::typing). An entry not in doc is skipped.
latest_run_by
The contiguous run of changes authored by actor_hex, ending at the document’s newest change by that actor.
plan_revert
Work out what undoing run would do, without touching the document.
revert_changes
Undo several changes, each on its own, into one open transaction: changes pairs each change with the actor hex whose work it is, newest first. Every revert is planned before any is written, because reading the history closes the open transaction, which would commit the first revert as a change of its own.
revert_run
Undo a run of changes by writing its inverse forward into doc.
revert_step
Undo one entry’s share of a run of work by writing its inverse forward into doc: revert_run for a run of one change, which is what a step of an agent’s run names (the toolkit’s RunStep).
run_bounds
Both returned head sets are prefix frontiers of the document’s own causal order, so they are valid arguments to AutoCommit::diff and mean the same thing on every peer holding the same changes.