com.perforce.p4java.ant.tasks
Class MoveTask

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.MoveTask
All Implemented Interfaces:
java.lang.Cloneable

public class MoveTask
extends ClientTask

Move file(s) from one location to another.

Move takes an already opened file and moves it from one client location to another, reopening it as a pending depot move. When the file is submitted with 'p4 submit', its depot file is moved accordingly.

Wildcards in fromFile and toFile must match. The fromFile must be a file opened for add or edit.

'p4 opened' lists pending moves. 'p4 diff' can compare a moved client file with its depot original, 'p4 sync' can schedule an update of a moved file, and 'p4 resolve' can resolve the update.

A client file may be moved many times before it is submitted. Moving a file back to its original location will undo a pending move, leaving unsubmitted content intact. Using 'p4 revert' will both undo the move and revert the unsubmitted content.

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  java.lang.String changelist
          If not IChangelist.UNKNOWN, the files are opened in the numbered pending changelist instead of the 'default' changelist.
protected  java.lang.String fileType
          If not null, the file is reopened as that filetype.
protected  boolean force
          If true, force a move to an existing target file; the file must be synced and not opened.
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 listOnly
          If true, don't actually perform the move, just return what would happen if the move was performed.
protected  boolean noClientMove
          If true, bypasses the client file rename.
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.
 
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
MoveTask()
          Default constructor.
 
Method Summary
protected  void execP4Command()
          Execute the Perforce move command with source and target file specs and options.
 IFileSpec getFromFileSpec()
          Gets the from file spec.
 IFileSpec getToFileSpec()
          Gets the to file spec.
 void setChangelist(java.lang.String changelist)
          Sets the changelist.
 void setFileType(java.lang.String fileType)
          Sets the file type.
 void setForce(boolean force)
          Sets the force.
 void setFromFile(java.lang.String fromFile)
          Sets the from file.
 void setListOnly(boolean listOnly)
          Sets the list only.
 void setNoClientMove(boolean noClientMove)
          Sets the no client move.
 void setToFile(java.lang.String toFile)
          Sets the to file.
 
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 not IChangelist.UNKNOWN, the files are opened in the numbered pending changelist instead of the 'default' changelist. Corresponds to the -c flag.


listOnly

protected boolean listOnly
If true, don't actually perform the move, just return what would happen if the move was performed. Corresponds to the -n flag.


force

protected boolean force
If true, force a move to an existing target file; the file must be synced and not opened. Note that the originating source file will no longer be synced to the client. Corresponds to the -f flag.


noClientMove

protected boolean noClientMove
If true, bypasses the client file rename. This option can be used to tell the server that the user has already renamed a file on the client. The use of this option can confuse the server if you are wrong about the client's contents. Only works for 2009.2 and later servers; earlier servers will produce a RequestException if you set this true. Corresponds to the -k flag.


fileType

protected java.lang.String fileType
If not null, the file is reopened as that filetype. Corresponds to the -t 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

MoveTask

public MoveTask()
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

setListOnly

public void setListOnly(boolean listOnly)
Sets the list only.

Parameters:
listOnly - the new list only

setForce

public void setForce(boolean force)
Sets the force.

Parameters:
force - the new force

setNoClientMove

public void setNoClientMove(boolean noClientMove)
Sets the no client move.

Parameters:
noClientMove - the new no client move

setFileType

public void setFileType(java.lang.String fileType)
Sets the file type.

Parameters:
fileType - the new file type

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 move command with source and target file specs and options. Log the returned file specs.

Move a file already opened for edit or add (the fromFile) to the destination file (the toFile). A file can be moved many times before it is submitted; moving it back to its original location will reopen it for edit. The full semantics of this operation (which can be confusing) are found in the main 'p4 help' documentation.

Note that this operation is not supported on servers earlier than 2009.1; any attempt to use this on earlier servers will result in a RequestException with a suitable message.

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.