/** * Copyright (c) 2010 Perforce Software. All rights reserved. */ package com.perforce.maven.scm.provider.p4.command.add; import java.io.IOException; import java.util.List; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmResult; import org.apache.maven.scm.command.add.AbstractAddCommand; import org.apache.maven.scm.command.add.AddScmResult; import org.apache.maven.scm.provider.ScmProviderRepository; import org.codehaus.plexus.util.StringUtils; 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.AddFilesOptions; /** * The class uses the Perforce add command to open new files to add to the Perforce depot. */ public class P4AddCommand extends AbstractAddCommand implements P4Command { /** The Constant command. */ public static final String command = "Perforce add command"; private IClient client; public void setClient( IClient client ) { this.client = client; } /** * @see org.apache.maven.scm.command.add.AbstractAddCommand#executeAddCommand * (org.apache.maven.scm.provider.ScmProviderRepository, org.apache.maven.scm.ScmFileSet, java.lang.String, * boolean) */ protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet files, String message, boolean binary ) throws ScmException { P4AddResult p4Result = new P4AddResult(); // Default the "includes" to the "**" pattern if ( files.getFileList().isEmpty() && StringUtils.isBlank( files.getIncludes() ) ) { try { // FIXME, comply with P4IGNORE files = new ScmFileSet( files.getBasedir(), "**", files.getExcludes() ); } catch ( IOException e ) { if ( getLogger().isErrorEnabled() ) { getLogger().error( e ); } } } List<IFileSpec> fileSpecs = P4Utils.scmFileSet2P4FileSpecsWithNoP4WildCard( files ); // Note: add command doesn't support "..." as a filespec if ( !fileSpecs.isEmpty() ) { AddFilesOptions addFilesOptions = new AddFilesOptions(); // Allow adding files with filenames that contain wildcard // characters. Filenames that contain the special characters // '@', '#', '%' or '*' are reformatted to encode the characters // using ASCII hexadecimal representation. After the files are // added, you must refer to them using the reformatted file // name, because Perforce does not recognize the local // filesystem name. addFilesOptions.setUseWildcards( true ); try { List<IFileSpec> retFileSpecs = client.addFiles( fileSpecs, addFilesOptions ); // Process the result filespecs p4Result.process( retFileSpecs ); // Process the result filespecs as additions p4Result.processAdditions( retFileSpecs ); } catch ( P4JavaException e ) { throw new ScmException( e.getLocalizedMessage(), e ); } } List<ScmFile> additions = p4Result.getAdditions(); return new AddScmResult( command, additions ); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 9680 | dantran | cleanup | ||
#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/add/P4AddCommand.java | |||||
#6 | 9476 | dantran |
- Each managed client now has its own server to prevent concurrency - Validate managed client and server instances |
||
#5 | 9422 | dantran | add update, changelog TCK | ||
#4 | 9342 | dantran | Add CheckIn TCK | ||
#3 | 9250 | dantran | caching client across mutiple commands | ||
#2 | 9177 | dantran |
Compatible with maven-scm-api-1.5+. The current 1.4 is too old |
||
#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/add/P4AddCommand.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/add/P4AddCommand.java | |||||
#1 | 8270 | Matt Attaway | Initial add of P4Maven source code |