Use VSCode diff view for resolving merge conflicts
It would be nice if the vscode diff view could be used to resolve conflicts.
Setting P4EDITOR='code --wait' just opens a new text document with markers and no colorization.
Perhaps this could be made to work with vscode's built-in 3-way merge editor: https://code.visualstudio.com/updates/v1_69#_3-way-merge-editor
Hi - thanks for suggesting - I have to say I thought this was a duplicate as I'm sure it's been discussed before but I can't find another one. Currently I think it's impractical to do with the way the command line p4 interface (which we use for all commands) works, so it's unlikely to happen, though there may be a way to implement it!
Apologies for the delay in getting back to this.
Arguments need to be remapped, apparently. Using "perforce.resolve.p4editor": ".vscode/p4_resolve.sh" seems to invoke the proper editor (albeit without proper syntax highlighting/intellisense), where p4_resolve.sh is:
#!/bin/bash
# This script maps p4 resolve arguments to vscode's merge editor arguments
#
# 'code' takes: <path1> <path2> <base> <result>
#
# perforce gives:
# 1 the base file
# 2 the source file (also known as "theirs")
# 3 the target file (also known as "yours")
# 4 the merge file.
code --wait --merge $2 $3 $1 $4
Apologies for the delay in getting back to this.
Arguments need to be remapped, apparently. Using
"perforce.resolve.p4editor": ".vscode/p4_resolve.sh"seems to invoke the proper editor (albeit without proper syntax highlighting/intellisense), wherep4_resolve.shis:#!/bin/bash # This script maps p4 resolve arguments to vscode's merge editor arguments # # 'code' takes: <path1> <path2> <base> <result> # # perforce gives: # 1 the base file # 2 the source file (also known as "theirs") # 3 the target file (also known as "yours") # 4 the merge file. code --wait --merge $2 $3 $1 $4
it's work on my env. thanks for your shraring.
but no highlighting for resolve opertion is a little hard
i guess it's rely on file extension name , anyone know how to change $1 , $2 file name to change tmp.xxxxxx.c ?
Apologies for the delay in getting back to this. Arguments need to be remapped, apparently. Using
"perforce.resolve.p4editor": ".vscode/p4_resolve.sh"seems to invoke the proper editor (albeit without proper syntax highlighting/intellisense), wherep4_resolve.shis:#!/bin/bash # This script maps p4 resolve arguments to vscode's merge editor arguments # # 'code' takes: <path1> <path2> <base> <result> # # perforce gives: # 1 the base file # 2 the source file (also known as "theirs") # 3 the target file (also known as "yours") # 4 the merge file. code --wait --merge $2 $3 $1 $4it's work on my env. thanks for your shraring.
but no highlighting for resolve opertion is a little hard
i guess it's rely on file extension name , anyone know how to change $1 , $2 file name to change tmp.xxxxxx.c ?
-
Backgroud: I use VSCode SSH from Windows to Linux. After I set
"perforce.resolve.p4editor": ".vscode/p4_resolve.sh", I still can't open VSCode as the merge tool when I enterp4 resolvein the VSCode terminal. -
Solution: But I made it after setting the environment variables:
export P4MERGE '/path/to/p4_resolve.sh'
Then I input p4 resolve to enter the resolving terminal, when I enter m (means merge) to try to merge the changes, I successfully opened the VSCode merge window.
- BTW:
You can use the same method to change the
DIFFandEDITbehavior:
export P4DIFF 'code --wait --diff'
export P4EDITOR 'code --wait'