com.perforce.p4java.ant.tasks
Class IntegrateTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.perforce.p4java.ant.tasks.PerforceTask
              extended by com.perforce.p4java.ant.tasks.ServerTask
                  extended by com.perforce.p4java.ant.tasks.ClientTask
                      extended by com.perforce.p4java.ant.tasks.IntegrateTask
All Implemented Interfaces:
java.lang.Cloneable

public class IntegrateTask
extends ClientTask

Open files for branching or merging. 'p4 integrate' stages change propagation from source files to target files, opening the target files in the client workspace. 'p4 resolve' then merges content from the source files into the opened target files, and 'p4 submit' commits the opened files to the depot. Integrations can be abandoned with 'p4 revert'.

When 'p4 integrate' opens a target file in the client workspace, it chooses an appropriate action: 'branch' for new files, 'integrate' when the source file has changed, and 'delete' when the source file was deleted. Open target files are left read-only in the client workspace. 'p4 edit' can downgrade a 'branch' to an 'add' or an 'integrate' to an 'edit', making the file read-write.

'p4 integrate' maintains integration history between files. This eliminates duplicate integrations and minimizes file merges by telling 'p4 resolve' what to use as the merge base: generally the highest revision already integrated. Integration history also prevents integrating back a pure, integration-only change. Such a change is one that resulted from 'p4 resolve' without manually editing the file. The search for integration history will include integrations indirectly through intermediate file branches The commands 'p4 integrated' and 'p4 filelog' display integration history.

A branch view may be given directly on the command line by stating the source (from) and target (to) files, or indirectly by naming a stored branch view with -b branch. A stored branch view may have many mappings, while a view on the command line can only have one. If a stored branch view is given, the target files and source files and revisions may be further limited on the command.

If no file specification is given then the entire branch view is examined for needed integrations. If a file specification is given, the integration is limited to only those target files. In both cases, the integration is also limited to those target files that are also in the client view.

If no revision specification is given then all revisions of the source file are considered for integration. If a single revision is given, then only revisions up to the given revision are included. If a pair of revisions is given (separated by a comma (,)) then only those revisions, inclusively, are integrated. Note that the revision specification concerns the fromFile, but is attached to the toFile. See 'p4 help revisions' for help specifying revisions.

See Also:
PerforceTask, ClientTask

Nested Class Summary
 
Nested classes/interfaces inherited from class com.perforce.p4java.ant.tasks.ServerTask
ServerTask.GlobalOption
 
Nested classes/interfaces inherited from class com.perforce.p4java.ant.tasks.PerforceTask
PerforceTask.Field, PerforceTask.File
 
Field Summary
protected  boolean bidirectionalInteg
          Causes the branch view to work bidirectionally, where the scope of the command is limited to integrations whose 'from' files match fromFile[revRange].
protected  java.lang.String branch
          If not null, use this as the integration branch specification.
protected  java.lang.String changelist
          If positive, the integrated files are opened in the numbered pending changelist instead of the default changelist.
protected  boolean deleteTargetAfterDelete
          If the source file has been deleted and the target file has changed, will delete the target file.
protected  boolean displayBaseDetails
          Display the base file name and revision which will be used in subsequent resolves if a resolve is needed.
protected  boolean doBaselessMerge
          Enables integration between files that have no integration history.
protected  boolean dontCopyToClient
          Don't copy newly branched files to the client.
protected  boolean forceIntegration
          Forces integrate to act without regard for previous integration history.
protected  java.lang.String fromFile
          Source file and revision specifiers, separated by space.
protected  IFileSpec fromFileSpec
          Source file and revision specifier for the Perforce command.
protected  boolean integrateAllAfterReAdd
          If the source file has been deleted and re-added, will attempt to integrate all outstanding revisions of the file, including those revisions prior to the delete.
protected  boolean integrateAroundDeletedRevs
          If true, enable integrations around deleted revisions; equivalent to -d (i.e.
protected  int maxFiles
          If positive, integrate only the first maxFiles files.
protected  boolean propagateType
          Propagate the source file's filetype to the target file.
protected  boolean rebranchSourceAfterDelete
          If the target file has been deleted and the source file has changed, will re-branch the source file on top of the target file.
protected  boolean reverseMapping
          Reverse the mappings in the branch view, with the target files and source files exchanging place.
protected  boolean showActionsOnly
          Display what integrations would be necessary but don't actually do them.
protected  java.lang.String toFile
          Target file and revision specifiers, separated by space.
protected  IFileSpec toFileSpec
          Target file and revision specifier for the Perforce command.
protected  boolean useHaveRev
          Causes the target files to be left at the revision currently on the client (the '#have' revision).
 
Fields inherited from class com.perforce.p4java.ant.tasks.ClientTask
p4Client
 
Fields inherited from class com.perforce.p4java.ant.tasks.ServerTask
allHosts, commandOptions, globaloptions, hostName, P4_SERVER_PROTOCOL_PROPERTIES_FILE, P4_SERVER_USAGE_PROPERTIES_FILE, p4Server, programName, programVersion, protocolPropertiesFile, protocolProps, textLanguage, unsetClientName, unsetUserName, usagePropertiesFile, usageProps, workingDirectory
 
Fields inherited from class com.perforce.p4java.ant.tasks.PerforceTask
charset, client, failOnError, fields, FILE_TOKEN_REGEX_PATTERN, fileList, files, fileSpecs, LINE_PADDING, LINE_SEPARATOR, p4Messages, passwd, port, protocol, retFileSpecs, retStatusMessage, user
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
IntegrateTask()
          Default constructor.
 
Method Summary
protected  void execP4Command()
          Execute the Perforce integrate command with source and target file specs and options.
 IFileSpec getFromFileSpec()
          Gets the from file spec.
 IFileSpec getToFileSpec()
          Gets the to file spec.
 void setBidirectionalInteg(boolean bidirectionalInteg)
          Sets the bidirectional integ.
 void setBranch(java.lang.String branch)
          Sets the branch.
 void setChangelist(java.lang.String changelist)
          Sets the changelist.
 void setDeleteTargetAfterDelete(boolean deleteTargetAfterDelete)
          Sets the delete target after delete.
 void setDisplayBaseDetails(boolean displayBaseDetails)
          Sets the display base details.
 void setDoBaselessMerge(boolean doBaselessMerge)
          Sets the do baseless merge.
 void setDontCopyToClient(boolean dontCopyToClient)
          Sets the dont copy to client.
 void setForceIntegration(boolean forceIntegration)
          Sets the force integration.
 void setFromFile(java.lang.String fromFile)
          Sets the from file.
 void setIntegrateAllAfterReAdd(boolean integrateAllAfterReAdd)
          Sets the integrate all after re add.
 void setIntegrateAroundDeletedRevs(boolean integrateAroundDeletedRevs)
          Sets the integrate around deleted revs.
 void setMaxFiles(int maxFiles)
          Sets the max files.
 void setPropagateType(boolean propagateType)
          Sets the propagate type.
 void setRebranchSourceAfterDelete(boolean rebranchSourceAfterDelete)
          Sets the rebranch source after delete.
 void setReverseMapping(boolean reverseMapping)
          Sets the reverse mapping.
 void setShowActionsOnly(boolean showActionsOnly)
          Sets the show actions only.
 void setToFile(java.lang.String toFile)
          Sets the to file.
 void setUseHaveRev(boolean useHaveRev)
          Sets the use have rev.
 
Methods inherited from class com.perforce.p4java.ant.tasks.ClientTask
cleanupP4, getP4Client, initP4, setP4Client
 
Methods inherited from class com.perforce.p4java.ant.tasks.ServerTask
cleanupP4Server, createGlobalOption, getGlobalOptions, getP4Server, initP4Server, initP4ServerOptions, setAllHosts, setHostName, setP4Server, setProgramName, setProgramVersion, setProtocolPropertiesFile, setProtocolProps, setTextLanguage, setUnsetClientName, setUnsetUserName, setUsagePropertiesFile, setUsageProps, setWorkingDirectory
 
Methods inherited from class com.perforce.p4java.ant.tasks.PerforceTask
addFileset, createField, createFile, execute, getFields, getFiles, getFileSpecs, getRetFileSpecs, getRetStatusMessage, init, isEmpty, logChangelistSummaries, logChangelistSummary, logExtendedFileSpec, logExtendedFileSpecs, logFileDiff, logFileDiffs, logFileLineMatch, logFileLineMatches, logFileSpec, logFileSpecs, logFix, logFixes, logJob, logJobs, parseChangelist, setCharset, setClient, setFailOnError, setFiles, setPasswd, setPort, setProtocol, setUser
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fromFile

protected java.lang.String fromFile
Source file and revision specifiers, separated by space. If the path contains whitespace, it must be double-quoted.


toFile

protected java.lang.String toFile
Target file and revision specifiers, separated by space. If the path contains whitespace, it must be double-quoted.


changelist

protected java.lang.String changelist
If positive, the integrated files are opened in the numbered pending changelist instead of the default changelist.


bidirectionalInteg

protected boolean bidirectionalInteg
Causes the branch view to work bidirectionally, where the scope of the command is limited to integrations whose 'from' files match fromFile[revRange]. Corresponds to the -s flag, with the fromFile arg being specified in the main method fromFile parameter.


integrateAroundDeletedRevs

protected boolean integrateAroundDeletedRevs
If true, enable integrations around deleted revisions; equivalent to -d (i.e. -Ds + -Di + -Dt)


rebranchSourceAfterDelete

protected boolean rebranchSourceAfterDelete
If the target file has been deleted and the source file has changed, will re-branch the source file on top of the target file. A.k.a "-Dt".


deleteTargetAfterDelete

protected boolean deleteTargetAfterDelete
If the source file has been deleted and the target file has changed, will delete the target file. A.k.a "-Ds".


integrateAllAfterReAdd

protected boolean integrateAllAfterReAdd
If the source file has been deleted and re-added, will attempt to integrate all outstanding revisions of the file, including those revisions prior to the delete. Normally 'p4 integrate' only considers revisions since the last add. A.k.a. "-Di".


forceIntegration

protected boolean forceIntegration
Forces integrate to act without regard for previous integration history. Corresponds to the -f flag.


useHaveRev

protected boolean useHaveRev
Causes the target files to be left at the revision currently on the client (the '#have' revision). Corresponds to the -h flag.


doBaselessMerge

protected boolean doBaselessMerge
Enables integration between files that have no integration history. Corresponds to the -i flag.


displayBaseDetails

protected boolean displayBaseDetails
Display the base file name and revision which will be used in subsequent resolves if a resolve is needed. Corresponds to the -o flag.


showActionsOnly

protected boolean showActionsOnly
Display what integrations would be necessary but don't actually do them. Corresponds to the -n flag.


reverseMapping

protected boolean reverseMapping
Reverse the mappings in the branch view, with the target files and source files exchanging place. Corresponds to the -r flag.


propagateType

protected boolean propagateType
Propagate the source file's filetype to the target file. Corresponds to the -t flag.


dontCopyToClient

protected boolean dontCopyToClient
Don't copy newly branched files to the client. Corresponds to the -v flag.


branch

protected java.lang.String branch
If not null, use this as the integration branch specification.


maxFiles

protected int maxFiles
If positive, integrate only the first maxFiles files. Corresponds to -m flag.


fromFileSpec

protected IFileSpec fromFileSpec
Source file and revision specifier for the Perforce command.


toFileSpec

protected IFileSpec toFileSpec
Target file and revision specifier for the Perforce command.

Constructor Detail

IntegrateTask

public IntegrateTask()
Default constructor.

Method Detail

setFromFile

public void setFromFile(java.lang.String fromFile)
Sets the from file.

Parameters:
fromFile - the new from file

setToFile

public void setToFile(java.lang.String toFile)
Sets the to file.

Parameters:
toFile - the new to file

setChangelist

public void setChangelist(java.lang.String changelist)
Sets the changelist.

Parameters:
changelist - the new changelist

setBidirectionalInteg

public void setBidirectionalInteg(boolean bidirectionalInteg)
Sets the bidirectional integ.

Parameters:
bidirectionalInteg - the new bidirectional integ

setIntegrateAroundDeletedRevs

public void setIntegrateAroundDeletedRevs(boolean integrateAroundDeletedRevs)
Sets the integrate around deleted revs.

Parameters:
integrateAroundDeletedRevs - the new integrate around deleted revs

setRebranchSourceAfterDelete

public void setRebranchSourceAfterDelete(boolean rebranchSourceAfterDelete)
Sets the rebranch source after delete.

Parameters:
rebranchSourceAfterDelete - the new rebranch source after delete

setDeleteTargetAfterDelete

public void setDeleteTargetAfterDelete(boolean deleteTargetAfterDelete)
Sets the delete target after delete.

Parameters:
deleteTargetAfterDelete - the new delete target after delete

setIntegrateAllAfterReAdd

public void setIntegrateAllAfterReAdd(boolean integrateAllAfterReAdd)
Sets the integrate all after re add.

Parameters:
integrateAllAfterReAdd - the new integrate all after re add

setForceIntegration

public void setForceIntegration(boolean forceIntegration)
Sets the force integration.

Parameters:
forceIntegration - the new force integration

setUseHaveRev

public void setUseHaveRev(boolean useHaveRev)
Sets the use have rev.

Parameters:
useHaveRev - the new use have rev

setDoBaselessMerge

public void setDoBaselessMerge(boolean doBaselessMerge)
Sets the do baseless merge.

Parameters:
doBaselessMerge - the new do baseless merge

setDisplayBaseDetails

public void setDisplayBaseDetails(boolean displayBaseDetails)
Sets the display base details.

Parameters:
displayBaseDetails - the new display base details

setShowActionsOnly

public void setShowActionsOnly(boolean showActionsOnly)
Sets the show actions only.

Parameters:
showActionsOnly - the new show actions only

setReverseMapping

public void setReverseMapping(boolean reverseMapping)
Sets the reverse mapping.

Parameters:
reverseMapping - the new reverse mapping

setPropagateType

public void setPropagateType(boolean propagateType)
Sets the propagate type.

Parameters:
propagateType - the new propagate type

setDontCopyToClient

public void setDontCopyToClient(boolean dontCopyToClient)
Sets the dont copy to client.

Parameters:
dontCopyToClient - the new dont copy to client

setBranch

public void setBranch(java.lang.String branch)
Sets the branch.

Parameters:
branch - the new branch

setMaxFiles

public void setMaxFiles(int maxFiles)
Sets the max files.

Parameters:
maxFiles - the new max files

getFromFileSpec

public IFileSpec getFromFileSpec()
Gets the from file spec.

Returns:
the from file spec

getToFileSpec

public IFileSpec getToFileSpec()
Gets the to file spec.

Returns:
the to file spec

execP4Command

protected void execP4Command()
                      throws org.apache.tools.ant.BuildException
Execute the Perforce integrate command with source and target file specs and options. Log the returned file specs.

Integrate ("merge") from one Perforce filespec to another. The semantics of Perforce merges are complex and are not explained here; please consult the main Perforce documentation for file merges and the IntegrateFilesOptions Javdoc comments for details of the less-commonly-used options.

Specified by:
execP4Command in class PerforceTask
Throws:
org.apache.tools.ant.BuildException - the build exception
See Also:
PerforceTask.execP4Command()


Copyright (c) 2010 Perforce Software. All rights reserved.