/** * Copyright (c) 2010 Perforce Software. All rights reserved. */ package com.perforce.maven.scm.provider.p4.command.checkin; import java.util.Date; 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.checkin.AbstractCheckInCommand; import org.apache.maven.scm.command.checkin.CheckInScmResult; 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.ChangelistStatus; import com.perforce.p4java.core.IChangelist; import com.perforce.p4java.core.file.IFileSpec; import com.perforce.p4java.exception.P4JavaException; import com.perforce.p4java.impl.generic.core.Changelist; import com.perforce.p4java.impl.mapbased.server.Server; import com.perforce.p4java.option.changelist.SubmitOptions; import com.perforce.p4java.option.client.ReopenFilesOptions; import com.perforce.p4java.option.server.OpenedFilesOptions; /** * The class uses the Perforce submit command to checkin files with a changelist and its associated jobs. */ public class P4CheckInCommand extends AbstractCheckInCommand implements P4Command { /** The Constant command. */ public static final String command = "Perforce submit command"; private IClient client; public void setClient( IClient client ) { this.client = client; } /** * @see org.apache.maven.scm.command.checkin.AbstractCheckInCommand executeCheckInCommand * (org.apache.maven.scm.provider.ScmProviderRepository, org.apache.maven.scm.ScmFileSet, java.lang.String, * org.apache.maven.scm.ScmVersion) */ protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, ScmFileSet files, String message, ScmVersion version ) throws ScmException { P4CheckInResult p4Result = new P4CheckInResult(); List<IFileSpec> fileSpecs = P4Utils.scmFileSet2P4FileSpecs( files ); try { //only commit when there are changes OpenedFilesOptions openedFilesOptions = new OpenedFilesOptions(); List<IFileSpec> retFileSpecs = client.openedFiles( fileSpecs, openedFilesOptions ); if ( !retFileSpecs.isEmpty() ) { Changelist newChangelistImpl = new Changelist( IChangelist.UNKNOWN, client.getName(), client.getOwnerName(), ChangelistStatus.NEW, new Date(), message, false, (Server) client.getServer() ); IChangelist retChangelist = client.createChangelist( newChangelistImpl ); ReopenFilesOptions reopenFilesOptions = new ReopenFilesOptions(); reopenFilesOptions.setChangelistId( retChangelist.getId() ); retFileSpecs = client.reopenFiles( fileSpecs, reopenFilesOptions ); if ( retChangelist.canRefresh() ) { retChangelist.refresh(); } SubmitOptions submitOptions = new SubmitOptions(); submitOptions.setJobIds( P4Utils.getJobs() ); retFileSpecs = retChangelist.submit( submitOptions ); p4Result.process( retFileSpecs ); } } catch ( P4JavaException e ) { throw new ScmException( e.getLocalizedMessage(), e ); } if ( !p4Result.isSuccess() ) { return new CheckInScmResult( command, "Unable to submit", p4Result.getCommandOutput(), p4Result.isSuccess() ); } return new CheckInScmResult( command, p4Result.getCommandResult() ); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 9549 | dantran |
only commit if there are opened files. ie we dont want accidental changelist created |
||
#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/checkin/P4CheckInCommand.java | |||||
#9 | 9498 | dantran |
- Setup Maven site for documetation - Implement ~/m2/p4maven-settings.xml to store external config overridable by system properties. All global settings now can be retrieved va P4Utils |
||
#8 | 9392 | dantran | copy over base TCK checkin test and adjust for P4 | ||
#7 | 9342 | dantran | Add CheckIn TCK | ||
#6 | 9290 | dantran | Introduce the reusable P4Utils.scmFileSet2P4FileSpecs util, and have edit and checkin command to use it | ||
#5 | 9267 | dantran | More swapping of P4Executor for P4Utils | ||
#4 | 9266 | dantran |
fixed up P4EditCommand to comply ScmFileSpec where the internal filelist is always relative to its basedir. When Creating P4 FileSpec, must convert the relative path to absolute path otherwise p4 would use it currently directory to calculate the path. Will need to apply the same principal to all commands |
||
#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/checkin/P4CheckInCommand.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/checkin/P4CheckInCommand.java | |||||
#1 | 8270 | Matt Attaway | Initial add of P4Maven source code |