tools/internal/parser: add diff support #2071
Merged
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.
List.SetBaseVersion takes an older base List, and makes Block.Changed()
reflect whether or not each block has changed compared to that base.
2 commits: one is the refactor to introduce the blockInfo struct, the other is diff.go and tests.
This is a building block that sets change information on a parsed list, which validations can then use to ignore unchanged elements. Generalized tree diff is an open academic research problem, so instead of doing that, this implementation takes some shortcuts by exploiting some special properties of the PSL, and by accepting some false positives (we mark as changed some things that didn't change, or changed in a way doesn't matter for validation) in exchange for simpler code and no false negatives.
I ran this logic against the last 50 PSL changes, here are the git diffs vs. changed parse tree nodes. Some noteworthy illustrations of the semantics:
aaa
as dirty. This is an easy adjustment to the newgtld output, and is on my TODO.