maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ken...@apache.org
Subject svn commit: r453271 - in /maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command: ./ checkin/ checkout/ update/
Date Thu, 05 Oct 2006 15:41:29 GMT
Author: kenney
Date: Thu Oct  5 08:41:28 2006
New Revision: 453271

URL: http://svn.apache.org/viewvc?view=rev&rev=453271
Log:
Fixed timing issue.

While parsing the svn commandline output, checks
are performed if files are files or directories.
At the time of the check, those files may not have
been written yet.

Moved generic code to a new abstract base class,
and added a method that filters the file list
after the execution of the command is complete.

Added:
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/AbstractFileCheckingConsumer.java
  (with props)
Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtils.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInConsumer.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutConsumer.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateConsumer.java

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/AbstractFileCheckingConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/AbstractFileCheckingConsumer.java?view=auto&rev=453271
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/AbstractFileCheckingConsumer.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/AbstractFileCheckingConsumer.java
Thu Oct  5 08:41:28 2006
@@ -0,0 +1,106 @@
+package org.apache.maven.scm.provider.svn.svnexe.command;
+
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.log.ScmLogger;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/*
+ * Copyright 2001-2006 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.
+ */
+
+/**
+ *
+ * @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
+ *
+ */
+public abstract class AbstractFileCheckingConsumer
+    implements StreamConsumer
+{
+    protected ScmLogger logger;
+
+    protected File workingDirectory;
+
+    private List files = new ArrayList();
+
+    protected int revision;
+
+    private boolean filtered;
+
+    public AbstractFileCheckingConsumer( ScmLogger logger, File workingDirectory )
+    {
+        this.logger = logger;
+        this.workingDirectory = workingDirectory;
+    }
+
+    public final void consumeLine( String line )
+    {
+        if ( line.length() <= 3 )
+        {
+            logger.warn( "Unexpected input, the line must be at least three characters long.
Line: '" + line + "'." );
+
+            return;
+        }
+
+        parseLine( line );
+    }
+
+    protected abstract void parseLine( String line );
+
+    protected List getFiles()
+    {
+        if ( !filtered )
+        {
+            for ( Iterator it = files.iterator(); it.hasNext(); )
+            {
+                if ( !new File( workingDirectory, ( (ScmFile) it.next() ).getPath() ).isFile()
)
+                {
+                    it.remove();
+                }
+            }
+
+            filtered = true;
+        }
+
+        return files;
+    }
+
+    protected final int parseInt( String revisionString )
+    {
+        try
+        {
+            return Integer.parseInt( revisionString );
+        }
+        catch ( NumberFormatException ex )
+        {
+            return 0;
+        }
+    }
+
+    protected void addFile( ScmFile file )
+    {
+        files.add( file );
+    }
+
+    public final int getRevision()
+    {
+        return revision;
+    }
+
+}

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

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

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtils.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtils.java?view=diff&rev=453271&r1=453270&r2=453271
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtils.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtils.java
Thu Oct  5 08:41:28 2006
@@ -62,14 +62,14 @@
             cl.createArgument().setValue( SvnUtil.getSettings().getConfigDirectory() );
         }
 
-        if ( !StringUtils.isEmpty( repository.getUser() ) )
+        if ( repository != null && !StringUtils.isEmpty( repository.getUser() ) )
         {
             cl.createArgument().setValue( "--username" );
 
             cl.createArgument().setValue( repository.getUser() );
         }
 
-        if ( !StringUtils.isEmpty( repository.getPassword() ) )
+        if ( repository != null && !StringUtils.isEmpty( repository.getPassword()
) )
         {
             cl.createArgument().setValue( "--password" );
 

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInConsumer.java?view=diff&rev=453271&r1=453270&r2=453271
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInConsumer.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInConsumer.java
Thu Oct  5 08:41:28 2006
@@ -19,10 +19,9 @@
 import org.apache.maven.scm.ScmFile;
 import org.apache.maven.scm.ScmFileStatus;
 import org.apache.maven.scm.log.ScmLogger;
-import org.codehaus.plexus.util.cli.StreamConsumer;
+import org.apache.maven.scm.provider.svn.svnexe.command.AbstractFileCheckingConsumer;
 
 import java.io.File;
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -30,7 +29,7 @@
  * @version $Id$
  */
 public class SvnCheckInConsumer
-    implements StreamConsumer
+    extends AbstractFileCheckingConsumer
 {
     private final static String SENDING_TOKEN = "Sending        ";
 
@@ -42,13 +41,6 @@
 
     private final static String COMMITTED_REVISION_TOKEN = "Committed revision";
 
-    private ScmLogger logger;
-
-    private File workingDirectory;
-
-    private List checkedInFiles = new ArrayList();
-
-    private int revision;
 
     // ----------------------------------------------------------------------
     //
@@ -56,26 +48,15 @@
 
     public SvnCheckInConsumer( ScmLogger logger, File workingDirectory )
     {
-        this.logger = logger;
-
-        this.workingDirectory = workingDirectory;
+        super( logger, workingDirectory );
     }
 
     // ----------------------------------------------------------------------
     // StreamConsumer Implementation
     // ----------------------------------------------------------------------
 
-    public void consumeLine( String line )
+    protected void parseLine( String line )
     {
-        logger.debug( line );
-
-        if ( line.length() <= 3 )
-        {
-            logger.warn( "Unexpected input, the line must be at least three characters long.
Line: '" + line + "'." );
-
-            return;
-        }
-
         String file;
 
         if ( line.startsWith( COMMITTED_REVISION_TOKEN ) )
@@ -110,38 +91,11 @@
             return;
         }
 
-        // If the file isn't a file; don't add it.
-        if ( !new File( workingDirectory, file ).isFile() )
-        {
-            return;
-        }
-
-        checkedInFiles.add( new ScmFile( file, ScmFileStatus.CHECKED_IN ) );
+        addFile( new ScmFile( file, ScmFileStatus.CHECKED_IN ) );
     }
 
     public List getCheckedInFiles()
     {
-        return checkedInFiles;
-    }
-
-    public int getRevision()
-    {
-        return revision;
-    }
-
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
-
-    private int parseInt( String revisionString )
-    {
-        try
-        {
-            return Integer.parseInt( revisionString );
-        }
-        catch ( NumberFormatException ex )
-        {
-            return 0;
-        }
+        return getFiles();
     }
 }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutConsumer.java?view=diff&rev=453271&r1=453270&r2=453271
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutConsumer.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutConsumer.java
Thu Oct  5 08:41:28 2006
@@ -1,28 +1,11 @@
 package org.apache.maven.scm.provider.svn.svnexe.command.checkout;
 
-/*
- * Copyright 2001-2006 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.ScmFile;
 import org.apache.maven.scm.ScmFileStatus;
 import org.apache.maven.scm.log.ScmLogger;
-import org.codehaus.plexus.util.cli.StreamConsumer;
+import org.apache.maven.scm.provider.svn.svnexe.command.AbstractFileCheckingConsumer;
 
 import java.io.File;
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -30,40 +13,17 @@
  * @version $Id$
  */
 public class SvnCheckOutConsumer
-    implements StreamConsumer
+    extends AbstractFileCheckingConsumer
 {
     private final static String CHECKED_OUT_REVISION_TOKEN = "Checked out revision";
 
-    private ScmLogger logger;
-
-    private File workingDirectory;
-
-    private List checkedOutFiles = new ArrayList();
-
-    private int revision;
-
     public SvnCheckOutConsumer( ScmLogger logger, File workingDirectory )
     {
-        this.logger = logger;
-
-        this.workingDirectory = workingDirectory;
+        super( logger, workingDirectory );
     }
 
-    // ----------------------------------------------------------------------
-    // StreamConsumer Implementation
-    // ----------------------------------------------------------------------
-
-    public void consumeLine( String line )
+    protected void parseLine( String line )
     {
-        logger.debug( line );
-
-        if ( line.length() <= 3 )
-        {
-            logger.warn( "Unexpected input, the line must be at least three characters long.
Line: '" + line + "'." );
-
-            return;
-        }
-
         String statusString = line.substring( 0, 1 );
 
         String file = line.substring( 3 ).trim();
@@ -74,14 +34,7 @@
         {
             String revisionString = line.substring( CHECKED_OUT_REVISION_TOKEN.length() +
1, line.length() - 1 );
 
-            try
-            {
-                revision = Integer.parseInt( revisionString );
-            }
-            catch ( NumberFormatException ex )
-            {
-                // ignored
-            }
+            revision = parseInt( revisionString );
 
             return;
         }
@@ -100,14 +53,7 @@
             return;
         }
 
-        // If the file isn't a file; don't add it.
-        if ( !new File( workingDirectory, file ).isFile() )
-        {
-            logger.debug( "Skipping non-file: " + file );
-            return;
-        }
-
-        checkedOutFiles.add( new ScmFile( file, status ) );
+        addFile( new ScmFile( file, status ) );
     }
 
     // ----------------------------------------------------------------------
@@ -116,11 +62,6 @@
 
     public List getCheckedOutFiles()
     {
-        return checkedOutFiles;
-    }
-
-    public int getRevision()
-    {
-        return revision;
+        return getFiles();
     }
 }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommand.java?view=diff&rev=453271&r1=453270&r2=453271
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommand.java
Thu Oct  5 08:41:28 2006
@@ -102,7 +102,7 @@
         }
         else
         {
-            // The tag specified does not appear to be numeric, so assume it refers 
+            // The tag specified does not appear to be numeric, so assume it refers
             // to a branch/tag url and perform a switch operation rather than update
             cl.createArgument().setValue( "switch" );
             cl.createArgument().setValue( SvnTagBranchUtils.resolveTagUrl( repository, tag
) );

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateConsumer.java?view=diff&rev=453271&r1=453270&r2=453271
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateConsumer.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateConsumer.java
Thu Oct  5 08:41:28 2006
@@ -19,10 +19,9 @@
 import org.apache.maven.scm.ScmFile;
 import org.apache.maven.scm.ScmFileStatus;
 import org.apache.maven.scm.log.ScmLogger;
-import org.codehaus.plexus.util.cli.StreamConsumer;
+import org.apache.maven.scm.provider.svn.svnexe.command.AbstractFileCheckingConsumer;
 
 import java.io.File;
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -30,21 +29,13 @@
  * @version $Id$
  */
 public class SvnUpdateConsumer
-    implements StreamConsumer
+    extends AbstractFileCheckingConsumer
 {
-    private final static String UPDATED_TO_REVISION_TOKEN = "Updated to revision";
+    private static final String UPDATED_TO_REVISION_TOKEN = "Updated to revision";
 
-    private final static String AT_REVISION_TOKEN = "At revision";
+    private static final String AT_REVISION_TOKEN = "At revision";
 
-    private final static String RESTORED_TOKEN = "Restored";
-
-    private ScmLogger logger;
-
-    private File workingDirectory;
-
-    private List updatedFiles = new ArrayList();
-
-    private int revision;
+    private static final String RESTORED_TOKEN = "Restored";
 
     // ----------------------------------------------------------------------
     //
@@ -52,26 +43,15 @@
 
     public SvnUpdateConsumer( ScmLogger logger, File workingDirectory )
     {
-        this.logger = logger;
-
-        this.workingDirectory = workingDirectory;
+        super( logger, workingDirectory );
     }
 
     // ----------------------------------------------------------------------
     // StreamConsumer Implementation
     // ----------------------------------------------------------------------
 
-    public void consumeLine( String line )
+    protected void parseLine( String line )
     {
-        logger.debug( line );
-
-        if ( line.length() <= 3 )
-        {
-            logger.warn( "Unexpected input, the line must be at least three characters long.
Line: '" + line + "'." );
-
-            return;
-        }
-
         String statusString = line.substring( 0, 1 );
 
         String file = line.substring( 3 ).trim();
@@ -117,39 +97,11 @@
             return;
         }
 
-        // If the file isn't a file; don't add it.
-        if ( !new File( workingDirectory, file ).isFile() )
-        {
-            logger.debug( "Skipping non-file: " + file );
-            return;
-        }
-
-        updatedFiles.add( new ScmFile( file, status ) );
+        addFile(new ScmFile( file, status ) );
     }
 
     public List getUpdatedFiles()
     {
-        return updatedFiles;
-    }
-
-    public int getRevision()
-    {
-        return revision;
-    }
-
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
-
-    private int parseInt( String revisionString )
-    {
-        try
-        {
-            return Integer.parseInt( revisionString );
-        }
-        catch ( NumberFormatException ex )
-        {
-            return 0;
-        }
+        return getFiles();
     }
 }



Mime
View raw message