WIP: fix: Check the syntactic validity of merges #321
No reviewers
Labels
No labels
Compat/Breaking
Kind
Bad merge
Kind
Bug
Kind
Documentation
Kind
Enhancement
Kind
Feature
Kind
New language
Kind
Security
Kind
Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: mergiraf/mergiraf#321
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "wetneb:320-check-syntactic-validity-of-merges"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Motivated by #320 and earlier cases like #170, we introduce a check to ensure that our grammar is able to parse the rendered version of a merged file.
This check was already being done for line-based merges: we extend it to structured merges.
Sadly it's not sufficient to fix the motivating example from #320 because the Python grammar is overly forgiving. But it's probably worth having anyway.
26ae5c6ee4
to2001e07ce9
fix: Check the syntactic validity of mergesto WIP: fix: Check the syntactic validity of mergesMarking as WIP because I realize this will need tweaking in case the compact mode is on, because we shouldn't expect that re-parsing the revisions derived from a file with conflicts should succeed (because of the added newlines in them).
2001e07ce9
toa70b4c0c85
Update: since the recent changes around avoiding the re-parsing of line-based merges, this PR would need a bit more work (because it re-introduces some of that).
I'm thinking it would actually make sense to change the rendering of MergedText so that it doesn't directly output a String, but a ParsedMerge instead, which could later be rendered to a String. This means that MergeResult could just have the ParsedMerge as a field (instead of
contents: String
currently). Does that sound like a good idea to you, @ada4a?This definitely sounds very appealing! Not needing to duplicate the rendering logic is especially nice. I'm not sure how hard this change would be to implement...
That would be lovely! We could probably avoid storing cached
conflict_mass
andconflict_count
as well...After a quick investigation, I think
ParsedMerge
is actually not a good fit for this, because (as its name indicates) it is geared towards parsed representations of line-based merges. It comes with an indexing logic to be able to generate matchings between revisions, which doesn't play well with representing the output of a structured merge (as it would require us to generate certain byte offsets which are complicated to compute and unnecessary when representing a merge output).The
MergedText
struct is much more fitting, because it lets us represent conflicts independently from line boundaries and isn't encumbered by this indexing. This should make it possible to check for syntactic validity regardless of whether the compact mode is on.Completely agree – and
ParsedMerge
should be trivially translatable intoMergedText
The example in #320 is still considered valid by tree-sitter-python, so the approach followed in this PR will not make it possible to detect its incorrectness.
Instead, I think we should not just parse the revisions, but also check that the parsed trees are consistent with the merged tree they are generated from. I'm opening a new PR for this: #368.
Pull request closed