|
Synopsis
Open files for branching or merging
Syntax
p4 [g-opts] integrate [options] fromFile[revRange] toFile p4 [g-opts] integrate [options] -b branchname [toFile[fromRevRange]...] p4 [g-opts] integrate [options] -b branchname -s fromFile[revRange] [toFile...]
options: -c changelist# -d -f -i -n -r -t -v
Description
When you've made changes to a file that need to be propagated to another file, start the process with p4 integrate. The simplest form of this command is p4 integrate fromFile toFile; this lets the Perforce server know that changes in fromFile need to be propagated to toFile, and has the following effects:
- If toFile doesn't yet exist, fromFile is copied to toFile, then toFile is opened for branch in the client workspace.
- If toFile exists, and was originally branched from fromfile as above, then toFile is opened for integrate. You'll then use p4 resolve to propagate all of, portions of, or none of the changes in fromFile to toFile. The p4 resolve command will use fromFile as theirs, toFile as yours, and the previously integrated revision of fromFile as base.
- If both toFile and fromFile exist, but toFile was not originally branched from fromFile, the integration will be rejected.
- If fromFile was deleted at its last revision, toFile will be opened for delete in the client workspace.
(Some of the available flags modify this behavior. See the Options section for details.)
The process is complete when you p4 submit toFile to the depot.
Multiple files can be specified by using wildcards in fromFile and toFile. If so, any wildcards used in fromFile must be matched with identical wildcards in toFile. Perforce compares the fromFile pattern to the toFile pattern, creates a list of fromFile/toFile pairs, and performs an integration on each pair.
The syntax p4 integrate fromFiles toFiles requires you to specify the mapping between fromFiles and toFiles each time changes need to be propagated from fromFiles to toFiles. Alternatively, use p4 branch to store the mappings between fromFiles and toFiles in a branch view; then use p4 integrate -b branchview whenever you need to propagate changes between fromFiles and toFiles.
Options
Because some of the more recent integration flags add complexity to the integration process, we've divided the options into Basic Integration Flags and Advanced Integration Flags
Basic Integration Flags
-b branchname [toFiles...]
|
Integrate the files using the sourceFile/targetFile mappings included in the branch view of branchname. If the toFiles argument is included, include only those target files in the branch view that match the pattern specified by toFiles.
|
-n
|
Display the integrations this command would perform without actually performing them.
|
-v
|
Open files for branching without copying toFiles into the client workspace.
Without this flag, p4 integrate copies newly-branched toFiles into the client workspace from fromFiles. When the -v (virtual) flag is used, Perforce won't copy toFiles to the client workspace. Instead, you can fetch them with p4 sync when you need them.
|
-c changelist#
|
Open the toFiles for branch, integrate, or delete in the specified pending changelist.
If this option is not provided, the files will be opened in the default changelist.
|
g_opts
|
See the Global Options section.
|
Advanced Integration Flags
-b branchname -s fromFile[RevRange] [ToFiles...]
|
In its simplest form, p4 integrate -b branchname -s fromFile allows you to integrate files using the source/target mappings included in the branch view of branchname, but include only those source files that match the patterns specified by fromFile.
In its more complicated form, when both fromFile and toFile are specified, integration will be performed bidirectionally: first, integration is performed from fromFile to toFile; then integration is performed from toFile to fromFile. This variation of p4 integrate was written to provide some needed functionality to P4Win, the Perforce Windows client; it is unlikely that you'll need to use this more complex form.
|
-b branchname -r [toFiles...]
|
Reverse the mappings in the branch view, integrating from the target files to the source files.
|
-d
|
Allow non-conforming adds and deletes.
By default, a non-existent toFile is only opened for branch or add if fromFile conforms to the condition that its revRange starts with a branch or add. (When revRange is not given, this condition is always met, because the implied revRange is #1 to #head.) The -d flag allows a non-existent toFile to be opened for branch or add even if the first revision of fromFile in revRange is an edit or an integrate.
An existing toFile is only opened for delete if it conforms to the condition that all of its revisions are already accounted for in previous integrations to or from fromFile. In other words, toFile is only opened for delete if all of its changes either came from fromFile or have been merged into fromFile. The -d flag allows an existing toFile to be opened for delete even if it doesn't conform to these conditions.
|
-f
|
Force the integration on all revisions of fromFile and toFile, even if some revisions have been integrated in the past. Best used with a revision range.
|
-i
|
Perform the integration even if toFile was not originally branched from fromFile. In this case, the last revision of fromFile that was opened for add is used as base (this is almost always the first revision of fromFile).
|
-t
|
Propagate the source file's filetype to the target file.
(Newly-branched files always use the source file's filetype, but without -t, the target file retains its previous filetype.)
|
Usage Notes
Can File Arguments Use Revision Specifier?
|
Can File Arguments Use Revision Range?
|
Minimal Access Level Required
|
---|
Yes
|
Yes
|
open
|
- FromFiles are often called source files, and toFiles are often called target files.
- Any toFiles that p4 integrate needs to operate on must be included in the p4 client workspace view.
- By default, files that have been opened for branch or integrate with p4 integrate are read-only in the client workspace. You can edit these files before submitting them using p4 edit to reopen the file for edit.
- You can use p4 integrate to rename files. The method is described in the p4 rename description.
- p4 integrate can be abbreviated as p4 integ. (We've used this abbreviation in the examples below to allow for more room in the second column).
- Whenever a toFile is integrated from a fromFile, Perforce creates an integration record in its database that describes the effect of the integration. The integration record includes the names of the fromFile, and toFile, the revisions of fromFile that were integrated into toFile, the new revision number for toFile, and the action that was taken at the time of the integration. See p4 integrated for a full description of integration actions.
Examples
p4 integ //depot/dev/... //depot/rel2/...
|
Branch or merge all files in //depot/dev/... to the corresponding files in //depot/rel2/...
If there is no corresponding file in //depot/rel2/..., this creates it.
|
p4 integ -b rel2br
|
Branch or merge all fromFiles contained in the branch view rel2br into the corresponding toFiles as mapped through the branch view.
|
p4 integ -b rel2br //depot/rel2/headers/...
|
Branch or merge those fromFiles contained in the branch view rel2br that map to the toFiles //depot/rel2/headers/...
|
p4 integ -b rel2br -r //depot/rel2/README
|
Branch or merge fromFile //depot/rel2/README from its toFile as mapped through the branch view rel2br.
|
Related Commands
To create or edit a branch specification
|
p4 branch
|
To view a list of existing branch specifications
|
p4 branches
|
To view a list of integrations that have already been performed and submitted
|
p4 integrated
|
To propagate changes from one file to another after opening files with p4 integrate
|
p4 resolve
|
To view a history of all integrations performed on a particular file
|
p4 filelog
|
|