maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r349683 - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src: main/java/org/apache/maven/scm/provider/perforce/command/ main/java/org/apache/maven/scm/provider/perforce/command/checkout/ test/java/org/apache/maven/scm/p...
Date Tue, 29 Nov 2005 09:33:39 GMT
Author: evenisse
Date: Tue Nov 29 01:33:28 2005
New Revision: 349683

URL: http://svn.apache.org/viewcvs?rev=349683&view=rev
Log:
PR: SCM-79
Sumitted by: Mike Perham

Add checked out files List to CheckOutConsumer

Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/PerforceVerbMapper.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumer.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumerTest.java

Modified: 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=349683&r1=349682&r2=349683&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/PerforceVerbMapper.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/PerforceVerbMapper.java
Tue Nov 29 01:33:28 2005
@@ -15,9 +15,14 @@
 
     static
     {
+        // Perforce uses different tenses sometimes so we need to map
+        // the different tenses to the same status.
         map.put( "add", ScmFileStatus.ADDED );
+        map.put( "added", ScmFileStatus.ADDED );
         map.put( "delete", ScmFileStatus.DELETED );
+        map.put( "deleted", ScmFileStatus.DELETED );
         map.put( "edit", ScmFileStatus.MODIFIED );
+        map.put( "edited", ScmFileStatus.MODIFIED );
     }
 
     public static ScmFileStatus toStatus( String verb )

Modified: 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=349683&r1=349682&r2=349683&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommand.java
Tue Nov 29 01:33:28 2005
@@ -45,8 +45,9 @@
     protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet
files, String tag )
         throws ScmException
     {
-        Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(),
tag );
-        PerforceCheckOutConsumer consumer = new PerforceCheckOutConsumer();
+        PerforceScmProviderRepository prepo = (PerforceScmProviderRepository) repo;
+        Commandline cl = createCommandLine( prepo, files.getBasedir(), tag );
+        PerforceCheckOutConsumer consumer = new PerforceCheckOutConsumer( prepo.getPath()
);
         try
         {
             Process proc = cl.execute();
@@ -59,15 +60,21 @@
         }
         catch ( CommandLineException e )
         {
-            e.printStackTrace();
+            getLogger().error( e );
         }
         catch ( IOException e )
         {
-            e.printStackTrace();
+            getLogger().error( e );
         }
 
-        return new CheckOutScmResult( cl.toString(), consumer.isSuccess() ? "Checkout successful"
: "Unable to sync",
-                                      consumer.getOutput(), consumer.isSuccess() );
+        if ( consumer.isSuccess() )
+        {
+            return new CheckOutScmResult( cl.toString(), consumer.getCheckedout() );
+        }
+        else
+        {
+            return new CheckOutScmResult( cl.toString(), "Unable to sync", consumer.getOutput(),
consumer.isSuccess() );
+        }
     }
 
     public static Commandline createCommandLine( PerforceScmProviderRepository repo, File
workingDirectory, String tag )
@@ -83,4 +90,4 @@
         return command;
     }
 
-}
\ No newline at end of file
+}

Modified: 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=349683&r1=349682&r2=349683&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumer.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumer.java
Tue Nov 29 01:33:28 2005
@@ -16,7 +16,13 @@
  * limitations under the License.
  */
 
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.ScmFile;
 import org.apache.maven.scm.provider.perforce.command.AbstractPerforceConsumer;
+import org.apache.maven.scm.provider.perforce.command.PerforceVerbMapper;
+import org.apache.regexp.RE;
 import org.codehaus.plexus.util.cli.StreamConsumer;
 
 /**
@@ -35,6 +41,17 @@
 
     private int currentState = STATE_NORMAL;
 
+    private RE fileRegexp = new RE( "([^#]+)#\\d+ - ([a-z]+)" );
+
+    private List checkedout = new ArrayList();
+
+    private String repo = null;
+
+    public PerforceCheckOutConsumer( String repoPath )
+    {
+        repo = repoPath;
+    }
+
     /*
      * //depot/modules/cordoba/runtime-ear/.j2ee#1 - deleted as
      * d:\perforce\depot\modules\cordoba\runtime-ear\.j2ee
@@ -56,8 +73,14 @@
      */
     public void consumeLine( String line )
     {
-        if ( currentState != STATE_ERROR && line.startsWith( "//" ) )
+        if ( currentState != STATE_ERROR && fileRegexp.match( line ) )
         {
+            String location = fileRegexp.getParen( 1 );
+            if ( location.startsWith( repo ) )
+            {
+                location = location.substring( repo.length() + 1 );
+            }
+            checkedout.add( new ScmFile( location, PerforceVerbMapper.toStatus( fileRegexp.getParen(
2 ) ) ) );
             return;
         }
 
@@ -74,4 +97,9 @@
     {
         return currentState == STATE_NORMAL;
     }
-}
\ No newline at end of file
+
+    public List getCheckedout()
+    {
+        return checkedout;
+    }
+}

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumerTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumerTest.java?rev=349683&r1=349682&r2=349683&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumerTest.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumerTest.java
Tue Nov 29 01:33:28 2005
@@ -21,6 +21,8 @@
 import java.io.FileInputStream;
 import java.io.InputStreamReader;
 
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileStatus;
 import org.apache.maven.scm.ScmTestCase;
 
 /**
@@ -34,7 +36,7 @@
     {
         File testFile = getTestFile( "src/test/resources/perforce/checkout_good.txt" );
 
-        PerforceCheckOutConsumer consumer = new PerforceCheckOutConsumer();
+        PerforceCheckOutConsumer consumer = new PerforceCheckOutConsumer("//depot/modules");
 
         FileInputStream fis = new FileInputStream( testFile );
         BufferedReader in = new BufferedReader( new InputStreamReader( fis ) );
@@ -47,12 +49,16 @@
 
         assertTrue( consumer.getOutput(), consumer.isSuccess() );
         assertEquals( "", consumer.getOutput() );
+        assertEquals( 4, consumer.getCheckedout().size() );
+        ScmFile file = (ScmFile) consumer.getCheckedout().get(0);
+        assertEquals( "cordoba/runtime-ear/.j2ee", file.getPath() );
+        assertEquals( ScmFileStatus.DELETED, file.getStatus() );
     }
 
     public void testBadParse() throws Exception {
         File testFile = getTestFile("src/test/resources/perforce/checkout_bad.txt");
 
-        PerforceCheckOutConsumer consumer = new PerforceCheckOutConsumer();
+        PerforceCheckOutConsumer consumer = new PerforceCheckOutConsumer("");
 
         FileInputStream fis = new FileInputStream( testFile );
         BufferedReader in = new BufferedReader( new InputStreamReader(fis) );



Mime
View raw message