vscode-perforce icon indicating copy to clipboard operation
vscode-perforce copied to clipboard

Use VSCode diff view for resolving merge conflicts

Open tcitta opened this issue 2 years ago • 4 comments

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

tcitta avatar Sep 07 '23 20:09 tcitta

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!

mjcrouch avatar Sep 12 '23 18:09 mjcrouch

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

tcitta avatar Oct 12 '23 14:10 tcitta

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

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 ?

simon8233 avatar Dec 12 '23 15:12 simon8233

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

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 ?

  1. 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 enter p4 resolve in the VSCode terminal.

  2. 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.

  1. BTW: You can use the same method to change the DIFF and EDIT behavior:
export P4DIFF 'code --wait --diff'
export P4EDITOR 'code --wait'

bi-an avatar Apr 30 '24 06:04 bi-an