/**
* Copyright (c) 2010 Perforce Software. All rights reserved.
*/
package com.perforce.maven.scm.provider.p4.command.list;
import java.util.List;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.ScmVersion;
import org.apache.maven.scm.command.list.AbstractListCommand;
import org.apache.maven.scm.command.list.ListScmResult;
import org.apache.maven.scm.provider.ScmProviderRepository;
import com.perforce.maven.scm.provider.p4.command.P4Command;
import com.perforce.maven.scm.provider.p4.util.P4Utils;
import com.perforce.p4java.client.IClient;
import com.perforce.p4java.core.file.IFileSpec;
import com.perforce.p4java.exception.P4JavaException;
import com.perforce.p4java.option.server.GetDepotFilesOptions;
import com.perforce.p4java.server.IOptionsServer;
/**
* The class uses the Perforce files command to list details about specified files: depot file name, revision, file,
* type, change action and changelist number of the current head revision.
*/
public class P4ListCommand
extends AbstractListCommand
implements P4Command
{
/** The Constant command. */
public static final String command = "Perforce files command";
private IClient client;
public void setClient( IClient client )
{
this.client = client;
}
/**
* @see org.apache.maven.scm.command.list.AbstractListCommand
* executeListCommand(org.apache.maven.scm.provider.ScmProviderRepository, org.apache.maven.scm.ScmFileSet,
* boolean, org.apache.maven.scm.ScmVersion)
*/
protected ListScmResult executeListCommand( ScmProviderRepository repo, ScmFileSet files, boolean recursive,
ScmVersion scmVersion )
throws ScmException
{
P4ListResult p4Result = new P4ListResult();
List<IFileSpec> fileSpecs = P4Utils.scmFileSet2P4FileSpecs( files );
if ( !fileSpecs.isEmpty() )
{
try
{
GetDepotFilesOptions getDepotFilesOptions = new GetDepotFilesOptions();
IOptionsServer server = (IOptionsServer) client.getServer();
List<IFileSpec> retFileSpecs = server.getDepotFiles( fileSpecs, getDepotFilesOptions );
p4Result.process( retFileSpecs );
}
catch ( P4JavaException e )
{
throw new ScmException( e.getLocalizedMessage(), e );
}
}
if ( !p4Result.isSuccess() )
{
return new ListScmResult( command, "The files command failed.", p4Result.getCommandOutput(),
p4Result.isSuccess() );
}
return new ListScmResult( command, p4Result.getCommandResult() );
}
}
# |
Change |
User |
Description |
Committed |
|
#1
|
10055 |
Matt Attaway |
Pull over numerous changes from @dantran's branch. |
|
|
//guest/perforce_software/p4maven/main/com.perforce.maven/src/main/java/com/perforce/maven/scm/provider/p4/command/list/P4ListCommand.java |
#1
|
8496 |
Matt Attaway |
Move P4Ant and P4Maven into their proper homes |
|
|
//public/perforce/p4maven/main/com.perforce.maven/src/main/java/com/perforce/maven/scm/provider/p4/command/list/P4ListCommand.java |
#1
|
8270 |
Matt Attaway |
Initial add of P4Maven source code |
|
|