-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: mergetool support #5411
feat: mergetool support #5411
Conversation
Just to document some of the pieces we specifically want to evaluate and/or change before merging:
Also want to put out a note at release time about our longer-term plans for merges in Unison. Side note: apparently |
Ok, putting files in a temp dir and switching to |
I'm about to test out vscode as a mergetool (supposedly the magic string is
), and maybe a few others, to make sure we've made the right assumptions about |
In initial testing, a couple things jumped out:
|
@mitchellwrosen I wanna try to get this merged for use in the knn demo work— Besides the merge conflict, where did we land on |
@aryairani I believe we landed on the latter, that |
@aryairani Ok, I think this is ready for review again |
Merging for now to be able to test it with other new features already in trunk, even though I think we should tweak the auto-load behavior after writing the files, and also we want to make a pass to limit the amount of time |
Overview
This PR adds a primitive mergetool support to
ucm
.If a
project/main> merge /topic
fails due to conflicts, and you have aUCM_MERGETOOL
env var set, we will first write four files:<tmpdir>/main.u
<tmpdir>/topic.u
<tmpdir>/main-topic-base.u
main-topic-merged.u
The first three files contain the conflicted definitions on the respective branches and the LCA (the "base"), followed by a fold line, followed by all dependents of the merge (from both
main
andtopic
), all rendered in a PPE that favors the target branch (main
). The fourth file contains a two-way diff betweenmain
andtopic
with git-like merge markers.Then we spawn the process specified in
UCM_MERGETOOL
, with the sentinel strings$BASE
,$LOCAL
,$REMOTE
, and$MERGED
substituted for<tmpdir>/main-topic-base.u.tmp
,<tmpdir>/main.u.tmp
,<tmpdir>/topic.u.tmp
andmain-topic-merged.u
, respectively. It is the user's responsibility to provide a mergetool that actually spawns in a new tab/window/etc.To get started with a dummy "no-op" mergetool that just prints the files, you could use
and then fiddle with the files afterwards. The existence of the
UCM_MERGETOOL
environment variable is what triggers the new behavior of separating the conflicted definitions into separate files (and additionally providing the LCA definitions), versus the old behavior of putting everything in one file.Test coverage
I've tested this manually. It'd be easy enough to get under test in transcripts with a new debug command like
debug.merge-with-mergetool
that accepts a string argument forUCM_MERGETOOL
, but we decided that manual testing + dogfooding is sufficient for now.Sample merge tool commands:
UCM_MERGETOOL='/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code --merge "$REMOTE" "$LOCAL" "$BASE" "$MERGED"' ucm
UCM_MERGETOOL='/Applications/IntelliJ\ IDEA\ CE.app/Contents/MacOS/idea merge "$LOCAL" "$REMOTE" "$BASE" "$MERGED"' ucm
fg
UCM_MERGETOOL='osascript -e '"'"'tell app "Terminal" to do script "/Applications/IntelliJ\\ IDEA\\ CE.app/Contents/MacOS/idea merge \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\""'"'" ucm
UCM_MERGETOOL='opendiff "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"' ucm
UCM_MERGETOOL='/Applications/p4merge.app/Contents/MacOS/p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED" 2>&1 >/dev/null &' ucm