Previous Table of Contents Index Next
Perforce 2009.1: Command Reference



p4 integrate
Synopsis
Open files for branching or merging.
Syntax
p4 [g-opts] integrate [options] fromFile[revRange] toFile
p4 [g-opts] integrate [options] -b branch [toFile[fromRevRange]...]
p4 [g-opts] integrate [options] -b branch -s fromFile[revRange] [toFile...]
options: -c changelist# -d -Dflag -f -h -i -I -o -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 shares a common ancestor with fromfile as above, then toFile is opened for integrate. You can then use p4 resolve to propagate all of, portions of, or none of the changes in fromFile to toFile. The p4 resolve command uses fromFile as theirs, toFile as yours, and the common ancestor of fromFile as base.
If both toFile and fromFile exist, but toFile shares no common ancestor with fromFile, the integration is rejected. Use the -i flag to force a baseless merge.
If fromFile was deleted at its last revision (and all previous changes have already been integrated between fromFile and toFile), toFile is 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.
To specify multiple files, use wildcards in fromFile and toFile. Any wildcards used in fromFile must match 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, and 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.
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.
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 is 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 graphical Perforce client programs; it is unlikely that you'll need to use this more complex form.
-b branchname -r
[toFiles...]
The -d flag enables integrations around deleted revisions. Using -d implies -Dt, -Ds, and -Di.
If the target file has been deleted and the source file has changed, (or the source file has changed and subsequently been deleted), using -d re-branches the changes from the source file on top of the target file.
If the source file has been deleted and the target file has changed, using -d deletes the target file.
If the source file has been deleted and re-added, using -d integrates all outstanding revisions of the file, including those revisions prior to the file's deletion.
If you do not use the -d flag, outstanding edits may not be mixed with a deleted file.
-Dt
-Ds
-Di
The -Dt flag allows integration around a deleted target file; the source file is branched onto the deleted target.
The -Ds flag allows integration around a deleted source file; if the source file has been deleted, any modified target file is also deleted.
The -Di flag ignores the fact that a source file was deleted and re-added when searching for an integration base.
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.
Don't automatically sync target files to the head revision before integrating. Use the have revision instead.
Perform the integration even if toFile and fromFile share no common ancestor, using the first revision as the base.
Equivalent to -i, the -I flag exists for compatibility purposes.
The -o flag outputs the base file name and revision to be used in subsequent resolves, if a resolve is needed.
(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?
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.
p4 integrate can be abbreviated as p4 integ. (This abbreviation is used the examples below).
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
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.
Branch or merge all fromFiles contained in the branch view rel2br into the corresponding toFiles as mapped through the branch view.
Branch or merge those fromFiles contained in the branch view rel2br that map to the toFiles //depot/rel2/headers/...
Branch or merge fromFile //depot/rel2/README from its toFile as mapped through the branch view rel2br.
Related Commands


Previous Table of Contents Index Next

Perforce 2009.1: Command Reference
Copyright 1999-2009 Perforce Software.