Repository navigation
fix: apply span changes on history recorded before 0.20 - #334
Merged
Merged
Conversation
Inserting a span change failed with "Apply error: change hash mismatch" whenever it depended on a change recorded before 0.20. Before applying a span change, preflight_span_references checks every change it depends on against its hash. It did that by re-encoding the change with the current writer and hashing the result. A change recorded before 0.20 keeps the hash of its original encoding, so the re-encoded hash never matches. The check now verifies the stored bytes against the requested hash. A dependency stored under the wrong hash is still refused.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
If a repo's history has changes recorded before 0.20, a span change that depends on them cannot be applied anywhere else.
pull, a freshcloneandinsertfrom another view all fail with:The repo is not damaged, but nobody else can receive the span change.
Spans are still off in release builds, so this does not hit users today. It blocks migrating existing repos to spans.
Cause
Before applying a span change,
preflight_span_referenceschecks every change it depends on against its hash. It re-encoded each change with the current writer and hashed the result. A change recorded before 0.20 keeps the hash of its original encoding, so the two never match.Fix
The check now verifies the stored bytes against the requested hash, instead of a re-encoding. Old changes stay as they are; no upgrade of old changes is needed. A dependency stored under the wrong hash is still refused.
Tests
legacy_history_span_insert_tests, using a real change recorded by the released 0.19.1 as a fixture. Covers pull, clone and insert from another view (these three fail with the error above before the fix), plus a test that a dependency stored under the wrong hash is still refused.doctor checkis consistent.cargo test --workspace --features atomic-cli/adoption-test-injection: 11,413 passed, 0 failed.cargo fmt --all -- --checkandcargo clippy --workspace -- -D warningsclean.