merge_tools: add new TUI for resolving conflicts#9078
merge_tools: add new TUI for resolving conflicts#9078
Conversation
32d89b6 to
78bbf56
Compare
Previously, we only looked ahead a single term when determining whether to write the current added term as a snapshot or not, meaning it didn't always find the optimal solution. This commit changes the implementation to always find the snapshot index which minimizes the diffs. Both implementations require `O(n)` diffs, but it could be slightly more expensive. Since most conflicts only have two terms, this isn't likely to be an issue though.
This removes the special case for using "base" instead of "base #1" when there's only one base, but since all new conflicts will have labels, this should be fine.
Currently, ratatui doesn't provide much support for scrollable areas except for lists and single paragraphs. This widget allows rendering an arbitrary series of widgets inside a scrollable block.
78bbf56 to
db725fa
Compare
|
In general this poses the question why this isn't going into scm-record, if its our blessed implementation. It makes even less sense if we want to take over stewardship of it in a few years when the legal situation around the project has improved. |
|
I'm also very interested in @arxanas opinion on this. |
|
I actually do love the "pages" so you can see the sides of the conflict in place around the file. That's smart Have you thought about what it would take to do a 3-pane terminal view? Ilya has a bit of prior art with diffedit3. I'd really love something nice here, a good TUI would be wonderful. |
I think it might make sense to have them be separate. If I understand correctly, scm-record is mainly for modifying diffs and commits, not for resolving conflicts.
The main difficulty with this is that I wanted to make something that can support many-sided conflicts, but the normal 3-pane view usually only for 2-sided conflicts. I do think this would be really nice to have though. Let me think about it and try to come up with a good UI for it. Maybe it could work where the left panel is a base snapshot to edit, and the middle and right panels are used to show a side-by-side diff to apply to that snapshot (with many-sided conflicts being achieved by having a way to select which diff is currently being applied)? I suppose this is similar to the idea of doing repeated invocations of a 3-pane viewer (#6702), but ideally it would be nice to let the user freely navigate between the sides instead of enforcing an order. |
Sorry this really doesn't answer the question I asked. I mean To me this comes across "I don't understand the required changes I need to make to scm-record, so I just rolled my own" which is imho bad engineering. |
I wasn't aware of this. To me, conflict resolution seems to require a different interface than the existing interface for scm-record, so I think it makes sense that they would be implemented as separate tools. If I did add this functionality to scm-record, I don't think I would be able to take advantage of much of the existing implementation; it would just end up being a separate UI that happens to be in the same repo.
I don't see how this is relevant. I don't think adding a new conflict resolution interface to scm-record would help with adding support for multiple splits at all. |
IMO current builtin diff editor doesn't work great with
jj resolve. It only supports 2-sided conflicts, it doesn't render conflict labels, and the way that conflicts are rendered is confusing except in the most basic cases. After seeingjj arrange, I thought I'd take a shot at making a custom TUI forjj resolvethat tries to solve these issues. This is just a work in progress still, but I thought I'd put it up as a draft in case anyone wants to try it out and give feedback.Features:
Views and key bindings
File list
This view is only visible when there are multiple files with conflicts.
j/k) - navigateq- discard changesc- confirm changesConflict viewer
This view is used for resolving normal conflicts. There is a separate view with fewer features for resolving conflicts involving deleted files, directories, symlinks, and git submodules.
j/k) - select conflicth/l) - select term within conflicta- resolve conflict by keeping all sidesr- use same resolution as current conflict for all remaining conflictsd- toggle diffsb- toggle showing bases vs sidese- open file in editor to manually resolve conflictsq- discard changesc- confirm changesTo-do
Checklist
If applicable:
CHANGELOG.mdREADME.md,docs/,demos/)cli/src/config-schema.json)how it works, how it's organized), including any code drafted by an LLM.
an eye towards deleting anything that is irrelevant, clarifying anything
that is confusing, and adding details that are relevant. This includes,
for example, commit descriptions, PR descriptions, and code comments.