Resolving conflicting changes
Conflicts occur when you attempt to integrate a file into an existing codeline or to submit a changelist containing a file that another user has edited and submitted while you had the file checked out. When the conflict occurs, Perforce schedules the file for resolve. Conflicts must be resolved before you can submit the changelist that contains the conflicting file.
When you attempt to submit a changelist containing a file that must be resolved, a Perforce Command Error is returned: Merges still pending—use 'resolve' to merge files.
When you return to the Solution Explorer, you will see a red question-mark badge next to the file icon in Solution Explorer
: (You may need to context-click the file icon and select Refresh to see the question-mark badge).
If there is a yellow triangle badge on any file, get the latest revision of that file by context-clicking it and selecting Revisions > Get Latest Revision. This will not overwrite the copy of the file that is in your workspace. After you have the latest revision, you can resolve the file. You can resolve files individually or attempt to resolve multiple files at once.
Note
In the P4VS Resolve dialog, Target is the file in your workspace and Source is the file in the depot.
Resolving multiple files
When there are multiple files in a changelist that need to be resolved, it is recommended that you first try to resolve them automatically.
To resolve multiple files at once, automatically:
- Select the files in Solution Explorer, then context-click and select Copy/Merge > Resolve….
-
In the Resolve dialog, select Auto resolve multiple files.
The dialog displays the Files to Resolve. As files are resolved, they are removed from this list.
-
Select whether to Merge binary files as text when resolving content.
If you select this option, P4VS treats binary files like text files and attempts a textual merge between the source and target files.
-
Select a Resolve method:
- Safe automatic resolve (no merging): Accepts the source file (the file in the depot) if it has the only changes. Accepts the target file (the file in your workspace) if it has the only changes. Doesn’t resolve if both the source and target have changed.
- Automatic resolve (allow merging): Accepts the source if it has the only changes. Accepts the target file if it has the only changes. Merges changes if both the source and target have changed and there are no conflicts.
- Accept Source: Replaces the copy of the file in your workspace with the version that is in the depot, discarding your changes.
- Accept Target: Accepts the file that is in your workspace, overwriting the version that is in the depot when you submit the file.
- Automatic resolve (allow merging with conflicts): Accepts the source if it has the only changes. Accepts the target file if it has the only changes. Creates a merged file if both the source and target have changed, even if there are conflicts. Where there are conflicts, both versions are included with text notations indicating the conflicts.
- (Optional) Select Set as Auto Default to set your selections as the default for auto-resolving multiple files.
- Click Auto Resolve.
- To check in the changes, submit the changelist that includes the resolved files.
To resolve multiple files one at a time (recommended when there are conflicts):
- Select Interactively resolve files one at a time.
- Follow the procedure described in Resolving individual files.
Resolving individual files
To resolve an individual file:
- Select the file in Solution Explorer, then context-click and select Copy/Merge > Resolve….
-
Select Interactively resolve files one at a time.
The Resolve dialog displays the Files to Resolve. If you are resolving multiple files one at a time, select the file you want to resolve. The files are removed from this list as they are resolved.
-
Select whether to Merge binary files as text when resolving content.
If you select this option, P4VS treats binary files like text files and attempts a textual merge between the source and target files.
-
View the Recommended action.
P4VS recommends an action, based on the differences and conflicts in the files selected. It also displays:
- The common base file
- The number of differences between the source and base file
- The number of differences between the target and base file
- The number of conflicts that would be present in the merged result.
-
Select a Resolve method:
- Accept Source: Replaces the copy of the file in your workspace with the version that is in the depot, discarding your changes.
- Accept Target: Accepts the file that is in your workspace, overwriting the version that is in the depot when you submit the file.
- Accept Merged: Replaces the file in your workspace with the merged result of the target file (in your workspace) and source file (in the depot).
- Run merge tool: Opens your chosen merge tool, enabling you to edit the file and save the merged result.
-
Select any Additional Actions that apply:
- Open File: Enables you to open either version of the file individually or the merged result file in any editor.
- Diff: Opens your diff tool to diff the files with each other or with the base file. It also enables you to diff the source, target, and base file with the merged file.
- File History: Displays the revision history of either file.
- Time-lapse View: Displays the history of either file using the Time-lapse View tool.
- Revision Graph: Displays the history of either file using the Revision Graph tool.
-
When the resolve is complete, check in the changes by submitting the changelist that includes the resolved file.
Note
The default diff and merge tool for P4VS is P4Merge. You can set diff and merge preferences, including configuring the diff and merge tool of your choice, on the Perforce - Diff/Merge node under Tools > Options > Source Control.