/** * Copyright (c) 2010 Perforce Software. All rights reserved. */ package com.perforce.maven.scm.provider.p4.command.checkout; import java.util.List; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.ScmTag; import org.apache.maven.scm.ScmVersion; import org.apache.maven.scm.command.checkout.AbstractCheckOutCommand; import org.apache.maven.scm.command.checkout.CheckOutScmResult; 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.client.SyncOptions; /** * Use Perforce sync command to update files from the repository. It will create a client if none is specified. */ public class P4CheckOutCommand extends AbstractCheckOutCommand implements P4Command { /** The Constant command. */ public static final String command = "Perforce sync command"; private IClient client; public void setClient( IClient client ) { this.client = client; } /** * @see org.apache.maven.scm.command.checkout.AbstractCheckOutCommand executeCheckOutCommand * (org.apache.maven.scm.provider.ScmProviderRepository, org.apache.maven.scm.ScmFileSet, * org.apache.maven.scm.ScmVersion, boolean) */ protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet files, ScmVersion version, boolean recursive ) throws ScmException { if ( version != null && !( version instanceof ScmTag ) && version instanceof ScmBranch ) { // branch type already handled by P4ScmProvider version = null; } P4CheckOutResult p4Result = new P4CheckOutResult(); List<IFileSpec> fileSpecs = P4Utils.scmFileSet2P4FileSpecs( files, version ); try { SyncOptions syncOptions = new SyncOptions( false, false, false, false ); String[] filesList = files.getBasedir().list(); if ( filesList == null || filesList.length == 0 ) { syncOptions.setForceUpdate( true ); } List<IFileSpec> retFileSpecs = client.sync( fileSpecs, syncOptions ); P4Utils.checkForError( retFileSpecs, this.getLogger() ); p4Result.process( retFileSpecs ); // perforce return all files including deleted one, so we need to remove it form result set p4Result.removeResultStatusType( ScmFileStatus.DELETED ); } catch ( P4JavaException e ) { throw new ScmException( e.getLocalizedMessage(), e ); } if ( !p4Result.isSuccess() ) { return new CheckOutScmResult( command, "The sync command failed.", p4Result.getCommandOutput(), p4Result.isSuccess() ); } return new CheckOutScmResult( command, p4Result.getCommandResult() ); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 9562 | dantran | remove P4Utils.checkForError(), it should be under P4Result.process | ||
#2 | 9548 | dantran |
- pickup P4PORT form env and system properties to support multi site using proxy - add development doc - check for error after each action |
||
#1 | 9519 | dantran | folder rename to match with its artifactId | ||
//guest/dantran/p4maven/com.perforce.maven/src/main/java/com/perforce/maven/scm/provider/p4/command/checkout/P4CheckOutCommand.java | |||||
#6 | 9486 | dantran | Simplify update command and rely on AbstractUpdateCommand to gather the ChangeSet | ||
#5 | 9471 | dantran |
- cleanup diff command - simplify branch command and full compliant with maven-scm-test - add checkout with branch - add repo's path as client manager lookup key in addition to p4port and rootdir so that we can handle mutiple clients on the same rootdir |
||
#4 | 9423 | dantran | get all test to use the same setup, handle checkout with tag, need to revisit how we handle ScmVersion | ||
#3 | 9422 | dantran | add update, changelog TCK | ||
#2 | 9250 | dantran | caching client across mutiple commands | ||
#1 | 9167 | dantran |
Populate //guest/dantran/p4maven/... from //guest/perforce_software/p4maven/main/.... |
||
//guest/perforce_software/p4maven/main/com.perforce.maven/src/main/java/com/perforce/maven/scm/provider/p4/command/checkout/P4CheckOutCommand.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/checkout/P4CheckOutCommand.java | |||||
#1 | 8270 | Matt Attaway | Initial add of P4Maven source code |