maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r349435 [1/3] - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src: main/java/org/apache/maven/scm/provider/perforce/ main/java/org/apache/maven/scm/provider/perforce/command/ main/java/org/apache/maven/scm/provider/per...
Date Mon, 28 Nov 2005 17:02:13 GMT
Author: evenisse
Date: Mon Nov 28 09:01:05 2005
New Revision: 349435

URL: http://svn.apache.org/viewcvs?rev=349435&view=rev
Log:
[SCM-79] Add remaining operations to Perforce provider

Added:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/AbstractPerforceConsumer.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/PerforceVerbMapper.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddConsumer.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInConsumer.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumer.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffConsumer.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditConsumer.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginConsumer.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveConsumer.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusConsumer.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagConsumer.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditConsumer.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/PerforceUpdateCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/PerforceUpdateConsumer.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddCommandTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddConsumerTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommandTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInConsumerTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommandTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumerTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommandTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffConsumerTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommandTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditConsumerTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/login/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommandTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginConsumerTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/remove/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveCommandTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveConsumerTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/status/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusCommandTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusConsumerTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/tag/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommandTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagConsumerTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/unedit/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditCommandTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditConsumerTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/addlog.txt   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/checkin_bad.txt   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/checkin_good.txt   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/checkout_bad.txt   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/checkout_good.txt   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/difflog.txt   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/editlog.txt   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/login_bad.txt   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/login_good.txt   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/removelog.txt   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/status_good.txt   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/tag_bad.txt   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/tag_good.txt   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/unedit_bad.txt   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/resources/perforce/unedit_good.txt   (with props)
Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/PerforceScmProvider.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogCommand.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/PerforceScmProvider.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/PerforceScmProvider.java?rev=349435&r1=349434&r2=349435&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/PerforceScmProvider.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/PerforceScmProvider.java Mon Nov 28 09:01:05 2005
@@ -16,19 +16,44 @@
  * limitations under the License.
  */
 
+import java.io.File;
+
 import org.apache.maven.scm.CommandParameters;
 import org.apache.maven.scm.ScmException;
 import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.add.AddScmResult;
 import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
+import org.apache.maven.scm.command.checkin.CheckInScmResult;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
+import org.apache.maven.scm.command.diff.DiffScmResult;
+import org.apache.maven.scm.command.edit.EditScmResult;
+import org.apache.maven.scm.command.remove.RemoveScmResult;
+import org.apache.maven.scm.command.status.StatusScmResult;
+import org.apache.maven.scm.command.tag.TagScmResult;
+import org.apache.maven.scm.command.unedit.UnEditScmResult;
+import org.apache.maven.scm.command.update.UpdateScmResult;
+import org.apache.maven.scm.login.LoginScmResult;
 import org.apache.maven.scm.provider.AbstractScmProvider;
 import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.perforce.command.add.PerforceAddCommand;
 import org.apache.maven.scm.provider.perforce.command.changelog.PerforceChangeLogCommand;
+import org.apache.maven.scm.provider.perforce.command.checkin.PerforceCheckInCommand;
+import org.apache.maven.scm.provider.perforce.command.checkout.PerforceCheckOutCommand;
+import org.apache.maven.scm.provider.perforce.command.diff.PerforceDiffCommand;
+import org.apache.maven.scm.provider.perforce.command.edit.PerforceEditCommand;
+import org.apache.maven.scm.provider.perforce.command.login.PerforceLoginCommand;
+import org.apache.maven.scm.provider.perforce.command.remove.PerforceRemoveCommand;
+import org.apache.maven.scm.provider.perforce.command.status.PerforceStatusCommand;
+import org.apache.maven.scm.provider.perforce.command.tag.PerforceTagCommand;
+import org.apache.maven.scm.provider.perforce.command.unedit.PerforceUnEditCommand;
+import org.apache.maven.scm.provider.perforce.command.update.PerforceUpdateCommand;
 import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
 import org.apache.maven.scm.repository.ScmRepository;
 import org.apache.maven.scm.repository.ScmRepositoryException;
+import org.codehaus.plexus.util.cli.Commandline;
 
 /**
- * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l </a>
  * @version $Id$
  */
 public class PerforceScmProvider
@@ -42,31 +67,24 @@
         throws ScmRepositoryException
     {
         String path;
-
         int port = 0;
-
         String host = null;
 
         int i1 = scmSpecificUrl.indexOf( delimiter );
-
         int i2 = scmSpecificUrl.indexOf( delimiter, i1 + 1 );
 
         if ( i1 > 0 )
         {
             int lastDelimiter = scmSpecificUrl.lastIndexOf( delimiter );
-
             path = scmSpecificUrl.substring( lastDelimiter + 1 );
-
             host = scmSpecificUrl.substring( 0, i1 );
 
             // If there is tree parts in the scm url, the second is the port
-
             if ( i2 >= 0 )
             {
                 try
                 {
                     String tmp = scmSpecificUrl.substring( i1 + 1, lastDelimiter );
-
                     port = Integer.parseInt( tmp );
                 }
                 catch ( NumberFormatException ex )
@@ -81,13 +99,10 @@
         }
 
         String user = null;
-
         String password = null;
-
         if ( host != null && host.indexOf( "@" ) > 1 )
         {
             user = host.substring( 0, host.indexOf( "@" ) );
-
             host = host.substring( host.indexOf( "@" ) + 1 );
         }
 
@@ -95,12 +110,12 @@
         {
             if ( host != null )
             {
-                getLogger().warn( "Username as part of path is deprecated, the new format is "
-                                  + "scm:perforce:[username@]host:port:path_to_repository" );
+                getLogger().warn(
+                                  "Username as part of path is deprecated, the new format is "
+                                      + "scm:perforce:[username@]host:port:path_to_repository" );
             }
 
             user = path.substring( 0, path.indexOf( "@" ) );
-
             path = path.substring( path.indexOf( "@" ) + 1 );
         }
 
@@ -113,16 +128,134 @@
     }
 
     /**
-     * @see org.apache.maven.scm.provider.AbstractScmProvider#changelog(org.apache.maven.scm.repository.ScmRepository, org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.CommandParameters)
+     * @see org.apache.maven.scm.provider.AbstractScmProvider#changelog(org.apache.maven.scm.repository.ScmRepository,
+     *      org.apache.maven.scm.ScmFileSet,
+     *      org.apache.maven.scm.CommandParameters)
      */
-    public ChangeLogScmResult changelog( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+    protected ChangeLogScmResult changelog( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters )
         throws ScmException
     {
         PerforceChangeLogCommand command = new PerforceChangeLogCommand();
+        command.setLogger( getLogger() );
+        return (ChangeLogScmResult) command.execute( repository.getProviderRepository(), fileSet, parameters );
+    }
 
+    protected AddScmResult add( ScmRepository repository, ScmFileSet fileSet, CommandParameters params )
+        throws ScmException
+    {
+        PerforceAddCommand command = new PerforceAddCommand();
         command.setLogger( getLogger() );
+        return (AddScmResult) command.execute( repository.getProviderRepository(), fileSet, params );
+    }
 
-        return (ChangeLogScmResult) command.execute( repository.getProviderRepository(), fileSet, parameters );
+    protected RemoveScmResult remove( ScmRepository repository, ScmFileSet fileSet, CommandParameters params )
+        throws ScmException
+    {
+        PerforceRemoveCommand command = new PerforceRemoveCommand();
+        command.setLogger( getLogger() );
+        return (RemoveScmResult) command.execute( repository.getProviderRepository(), fileSet, params );
+    }
+
+    protected CheckInScmResult checkin( ScmRepository repository, ScmFileSet fileSet, CommandParameters params )
+        throws ScmException
+    {
+        PerforceCheckInCommand command = new PerforceCheckInCommand();
+        command.setLogger( getLogger() );
+        return (CheckInScmResult) command.execute( repository.getProviderRepository(), fileSet, params );
+    }
+
+    protected CheckOutScmResult checkout( ScmRepository repository, ScmFileSet fileSet, CommandParameters params )
+        throws ScmException
+    {
+        PerforceCheckOutCommand command = new PerforceCheckOutCommand();
+        command.setLogger( getLogger() );
+        return (CheckOutScmResult) command.execute( repository.getProviderRepository(), fileSet, params );
+    }
+
+    protected DiffScmResult diff( ScmRepository repository, ScmFileSet fileSet, CommandParameters params )
+        throws ScmException
+    {
+        PerforceDiffCommand command = new PerforceDiffCommand();
+        command.setLogger( getLogger() );
+        return (DiffScmResult) command.execute( repository.getProviderRepository(), fileSet, params );
+    }
+
+    protected EditScmResult edit( ScmRepository repository, ScmFileSet fileSet, CommandParameters params )
+        throws ScmException
+    {
+        PerforceEditCommand command = new PerforceEditCommand();
+        command.setLogger( getLogger() );
+        return (EditScmResult) command.execute( repository.getProviderRepository(), fileSet, params );
+    }
+
+    protected LoginScmResult login( ScmRepository repository, ScmFileSet fileSet, CommandParameters params )
+        throws ScmException
+    {
+        PerforceLoginCommand command = new PerforceLoginCommand();
+        command.setLogger( getLogger() );
+        return (LoginScmResult) command.execute( repository.getProviderRepository(), fileSet, params );
+    }
+
+    protected StatusScmResult status( ScmRepository repository, ScmFileSet fileSet, CommandParameters params )
+        throws ScmException
+    {
+        PerforceStatusCommand command = new PerforceStatusCommand();
+        command.setLogger( getLogger() );
+        return (StatusScmResult) command.execute( repository.getProviderRepository(), fileSet, params );
+    }
+
+    protected TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, CommandParameters params )
+        throws ScmException
+    {
+        PerforceTagCommand command = new PerforceTagCommand();
+        command.setLogger( getLogger() );
+        return (TagScmResult) command.execute( repository.getProviderRepository(), fileSet, params );
+    }
+
+    protected UnEditScmResult unedit( ScmRepository repository, ScmFileSet fileSet, CommandParameters params )
+        throws ScmException
+    {
+        PerforceUnEditCommand command = new PerforceUnEditCommand();
+        command.setLogger( getLogger() );
+        return (UnEditScmResult) command.execute( repository.getProviderRepository(), fileSet, params );
+    }
+
+    protected UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, CommandParameters params )
+        throws ScmException
+    {
+        PerforceUpdateCommand command = new PerforceUpdateCommand();
+        command.setLogger( getLogger() );
+        return (UpdateScmResult) command.execute( repository.getProviderRepository(), fileSet, params );
     }
 
+    public static Commandline createP4Command( PerforceScmProviderRepository repo, File workingDir )
+    {
+        Commandline command = new Commandline();
+        command.setExecutable( "p4" );
+        command.setWorkingDirectory( workingDir.getAbsolutePath() );
+
+        if ( repo.getHost() != null )
+        {
+            command.createArgument().setValue( "-H" );
+            String value = repo.getHost();
+            if ( repo.getPort() != 0 )
+            {
+                value += ":" + Integer.toString( repo.getPort() );
+            }
+            command.createArgument().setValue( value );
+        }
+
+        if ( repo.getUser() != null )
+        {
+            command.createArgument().setValue( "-u" );
+            command.createArgument().setValue( repo.getUser() );
+        }
+
+        if ( repo.getPassword() != null )
+        {
+            command.createArgument().setValue( "-P" );
+            command.createArgument().setValue( repo.getPassword() );
+        }
+        return command;
+    }
 }

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/AbstractPerforceConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/AbstractPerforceConsumer.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/AbstractPerforceConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/AbstractPerforceConsumer.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,26 @@
+package org.apache.maven.scm.provider.perforce.command;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * @author mperham
+ * @version $Id$
+ */
+public abstract class AbstractPerforceConsumer
+    implements StreamConsumer
+{
+    private StringWriter out = new StringWriter();
+
+    protected PrintWriter output = new PrintWriter( out );
+
+    public String getOutput()
+    {
+        output.flush();
+        out.flush();
+        return out.toString();
+    }
+
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/AbstractPerforceConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/AbstractPerforceConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/PerforceVerbMapper.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/PerforceVerbMapper.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/PerforceVerbMapper.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/PerforceVerbMapper.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,35 @@
+package org.apache.maven.scm.provider.perforce.command;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.scm.ScmFileStatus;
+
+/**
+ * @author mperham
+ * @version $Id$
+ */
+public class PerforceVerbMapper
+{
+    private static final Map map = new HashMap();
+
+    static
+    {
+        map.put( "add", ScmFileStatus.ADDED );
+        map.put( "delete", ScmFileStatus.DELETED );
+        map.put( "edit", ScmFileStatus.MODIFIED );
+    }
+
+    public static ScmFileStatus toStatus( String verb )
+    {
+        ScmFileStatus stat = (ScmFileStatus) map.get( verb );
+        if ( stat == null )
+        {
+            // XXX testing only
+            System.err.println( "No such verb: " + verb );
+            return ScmFileStatus.UNKNOWN;
+        }
+        return stat;
+    }
+
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/PerforceVerbMapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/PerforceVerbMapper.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddCommand.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddCommand.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,106 @@
+package org.apache.maven.scm.provider.perforce.command.add;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.maven.scm.ScmException;
+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.apache.maven.scm.provider.perforce.PerforceScmProvider;
+import org.apache.maven.scm.provider.perforce.command.PerforceCommand;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
+ *          evenisse $
+ */
+public class PerforceAddCommand
+    extends AbstractAddCommand
+    implements PerforceCommand
+{
+
+    protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet files, String message, boolean binary )
+        throws ScmException
+    {
+        Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files );
+        PerforceAddConsumer consumer = new PerforceAddConsumer();
+        try
+        {
+            Process proc = cl.execute();
+            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream() ) );
+            String line = null;
+            while ( ( line = br.readLine() ) != null )
+            {
+                consumer.consumeLine( line );
+            }
+        }
+        catch ( CommandLineException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+
+        return new AddScmResult( cl.toString(), consumer.getAdditions() );
+    }
+
+    public static Commandline createCommandLine( PerforceScmProviderRepository repo, File workingDirectory,
+                                                ScmFileSet files )
+    {
+        Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory );
+
+        command.createArgument().setValue( "add" );
+
+        try
+        {
+            String candir = workingDirectory.getCanonicalPath();
+            File[] fs = files.getFiles();
+            for ( int i = 0; i < fs.length; i++ )
+            {
+                File file = fs[i];
+                // I want to use relative paths to add files to make testing
+                // simpler.
+                // Otherwise the absolute path will be different on everyone's
+                // machine
+                // and testing will be a little more painful.
+                String canfile = file.getCanonicalPath();
+                if ( canfile.startsWith( candir ) )
+                {
+                    canfile = canfile.substring( candir.length() + 1 );
+                }
+                command.createArgument().setValue( file.getName() );
+            }
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+        return command;
+    }
+}
\ No newline at end of file

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddConsumer.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddConsumer.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,81 @@
+package org.apache.maven.scm.provider.perforce.command.add;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogConsumer.java 331276 2005-11-07 15:04:54Z
+ *          evenisse $
+ */
+public class PerforceAddConsumer
+    implements StreamConsumer
+{
+
+    private static final String PATTERN = "^([^#]+)#1 - (.*)";
+
+    private static final String FILE_BEGIN_TOKEN = "//";
+
+    private List additions = new ArrayList();
+
+    private RE revisionRegexp;
+
+    public PerforceAddConsumer()
+    {
+        try
+        {
+            revisionRegexp = new RE( PATTERN );
+        }
+        catch ( RESyntaxException ignored )
+        {
+            ignored.printStackTrace();
+        }
+    }
+
+    public List getAdditions()
+    {
+        return additions;
+    }
+
+    public void consumeLine( String line )
+    {
+        if ( line.startsWith( "... " ) )
+        {
+            //TODO log this somehow?
+            //System.out.println("Perforce: " + line);
+            return;
+        }
+
+        if ( !line.startsWith( FILE_BEGIN_TOKEN ) )
+        {
+            throw new IllegalStateException( "Unknown error: " + line );
+        }
+
+        if ( !revisionRegexp.match( line ) )
+        {
+            throw new IllegalStateException( "Unknown input: " + line );
+        }
+
+        additions.add( revisionRegexp.getParen( 1 ) );
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogCommand.java?rev=349435&r1=349434&r2=349435&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogCommand.java Mon Nov 28 09:01:05 2005
@@ -24,6 +24,7 @@
 import org.apache.maven.scm.command.changelog.AbstractChangeLogCommand;
 import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
 import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
 import org.apache.maven.scm.provider.perforce.command.PerforceCommand;
 import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
 
@@ -58,46 +59,11 @@
 
     public static Commandline createCommandLine( PerforceScmProviderRepository repo, File workingDirectory )
     {
-        Commandline command = new Commandline();
-
-        command.setExecutable( "p4" );
-
-        command.setWorkingDirectory( workingDirectory.getAbsolutePath() );
-
-        if ( repo.getHost() != null )
-        {
-            command.createArgument().setValue( "-H" );
-
-            String value = repo.getHost();
-
-            if ( repo.getPort() != 0 )
-            {
-                value += ":" + Integer.toString( repo.getPort() );
-            }
-
-            command.createArgument().setValue( value );
-        }
-
-        if ( repo.getUser() != null )
-        {
-            command.createArgument().setValue( "-u" );
-
-            command.createArgument().setValue( repo.getUser() );
-        }
-
-        if ( repo.getPassword() != null )
-        {
-            command.createArgument().setValue( "-P" );
-
-            command.createArgument().setValue( repo.getPassword() );
-        }
+        Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory );
 
         command.createArgument().setValue( "filelog" );
-
         command.createArgument().setValue( "-t" );
-
         command.createArgument().setValue( "-l" );
-
         command.createArgument().setValue( repo.getPath() );
 
         return command;

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommand.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommand.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,126 @@
+package org.apache.maven.scm.provider.perforce.command.checkin;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.checkin.AbstractCheckInCommand;
+import org.apache.maven.scm.command.checkin.CheckInScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
+import org.apache.maven.scm.provider.perforce.command.PerforceCommand;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
+ *          evenisse $
+ */
+public class PerforceCheckInCommand
+    extends AbstractCheckInCommand
+    implements PerforceCommand
+{
+
+    protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, ScmFileSet files, String message,
+                                                     String something )
+        throws ScmException
+    {
+        Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files );
+        PerforceCheckInConsumer consumer = new PerforceCheckInConsumer();
+        try
+        {
+            Process proc = cl.execute();
+            DataOutputStream dos = new DataOutputStream( proc.getOutputStream() );
+            dos.writeUTF( createChangeListSpecification( (PerforceScmProviderRepository) repo, files, message ) );
+            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream() ) );
+            String line = null;
+            while ( ( line = br.readLine() ) != null )
+            {
+                consumer.consumeLine( line );
+            }
+        }
+        catch ( CommandLineException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+
+        return new CheckInScmResult( cl.toString(), consumer.isSuccess() ? "Checkin successful" : "Unable to submit",
+                                     consumer.getOutput(), consumer.isSuccess() );
+    }
+
+    public static Commandline createCommandLine( PerforceScmProviderRepository repo, File workingDirectory,
+                                                ScmFileSet files )
+    {
+        Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory );
+
+        command.createArgument().setValue( "submit" );
+        command.createArgument().setValue( "-i" );
+        return command;
+    }
+
+    private static final String NEWLINE = "\r\n";
+
+    public static String createChangeListSpecification( PerforceScmProviderRepository repo, ScmFileSet files, String msg )
+    {
+        StringBuffer buf = new StringBuffer();
+        buf.append( "Change: new" ).append( NEWLINE ).append( NEWLINE );
+        buf.append( "Description:" ).append( NEWLINE ).append( "\t" ).append( msg ).append( NEWLINE ).append( NEWLINE );
+        buf.append( "Files:" ).append( NEWLINE );
+        try
+        {
+            File workingDir = files.getBasedir();
+            String candir = workingDir.getCanonicalPath();
+            File[] fs = files.getFiles();
+            for ( int i = 0; i < fs.length; i++ )
+            {
+                File file = fs[i];
+                // XXX Submit requires the canonical repository path for each
+                // file.
+                // It is unclear how to get that from a File object.
+                // We assume the repo object has the relative prefix
+                // "//depot/some/project"
+                // and canfile has the relative path "src/foo.xml" to be added
+                // to that prefix.
+                // "//depot/some/project/src/foo.xml"
+                String canfile = file.getCanonicalPath();
+                if ( canfile.startsWith( candir ) )
+                {
+                    canfile = canfile.substring( candir.length() + 1 );
+                }
+                buf.append( "\t" ).append( repo.getPath() ).append( "/" ).append( canfile.replace( '\\', '/' ) )
+                    .append( NEWLINE );
+            }
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+        return buf.toString();
+    }
+}
\ No newline at end of file

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInConsumer.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInConsumer.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,169 @@
+package org.apache.maven.scm.provider.perforce.command.checkin;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogConsumer.java 331276 2005-11-07 15:04:54Z
+ *          evenisse $
+ */
+public class PerforceCheckInConsumer
+    implements StreamConsumer
+{
+    private static final String CREATED_PATTERN = "^Change \\d+ created .+$";
+
+    private static final String SUBMITTING_PATTERN = "^Submitting change \\d+\\.$";
+
+    private static final String LOCKING_PATTERN = "^Locking \\d+ files \\.\\.\\.$";
+
+    private static final String OP_PATTERN = "^[a-z]+ //[^#]+#\\d+$";
+
+    private static final String COMPLETE_PATTERN = "^Change \\d+ submitted.$";
+
+    public static final int STATE_CREATED = 1;
+
+    public static final int STATE_SUBMITTING = 2;
+
+    public static final int STATE_LOCKING = 3;
+
+    public static final int STATE_OP = 4;
+
+    public static final int STATE_COMPLETE = 5;
+
+    public static final int STATE_ERROR = 6;
+
+    private StringWriter errors = new StringWriter();
+
+    private PrintWriter errorOutput = new PrintWriter( errors );
+
+    private int currentState = STATE_CREATED;
+
+    private RE opRegexp;
+
+    public PerforceCheckInConsumer()
+    {
+        try
+        {
+            opRegexp = new RE( OP_PATTERN );
+        }
+        catch ( RESyntaxException ignored )
+        {
+            ignored.printStackTrace();
+        }
+    }
+
+    /*
+     * Change 80835 created with 1 open file(s). Submitting change 80835.
+     * Locking 1 files ... add //depot/modules/cordoba/runtime-ear/foo.xml#1
+     * Change 80835 submitted.
+     */
+    /*
+     * Submitting change 80837. Locking 1 files ... edit
+     * //depot/modules/cordoba/runtime-ear/Foo.java#2 Submit validation failed --
+     * fix problems then use 'p4 submit -c 80837'. 'checkstyle' validation
+     * failed:
+     * 
+     * depot/modules/cordoba/runtime-ear/Foo.java:3:1: Got an exception -
+     * expecting EOF, found '}'
+     */
+    public void consumeLine( String line )
+    {
+        if ( line.startsWith( "... " ) )
+        {
+            //TODO log this somehow?
+            //System.out.println("Perforce: " + line);
+            return;
+        }
+
+        switch ( currentState )
+        {
+            case STATE_CREATED:
+                boolean created = new RE( CREATED_PATTERN ).match( line );
+                if ( created )
+                {
+                    currentState++;
+                    break;
+                }
+                error( line );
+                break;
+            case STATE_SUBMITTING:
+                boolean submitting = new RE( SUBMITTING_PATTERN ).match( line );
+                if ( submitting )
+                {
+                    currentState++;
+                    break;
+                }
+                error( line );
+                break;
+            case STATE_LOCKING:
+                boolean locked = new RE( LOCKING_PATTERN ).match( line );
+                if ( locked )
+                {
+                    currentState++;
+                    break;
+                }
+                error( line );
+                break;
+            case STATE_OP:
+                boolean operation = opRegexp.match( line );
+                if ( operation )
+                {
+                    break;
+                }
+                else if ( new RE( COMPLETE_PATTERN ).match( line ) )
+                {
+                    currentState++;
+                    break;
+                }
+                error( line );
+                break;
+            case STATE_ERROR:
+                error( line );
+                break;
+        }
+    }
+
+    private void error( String line )
+    {
+        //        if (currentState != STATE_ERROR) {
+        //            System.out.println("Unable to match: " + line + " State: " +
+        // currentState);
+        //            new Exception().printStackTrace();
+        //        }
+        currentState = STATE_ERROR;
+        errorOutput.println( line );
+    }
+
+    public boolean isSuccess()
+    {
+        return currentState == STATE_COMPLETE;
+    }
+
+    public String getOutput()
+    {
+        errorOutput.flush();
+        errors.flush();
+        return errors.toString();
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommand.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommand.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,86 @@
+package org.apache.maven.scm.provider.perforce.command.checkout;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.checkout.AbstractCheckOutCommand;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
+import org.apache.maven.scm.provider.perforce.command.PerforceCommand;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
+ *          evenisse $
+ */
+public class PerforceCheckOutCommand
+    extends AbstractCheckOutCommand
+    implements PerforceCommand
+{
+
+    protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet files, String tag )
+        throws ScmException
+    {
+        Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), tag );
+        PerforceCheckOutConsumer consumer = new PerforceCheckOutConsumer();
+        try
+        {
+            Process proc = cl.execute();
+            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream() ) );
+            String line = null;
+            while ( ( line = br.readLine() ) != null )
+            {
+                consumer.consumeLine( line );
+            }
+        }
+        catch ( CommandLineException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+
+        return new CheckOutScmResult( cl.toString(), consumer.isSuccess() ? "Checkout successful" : "Unable to sync",
+                                      consumer.getOutput(), consumer.isSuccess() );
+    }
+
+    public static Commandline createCommandLine( PerforceScmProviderRepository repo, File workingDirectory, String tag )
+    {
+        Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory );
+
+        command.createArgument().setValue( "sync" );
+        // Not sure what to do here. I'm unclear whether we should be
+        // sync'ing each file individually to the label or just sync the
+        // entire contents of the workingDir. I'm going to assume the
+        // latter until the exact semantics are clearer.
+        command.createArgument().setValue( "..." + ( tag != null ? "@" + tag : "" ) );
+        return command;
+    }
+
+}
\ No newline at end of file

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumer.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumer.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,77 @@
+package org.apache.maven.scm.provider.perforce.command.checkout;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.provider.perforce.command.AbstractPerforceConsumer;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogConsumer.java 331276 2005-11-07 15:04:54Z
+ *          evenisse $
+ */
+public class PerforceCheckOutConsumer
+    extends AbstractPerforceConsumer
+    implements StreamConsumer
+{
+
+    public static final int STATE_NORMAL = 1;
+
+    public static final int STATE_ERROR = 2;
+
+    private int currentState = STATE_NORMAL;
+
+    /*
+     * //depot/modules/cordoba/runtime-ear/.j2ee#1 - deleted as
+     * d:\perforce\depot\modules\cordoba\runtime-ear\.j2ee
+     * //depot/modules/cordoba/runtime-ear/.project#1 - deleted as
+     * d:\perforce\depot\modules\cordoba\runtime-ear\.project
+     * //depot/modules/cordoba/runtime-ear/.runtime#1 - deleted as
+     * d:\perforce\depot\modules\cordoba\runtime-ear\.runtime
+     * //depot/modules/cordoba/runtime-ear/Foo.java#1 - deleted as
+     * d:\perforce\depot\modules\cordoba\runtime-ear\Foo.java
+     * //depot/modules/cordoba/runtime-ear/META-INF/.modulemaps#1 - deleted as
+     * d:\perforce\depot\modules\cordoba\runtime-ear\META-INF\.modulemaps
+     * //depot/modules/cordoba/runtime-ear/META-INF/application.xml#1 - deleted
+     * as d:\perforce\depot\modules\cordoba\runtime-ear\META-INF\application.xml
+     * //depot/modules/cordoba/runtime-ear/pom.xml#4 - deleted as
+     * d:\perforce\depot\modules\cordoba\runtime-ear\pom.xml
+     */
+    /*
+     * Invalid changelist/client/label/date '@somelabel'.
+     */
+    public void consumeLine( String line )
+    {
+        if ( currentState != STATE_ERROR && line.startsWith( "//" ) )
+        {
+            return;
+        }
+
+        error( line );
+    }
+
+    private void error( String line )
+    {
+        currentState = STATE_ERROR;
+        output.println( line );
+    }
+
+    public boolean isSuccess()
+    {
+        return currentState == STATE_NORMAL;
+    }
+}
\ No newline at end of file

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommand.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommand.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,93 @@
+package org.apache.maven.scm.provider.perforce.command.diff;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.diff.AbstractDiffCommand;
+import org.apache.maven.scm.command.diff.DiffScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
+import org.apache.maven.scm.provider.perforce.command.PerforceCommand;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
+ *          evenisse $
+ */
+public class PerforceDiffCommand
+    extends AbstractDiffCommand
+    implements PerforceCommand
+{
+
+    protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet files, String startRev,
+                                               String endRev )
+        throws ScmException
+    {
+        Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), startRev, endRev );
+        PerforceDiffConsumer consumer = new PerforceDiffConsumer();
+        boolean success = false;
+        try
+        {
+            Process proc = cl.execute();
+            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream() ) );
+            String line = null;
+            while ( ( line = br.readLine() ) != null )
+            {
+                consumer.consumeLine( line );
+            }
+            success = proc.waitFor() == 0;
+        }
+        catch ( CommandLineException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( InterruptedException e )
+        {
+            e.printStackTrace();
+        }
+
+        return new DiffScmResult( cl.toString(), success ? "Diff successful" : "Unable to diff", consumer
+            .getOutput(), success );
+    }
+
+    public static Commandline createCommandLine( PerforceScmProviderRepository repo, File workingDirectory,
+                                                String startRev, String endRev )
+    {
+        Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory );
+
+        command.createArgument().setValue( "diff2" );
+        command.createArgument().setValue( "-u" );
+        // I'm assuming the "revs" are actually labels
+        command.createArgument().setValue( "..." + ( startRev != null ? "@" + startRev : "" ) );
+        command.createArgument().setValue( "...@" + ( endRev != null ? endRev : "head" ) );
+        return command;
+    }
+
+}
\ No newline at end of file

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffConsumer.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffConsumer.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,56 @@
+package org.apache.maven.scm.provider.perforce.command.diff;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogConsumer.java 331276 2005-11-07 15:04:54Z
+ *          evenisse $
+ */
+public class PerforceDiffConsumer
+    implements StreamConsumer
+{
+    private StringWriter out = new StringWriter();
+
+    private PrintWriter output = new PrintWriter( out );
+
+    /*
+     * I don't see any easy way to distinguish between an error and
+     * normal diff output.  I see two possibilities:
+     * 
+     * 1) Use the p4 global "-s" parameter
+     * 2) Check for a non-zero code returned by the p4 process
+     * 
+     * We'll do the latter as it's simpler to implement.
+     */
+    public void consumeLine( String line )
+    {
+        output.println( line );
+    }
+
+    public String getOutput()
+    {
+        output.flush();
+        out.flush();
+        return out.toString();
+    }
+}
\ No newline at end of file

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommand.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommand.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,106 @@
+package org.apache.maven.scm.provider.perforce.command.edit;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.edit.AbstractEditCommand;
+import org.apache.maven.scm.command.edit.EditScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
+import org.apache.maven.scm.provider.perforce.command.PerforceCommand;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
+ *          evenisse $
+ */
+public class PerforceEditCommand
+    extends AbstractEditCommand
+    implements PerforceCommand
+{
+
+    protected ScmResult executeEditCommand( ScmProviderRepository repo, ScmFileSet files )
+        throws ScmException
+    {
+        Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files );
+        PerforceEditConsumer consumer = new PerforceEditConsumer();
+        try
+        {
+            Process proc = cl.execute();
+            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream() ) );
+            String line = null;
+            while ( ( line = br.readLine() ) != null )
+            {
+                consumer.consumeLine( line );
+            }
+        }
+        catch ( CommandLineException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+
+        return new EditScmResult( cl.toString(), consumer.getEdits() );
+    }
+
+    public static Commandline createCommandLine( PerforceScmProviderRepository repo, File workingDirectory,
+                                                ScmFileSet files )
+    {
+        Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory );
+
+        command.createArgument().setValue( "edit" );
+
+        try
+        {
+            String candir = workingDirectory.getCanonicalPath();
+            File[] fs = files.getFiles();
+            for ( int i = 0; i < fs.length; i++ )
+            {
+                File file = fs[i];
+                // I want to use relative paths to add files to make testing
+                // simpler.
+                // Otherwise the absolute path will be different on everyone's
+                // machine
+                // and testing will be a little more painful.
+                String canfile = file.getCanonicalPath();
+                if ( canfile.startsWith( candir ) )
+                {
+                    canfile = canfile.substring( candir.length() + 1 );
+                }
+                command.createArgument().setValue( file.getName() );
+            }
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+        return command;
+    }
+}
\ No newline at end of file

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditConsumer.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditConsumer.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,97 @@
+package org.apache.maven.scm.provider.perforce.command.edit;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.provider.perforce.command.AbstractPerforceConsumer;
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogConsumer.java 331276 2005-11-07 15:04:54Z
+ *          evenisse $
+ */
+public class PerforceEditConsumer
+    extends AbstractPerforceConsumer
+    implements StreamConsumer
+{
+
+    private static final String PATTERN = "^([^#]+)#\\d+ - (.*)";
+
+    private static final String FILE_BEGIN_TOKEN = "//";
+
+    private List edits = new ArrayList();
+
+    private RE revisionRegexp;
+
+    private boolean errors = false;
+
+    public PerforceEditConsumer()
+    {
+        try
+        {
+            revisionRegexp = new RE( PATTERN );
+        }
+        catch ( RESyntaxException ignored )
+        {
+            ignored.printStackTrace();
+        }
+    }
+
+    public List getEdits()
+    {
+        return edits;
+    }
+
+    public void consumeLine( String line )
+    {
+        if ( line.startsWith( "... " ) )
+        {
+            //Should we log this somehow?
+            //System.out.println("Perforce: " + line);
+            return;
+        }
+
+        if ( !line.startsWith( FILE_BEGIN_TOKEN ) )
+        {
+            error( line );
+        }
+
+        if ( !revisionRegexp.match( line ) )
+        {
+            error( line );
+        }
+
+        edits.add( revisionRegexp.getParen( 1 ) );
+    }
+
+    private void error( String line )
+    {
+        errors = true;
+        output.println( line );
+    }
+
+    public boolean isSuccess()
+    {
+        return !errors;
+    }
+
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommand.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommand.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,84 @@
+package org.apache.maven.scm.provider.perforce.command.login;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.login.AbstractLoginCommand;
+import org.apache.maven.scm.login.LoginScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
+import org.apache.maven.scm.provider.perforce.command.PerforceCommand;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
+ *          evenisse $
+ */
+public class PerforceLoginCommand
+    extends AbstractLoginCommand
+    implements PerforceCommand
+{
+
+    public LoginScmResult executeLoginCommand( ScmProviderRepository repo, ScmFileSet files, CommandParameters params )
+        throws ScmException
+    {
+        Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), params );
+        PerforceLoginConsumer consumer = new PerforceLoginConsumer();
+        // In Perforce the user logs in once and then has a ticket good for 12 hours.
+        // We assume the user has logged in already so we don't have to deal with
+        // password management.
+//        try
+//        {
+//            Process proc = cl.execute();
+//            DataOutputStream dos = new DataOutputStream( proc.getOutputStream() );
+//            dos.writeUTF( "TODO???\r\n" );
+//            dos.close();
+//            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream() ) );
+//            String line = null;
+//            while ( ( line = br.readLine() ) != null )
+//            {
+//                consumer.consumeLine( line );
+//            }
+//        }
+//        catch ( CommandLineException e )
+//        {
+//            e.printStackTrace();
+//        }
+//        catch ( IOException e )
+//        {
+//            e.printStackTrace();
+//        }
+
+        return new LoginScmResult( cl.toString(), consumer.isSuccess() ? "Login successful" : "Login failed", consumer
+            .getOutput(), consumer.isSuccess() );
+    }
+
+    public static Commandline createCommandLine( PerforceScmProviderRepository repo, File workingDir,
+                                                CommandParameters params )
+    {
+        Commandline command = PerforceScmProvider.createP4Command( repo, workingDir );
+
+        command.createArgument().setValue( "login" );
+        return command;
+    }
+}
\ No newline at end of file

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginConsumer.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginConsumer.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,65 @@
+package org.apache.maven.scm.provider.perforce.command.login;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.provider.perforce.command.AbstractPerforceConsumer;
+import org.apache.regexp.RE;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogConsumer.java 331276 2005-11-07 15:04:54Z
+ *          evenisse $
+ */
+public class PerforceLoginConsumer
+    extends AbstractPerforceConsumer
+    implements StreamConsumer
+{
+
+    private static final String LOGIN_PATTERN = "^User [^ ]+ logged in.$";
+
+    public static final int STATE_LOGIN = 1;
+
+    public static final int STATE_ERROR = 2;
+
+    private int currentState = STATE_LOGIN;
+
+    public void consumeLine( String line )
+    {
+        if ( line.startsWith( "Enter password:" ) )
+        {
+            return;
+        }
+        if ( currentState != STATE_ERROR && new RE( LOGIN_PATTERN ).match( line ) )
+        {
+            return;
+        }
+
+        error( line );
+    }
+
+    private void error( String line )
+    {
+        currentState = STATE_ERROR;
+        output.println( line );
+    }
+
+    public boolean isSuccess()
+    {
+        return currentState == STATE_LOGIN;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message