Skip to content

Implement RevertToCheckpoint functionality and improve error handling#9286

Open
khanaffan wants to merge 6 commits into
masterfrom
affank/revert-to-version
Open

Implement RevertToCheckpoint functionality and improve error handling#9286
khanaffan wants to merge 6 commits into
masterfrom
affank/revert-to-version

Conversation

@khanaffan
Copy link
Copy Markdown
Contributor

imodel-native: iTwin/imodel-native#1419

This pull request introduces new APIs and implementations for efficiently reverting an iModel database to a previous version by computing and applying the difference between versions, with robust error handling and test coverage. The main changes include new diffing methods in ChangeTracker, the RevertToVersion implementation in TxnManager, and comprehensive tests to validate the new functionality. Node.js bindings are also updated to expose the new revert capability.

* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { DbResult, GuidString, Id64, Id64String } from "@itwin/core-bentley";
import { DbResult, Guid, GuidString, Id64, Id64String, Logger, LogLevel, OpenMode } from "@itwin/core-bentley";
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an @Alpha backend API to revert a briefcase to a checkpoint by diffing against a target checkpoint and applying the inverse, along with new standalone tests validating revert behavior (including schema + data reverts, and error cases).

Changes:

  • Added BriefcaseDb.revertToCheckpoint(...) and new RevertToCheckpointArgs type (file-path or V2-checkpoint changeset index).
  • Added standalone tests covering revert-to-checkpoint flows and rejection cases (unsaved changes, pending txns).
  • Updated API extraction outputs and added a rush change file.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
core/backend/src/test/standalone/SQliteChangesetReaderAndChangesetECAdaptor.test.ts Adds revertToCheckpoint test suite validating revert + push/pull behavior and error handling scenarios.
core/backend/src/IModelDb.ts Introduces BriefcaseDb.revertToCheckpoint implementation with precondition checks and V2-checkpoint support.
core/backend/src/BriefcaseManager.ts Defines RevertToCheckpointArgs discriminated union for checkpoint target selection.
common/changes/@itwin/core-backend/affank-revert-to-version_2026-05-12-01-44.json Adds changelog entry (type none).
common/api/summary/core-backend.exports.csv Exposes new alpha export RevertToCheckpointArgs.
common/api/core-backend.api.md Updates extracted API to include revertToCheckpoint and RevertToCheckpointArgs.

* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { DbResult, GuidString, Id64, Id64String } from "@itwin/core-bentley";
import { DbResult, Guid, GuidString, Id64, Id64String, Logger, LogLevel, OpenMode } from "@itwin/core-bentley";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants