Question

I want to design a shell script that will take the resolve decision based on the diff chunks shown by 'p4 resolve'

The current state of my script is something like -

p4 integ -b @=CL #This will open the files in my default CL.

p4 resolve #It will now resolve the files opened in my default CL one by one

Now my Problem is, with p4 resolve, I cannot redirect its output to some file and or read the diff chunks because, it shows diff chunks for one file and waits for the user input for resolve decision. I want the script to take the very obvious resolve decision.

So, is there any way to find the diff chunks for the files in my default CL? So that, I can read these diff chunks anyhow and make these obvious resolve decisions?

Était-ce utile?

La solution

I wanted to do something similar; output the actual conflicts in a Jenkins job so that the information could be sent to the relevant development engineer.

I noticed the handy p4-dump-conficts script by jwd, based on that, perhaps the following is enough

echo -e "d\ns\n" | P4EDITOR=cat p4 resolve

(i.e. get p4 resolve to (d)iff and then (s)kip and use cat to output the results. This works for all 'pending' files in the workspace)

Autres conseils

I recently had a similar need, and hacked together a solution with a shell script.

The problem, for me, was that p4 resolve wants to be interactive, but I just wanted to see the conflicts in a file.

I didn't want to run p4 resolve -f since that would mark the file as resolved in Perforce.

I just wanted to view the conflicts, maybe email them to someone else, without really doing the resolve. You can do this interactively with the (e)dit and (s)kip commands of p4 resolve, but I wanted a hands-off version.

Save this script as p4-dump-conflicts:

#!/usr/bin/env bash

function cat_to_file() {
    cat "$@" > "$OUTFILE"
}
export -f cat_to_file
destFileName=$(dirname "$1")/CONFLICTS_$(basename "$1")
OUTFILE="$destFileName" P4EDITOR=cat_to_file p4 resolve "$1" <<END_INPUT
e
s
END_INPUT

If you run p4-dump-conflicts myfile, it will write out CONFLICTS_myfile, containing the conflict markers. It will leave the file un-resolved in Perforce, though.

Note: Only works for one file, as-is.

For your question in particular, you could process the CONFLICTS_xxx file however you want, then use the results of that for the final merge resolution.

Yes, you can use p4 resolve -n to print the same output as p4 resolve, without prompting for input or taking any action. From the p4 resolve docs:

-n List the files that need resolving without actually performing the resolve.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top