fix(revert): match Dolt 2.0.5 dirty-set rules (PR dolt#11073 + follow-up)#992
Conversation
…-up)
Dolt 2.0.5 tightened dolt_revert's dirty-set check to match git's
behavior:
1. Any staged change refuses the revert, even when the staged
table is unrelated to the revert target. Mirrors git's
"index must be clean" requirement — otherwise the revert
commit would mix staged work with the inverse-change commit.
2. Unstaged changes refuse the revert only if they overlap with
a table the revert would touch. Disjoint unstaged changes
are allowed and get folded into the revert commit.
Previous doltlite behavior was "refuse only if dirty change touches
a table the revert would also touch", which allowed staged-disjoint
to proceed. That diverged from Dolt 2.0.5 on
revert_head_staged_unrelated_table_committed (caught by
vc_oracle_revert_test.sh once Dolt was upgraded to 2.0.5).
Replace doltliteRevertHasDirtyTouchedTables /
doltliteCollectRevertTouchedTables / their internal name-list helpers
with a single doltliteRevertCheckDirty that does both checks inline:
* If session-staged catalog hash differs from session-head hash,
flag dirty regardless of which tables differ.
* Else compare working catalog to head; for each differing table,
check whether the revert target catalog and parent catalog
differ on that same table — if so, flag dirty.
Error message also updated to match Dolt's:
"Your local changes would be overwritten by revert.\nhint: ..."
Verified against /tmp/dolt-2.0.5 binary downloaded from the v2.0.5
release:
* vc_oracle_revert_test.sh: 6/6 pass (was 5/6 with the staged-disjoint
case failing before this change)
* vc_oracle_revert_cherrypick_test.sh: 45/45 pass
* doltlite_merge.sh: 91/91 pass
* doltlite_conflicts.sh: 40/40 pass
* doltlite_advanced.sh: 140/140 pass
References: Dolt PR dolthub/dolt#11073 ("dolt revert to more closely
match git") and follow-up commit 014f1d8 ("align revert dirty-set
rules with git") in dolthub/dolt v2.0.5.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sysbench-Style Benchmark: Doltlite vs SQLiteIn-MemoryReads
Writes
File-BackedReads
Writes
File-Backed (autocommit)Each statement runs as its own transaction — exposes per-commit ReadsReads have no commit cost; these are the same SQL files as the
Writes
10000 rows, median of 21 invocations per test, workload-only timing via host monotonic clock when available. Performance Ceiling Check (1.8x individual, 1.5x average)All tests within ceilings. |
Sysbench-Style Benchmark (TEXT PK): Doltlite vs SQLiteCompanion to the classic Sysbench-Style Benchmark. Every workload here In-MemoryReads
Writes
File-BackedReads
Writes
File-Backed (autocommit)Each statement runs as its own transaction — exposes per-commit ReadsReads have no commit cost; these are the same SQL files as the
Writes
1000 rows, median of 13 invocations per test, workload-only timing via host monotonic clock when available. Performance Ceiling Check (1.8x individual, 1.5x average)All tests within ceilings. Sysbench-Style Benchmark (BLOB PK): Doltlite vs SQLiteCompanion to the classic Sysbench-Style Benchmark. Every workload here In-MemoryReads
Writes
File-BackedReads
Writes
File-Backed (autocommit)Each statement runs as its own transaction — exposes per-commit ReadsReads have no commit cost; these are the same SQL files as the
Writes
1000 rows, median of 13 invocations per test, workload-only timing via host monotonic clock when available. Performance Ceiling Check (1.8x individual, 1.5x average)All tests within ceilings. Sysbench-Style Benchmark (composite PK): Doltlite vs SQLiteCompanion to the classic Sysbench-Style Benchmark. Every workload here In-MemoryReads
Writes
File-BackedReads
Writes
File-Backed (autocommit)Each statement runs as its own transaction — exposes per-commit ReadsReads have no commit cost; these are the same SQL files as the
Writes
1000 rows, median of 13 invocations per test, workload-only timing via host monotonic clock when available. Performance Ceiling Check (1.8x individual, 1.5x average)All tests within ceilings. |
doltlite_revert_dirty.sh was written against the older "refuse only on
touched-table dirty" rule. With the new staged-anywhere check, two
tests need updating:
* rv_dirty_same_refuses — expected error string updated from the
old "cannot revert with uncommitted changes" to Dolt 2.0.5's
"Your local changes would be overwritten by revert".
* rv_staged_unrelated_* — was asserting that staged unrelated
changes are folded into the revert commit. Under the new rule,
any staged change refuses the revert (git's index-clean
requirement), so flip the assertion: refuse, no new commit,
target table unchanged, staged table still dirty.
Case 1 (unstaged unrelated → allowed) and case 4 (clean → allowed)
are unchanged; the new rule preserves those paths exactly.
Verified locally: 14/14 pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Match the Dolt 2.0.5 revert semantics so the version-control oracle tests pass against the current Dolt release.
Two rules, mirroring
git revertexactly:What was wrong
Before this PR, doltlite refused only when a dirty change overlapped with a table the revert would touch. That matched Dolt's behavior up through 2.0.4 but diverged from 2.0.5, which added the stricter index-clean rule on top.
Caught by
vc_oracle_revert_test.sh'srevert_head_staged_unrelated_table_committedcase once CI upgraded to Dolt 2.0.5.What changed
Replaced three internal helpers (
doltliteRevertHasDirtyTouchedTables,doltliteCollectRevertTouchedTables, plus the name-list utility helpers) with a singledoltliteRevertCheckDirtythat does both checks inline:session-staged catalog hash != session-head hash, flag dirty regardless of which tables differ.Error message updated to match Dolt's exact wording:
Net diff: -131 lines, +58 lines (simpler, single helper).
References
014f1d8— "align revert dirty-set rules with git" (the follow-up that added the index-clean rule)Test plan
Verified locally against
/tmp/dolt-2.0.5(the binary downloaded from the v2.0.5 release):vc_oracle_revert_test.sh— 6/6 pass (was 5/6 withrevert_head_staged_unrelated_table_committedfailing before this change)vc_oracle_revert_cherrypick_test.sh— 45/45 passdoltlite_merge.sh— 91/91 passdoltlite_conflicts.sh— 40/40 passdoltlite_advanced.sh— 140/140 pass🤖 Generated with Claude Code