Resolve conflicts between file revisions
p4 resolve is used to combine the contents of two files or file revisions into a single file revision. Two situations require the use of p4 resolve before a file can be submitted:
The primary difference between these two cases is that resolving a simple file conflict involves multiple revisions of a single file, but resolving for integration involves combining two separate files. In either case, if the file is of type text, p4 resolve allows the user to choose whether to overwrite the file revision in the depot with the file in the client workspace, overwrite the file in the client workspace with the file in the depot, or merge changes from both the depot revision and the client workspace revision into a single file. If the file is of type binary, only the first two options are normally available, since merges don't generally work with binary files.
The p4 resolve dialog refers to four file revisions whose meaning depends on whether or not the resolution fixes a simple file conflict or is resolving for integration:
The p4 resolve dialog presents the following options:
Option | Short Meaning |
What it Does |
Available by Default for Binary Files? |
e | edit merged | Edit the preliminary merge file generated by Perforce | no |
ey | edit yours | Edit the revision of the file currently in the client | yes |
et | edit theirs | Edit the revision in the depot that the client revision conflicts with (usually the head revision). This edit is read-only. | yes |
dy | diff yours | Show diffs between yours and base | no |
dt | diff theirs | Show diffs between theirs and base | no |
dm | diff merge | Show diffs between merge and base | no |
d | diff | Show diffs between merge thatand yours | yes |
m | merge |
Invoke the command
P4MERGE base theirs yours mergeTo use this option, you must set the environment variable P4MERGE to the name of a third-party program that merges the first three files and writes the fourth as a result. This command has no effect if P4MERGE is not set. | no |
? | help | Display help for p4 resolve | yes |
s | skip | Don't perform the resolve right now. | yes |
ay | accept yours | Accept yours , ignoring changes that may have been made in theirs. | yes |
at | accept theirs | Accept theirs into the client workspace as the resolved revision. The revision that was in the client workspace is overwritten. When resolving simple conflicts, this option is identical to performing p4 revert on the client workspace file. When resolving for integrate, this copies the source file to the target file. | yes |
am | accept merge | Accept merged into the client workspace as the resolved revision. The revision originally in the client workspace is overwritten. | no |
a | accept | Keep Perforce's recommended result: if theirs is identical to base, accept yours; if yours is identical to base, accept theirs; if yours and theirs are different from base, and there are no conflicts between yours and theirs; accept merge; otherwise, there are conflicts between yours and theirs, so skip this file | no |
Resolution of a file is completed when any of the accept options are chosen, or if the file is skipped.
To help decide which option to choose, counts of four types of changes that have been made to the file revisions are displayed by p4 resolve:
Diff Chunks: 2 yours + 3 theirs + 5 both + 7 conflicting
The meanings of these values are:
If there are no conflicting chunks, it is often safe to accept Perforce's generated merge file, since Perforce will substitute all the changes from yours and theirs into base. If there are conflicting chunks, the merge file must be edited. In this case, Perforce will include the conflicting yours, theirs, and base text in the merge file; it's up to you to choose which version of the chunk you want to keep. The different text is clearly delineated with file markers:
>>>> ORIGINAL VERSION foo#n
<text>
==== THEIR VERSION foo#m
<text>
==== YOUR VERSION foo
<text>
<<<<
Choose the text you want to keep; delete the conflicting chunks and all the difference markers.
-am -af -as -at -ay |
Skip the resolution dialog; resolve the files automatically as follows:
|
-n | List the files that need resolving without actually performing the resolve. |
-v | Include conflict markers in the file for all changes between yours and base, and between theirs and base. Normally, conflict markers are included only when yours and theirs conflict. |
-b | Display all the possible resolve options in the p4 resolve dialog, even if the file is a binary file. This allows binary files to be merged, but this only has meaning if P4MERGE is set to a utility that can merge binary files. |
-f | Allow already-resolved but not yet submitted files to be resolved again. |
g_opts | See global options section. |
Can File Arg Use Revision Specifier? |
Can File Arg Use Revision Range? |
Minimal Access Level Required |
---|---|---|
No | No | open |
To view a list of resolved but unsubmitted files | p4 resolved |
To schedule the propagation of changes between two separate files | p4 integrate |
To submit a set of changed files to the depot | p4 submit |
To copy a file to the client workspace, or schedule an open file for resolve | p4 sync |