/** * Copyright (c) 2010 Perforce Software. All rights reserved. */ package com.perforce.maven.scm.provider.p4.command.unedit; import java.util.List; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmResult; import org.apache.maven.scm.command.unedit.AbstractUnEditCommand; import org.apache.maven.scm.command.unedit.UnEditScmResult; 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.RevertFilesOptions; /** * The class uses the Perforce revert command to undo changes on opened files. */ public class P4UnEditCommand extends AbstractUnEditCommand implements P4Command { /** The Constant command. */ public static final String command = "Perforce revert command"; private IClient client; public void setClient( IClient client ) { this.client = client; } /** * @see org.apache.maven.scm.command.unedit.AbstractUnEditCommand * executeUnEditCommand(org.apache.maven.scm.provider.ScmProviderRepository, org.apache.maven.scm.ScmFileSet) */ protected ScmResult executeUnEditCommand( ScmProviderRepository repo, ScmFileSet files ) throws ScmException { P4UnEditResult p4Result = new P4UnEditResult(); List<IFileSpec> fileSpecs = P4Utils.scmFileSet2P4FileSpecs( files ); if ( !fileSpecs.isEmpty() ) { try { RevertFilesOptions revertFilesOptions = new RevertFilesOptions(); List<IFileSpec> retFileSpecs = client.revertFiles( fileSpecs, revertFilesOptions ); P4Utils.checkForError( retFileSpecs, this.getLogger() ); p4Result.process( retFileSpecs ); } catch ( P4JavaException e ) { throw new ScmException( e.getLocalizedMessage(), e ); } } return new UnEditScmResult( command, p4Result.isSuccess() ? "Revert successful" : "Unable to revert", p4Result.getCommandOutput(), p4Result.isSuccess() ); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 9562 | dantran | remove P4Utils.checkForError(), it should be under P4Result.process | ||
#3 | 9548 | dantran |
- pickup P4PORT form env and system properties to support multi site using proxy - add development doc - check for error after each action |
||
#2 | 9533 | dantran | source format | ||
#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/unedit/P4UnEditCommand.java | |||||
#4 | 9295 | dantran | More migratoin using P4Utils.scmFileSet2P4FileSpecs | ||
#3 | 9251 | dantran | Use P4Utils instead of P4Executor which will be retire | ||
#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/unedit/P4UnEditCommand.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/unedit/P4UnEditCommand.java | |||||
#1 | 8270 | Matt Attaway | Initial add of P4Maven source code |