Skip to content

Commit 4e46b13

Browse files
authored
Merge branch 'master' into da4/solid-primitive-is-skew
2 parents 2f961e8 + 6acfe83 commit 4e46b13

8 files changed

Lines changed: 153 additions & 54 deletions

File tree

common/api/core-backend.api.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4589,9 +4589,6 @@ export class IModelNative {
45894589
static get platform(): typeof IModelJsNative;
45904590
}
45914591

4592-
// @internal (undocumented)
4593-
export const _implicitTxn: unique symbol;
4594-
45954592
// @beta
45964593
export type ImplicitWriteEnforcement = "allow" | "log" | "throw";
45974594

common/api/summary/core-backend.exports.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,6 @@ public;class;IModelJsFs
367367
public;class;IModelJsFsStats
368368
public;interface;IModelNameArg
369369
internal;class;IModelNative
370-
internal;const;_implicitTxn
371370
beta;type;ImplicitWriteEnforcement
372371
public;class;InformationContentElement
373372
preview;class;InformationContentElement
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "",
5+
"type": "none",
6+
"packageName": "@itwin/core-backend"
7+
}
8+
],
9+
"packageName": "@itwin/core-backend",
10+
"email": "50554904+hl662@users.noreply.github.com"
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "",
5+
"type": "none",
6+
"packageName": "@itwin/linear-referencing-backend"
7+
}
8+
],
9+
"packageName": "@itwin/linear-referencing-backend",
10+
"email": "50554904+hl662@users.noreply.github.com"
11+
}

core/backend/src/internal/cross-package.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
export { IModelJsNative, NativeCloudSqlite, NativeLoggerCategory } from "@bentley/imodeljs-native";
77
export { IModelNative } from "./NativePlatform";
88
export {
9-
_implicitTxn,
109
_nativeDb,
1110
} from "./Symbols";

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+

domains/linear-referencing/backend/src/LinearReferencingElementAspects.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import { Id64String, JsonUtils } from "@itwin/core-bentley";
10-
import { _implicitTxn, EditTxn, ElementMultiAspect, IModelDb } from "@itwin/core-backend";
10+
import { EditTxn, ElementMultiAspect, IModelDb } from "@itwin/core-backend";
1111
import { RelatedElement } from "@itwin/core-common";
1212
import {
1313
DistanceExpressionProps, LinearlyReferencedAtLocationAspectProps, LinearlyReferencedFromToLocationAspectProps,
@@ -89,8 +89,13 @@ export class LinearlyReferencedAtLocation extends LinearlyReferencedLocation {
8989

9090
public static insert(txnOrIModel: EditTxn | IModelDb, locatedElementId: Id64String,
9191
at: DistanceExpression, fromReferentId?: Id64String): void {
92-
const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];
93-
txn.insertAspect(this.toProps(locatedElementId, at, fromReferentId));
92+
const aspectProps = this.toProps(locatedElementId, at, fromReferentId);
93+
if (txnOrIModel instanceof EditTxn)
94+
txnOrIModel.insertAspect(aspectProps);
95+
else {
96+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- deprecated IModelDb overload is intentionally preserved for backward compatibility.
97+
txnOrIModel.elements.insertAspect(aspectProps);
98+
}
9499
}
95100
}
96101

@@ -147,7 +152,12 @@ export class LinearlyReferencedFromToLocation extends LinearlyReferencedLocation
147152

148153
public static insert(txnOrIModel: EditTxn | IModelDb, locatedElementId: Id64String,
149154
from: DistanceExpression, to: DistanceExpression, fromReferentId?: Id64String, toReferentId?: Id64String): void {
150-
const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];
151-
txn.insertAspect(this.toProps(locatedElementId, from, to, fromReferentId, toReferentId));
155+
const aspectProps = this.toProps(locatedElementId, from, to, fromReferentId, toReferentId);
156+
if (txnOrIModel instanceof EditTxn)
157+
txnOrIModel.insertAspect(aspectProps);
158+
else {
159+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- deprecated IModelDb overload is intentionally preserved for backward compatibility.
160+
txnOrIModel.elements.insertAspect(aspectProps);
161+
}
152162
}
153163
}

0 commit comments

Comments
 (0)