Skip to content

Commit 6acfe83

Browse files
CopilotaruniverseCopilot
authored
Docs: Clarify undo/redo scope and pushed changeset reversal in IModelDbReadwrite (#9282)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: aruniverse <11051042+aruniverse@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 6f335a1 commit 6acfe83

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

docs/learning/backend/IModelDbReadwrite.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@ A backend can make the following kinds of changes:
88
- [Create or update Models](./CreateModels.md)
99
- [Reserve Codes](./ReserveCodes.md)
1010

11-
Use [IModelDb.saveChanges]($backend) to commit changes locally. [BriefcaseDb.txns]($backend) manages local transactions, it supports local undo/redo.
11+
Use [IModelDb.saveChanges]($backend) to commit changes locally. [BriefcaseDb.txns]($backend) manages local transactions and supports undo/redo of pending local changes — those saved via [IModelDb.saveChanges]($backend) but not yet pushed. Once changes are pushed to iModelHub via [BriefcaseDb.pushChanges]($backend), they become part of the permanent changeset history and can no longer be reversed using the local undo/redo stack.
1212

1313
## Pushing changes to iModelHub
1414

1515
Use [BriefcaseDb.pushChanges]($backend) to push local changes to iModelHub as a changeset, so that others can see them. After a changeset is pushed to iModelHub, it becomes part of the iModel's permanent timeline. This method automatically [pulls and merges](./IModelDbSync.md) new ChangeSets from iModelHub.
1616

1717
> Only a single application can push to iModelHub at a time. IModelDb.pushChanges automatically retries push on appropriate failures. However, it is possible that all retry attempts fail, if there are a lot of other applications pushing at the same time. In that case, push should be attempted again later.
1818
19+
## Reversing pushed changesets
20+
21+
While the local undo/redo stack is cleared after pushing, it is still possible to reverse the *effect* of previously-pushed changesets using [BriefcaseDb.revertAndPushChanges]($backend). This method applies the targeted changesets in reverse to produce a new "revert" changeset, which is then pushed to iModelHub. Before calling it, the briefcase must be "clean": it must have no unsaved changes (`hasUnsavedChanges` must be false) and no pending transactions (`txns.hasPendingTxns` must be false). Save and push local changes first, or discard them, before attempting the revert. The original changesets are **not** removed from iModelHub's timeline — the history is append-only and immutable.
22+
23+
| Scenario | Mechanism |
24+
|---|---|
25+
| Undo/redo **unpushed** local changes | `txns.reverseTxns` / `txns.reinstateTxn` |
26+
| Reverse the effect of **pushed** changesets | `BriefcaseDb.revertAndPushChanges({ toIndex })` |
27+
| Remove a changeset from history entirely | Not possible — iModelHub timeline is immutable |
28+

0 commit comments

Comments
 (0)