Merge changes
After you create branches, you might need to propagate changes between
them. For example, if you fix a bug in a release branch, you probably
want to incorporate the fix back into your main codeline. To propagate
selected changes between branched files, you use the p4
merge
and p4 resolve
commands, as
follows:
- Issue the
p4 merge
command to schedule the files for resolve. -
Issue the
p4 resolve
command to propagate changes from the source files to the target files.To propagate individual changes, edit the merge file or use a merge program. The changes are made to the target files in the client workspace.
- Submit the changelist containing the resolved files.
Example Propagating changes between branched files
Bruno has fixed a bug in the release 2.2 branch of the Jam project and needs to integrate it back to the main codeline. From his home directory, Bruno types the following:
p4 merge //JamCode/release/jam/2.2/src/Jambase //JamCode/dev/jam/Jambase
He sees the following message:
//JamCode/dev/jam/Jambase#134 - merge from ////JamCode/release/jam/2.2/src/Jambase#9
The file has been scheduled for resolve. He types p4
resolve
, and the standard merge dialog appears on his
screen.
//JamCode/dev/jam/Jambase - merging depot/release/jam/2.2/src/Jambase#9 Diff chunks: 0 yours + 1 theirs + 0 both + 0 conflicting Accept(a) Edit(e) Diff(d) Merge (m) Skip(s) Help(?) [at]:
He resolves the conflict. When he’s done, the result file overwrites the file in his workspace. The changelist containing the file must be submitted to the depot.
To run the p4 merge
or p4 copy
commands, you must have
Helix Core Server write
permission on the target files, and read
access on the source files. (See the
Helix Core Server Administrator Guide
for information on
Helix Core Server
permissions.)
By default, a file that has been newly created in a client workspace by
p4 merge
cannot be edited before being submitted. To
edit a newly merged file before submission, resolve it, then issue the
p4 edit
command.
If the range of revisions being merged includes deleted revisions (for
example, a file was deleted from the depot, then re-added), you can
specify how deleted revisions are merged using the -Di
option. For details, refer to the
Helix Core Command-Line (P4) Reference.
Also in this section: