maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r691605 - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command: checkin/ checkout/ diff/ tag/
Date Wed, 03 Sep 2008 13:28:05 GMT
Author: vsiveton
Date: Wed Sep  3 06:28:04 2008
New Revision: 691605

URL: http://svn.apache.org/viewvc?rev=691605&view=rev
Log:
SCM-246:  p4 command reports most or all errors on stderr but maven-scm-provider-perforce
throws away stderr
Submitted by: Tom Parker
Reviewed by: Vincent Siveton

o patch applied

Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommand.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/diff/PerforceDiffCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.java

Modified: 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/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommand.java?rev=691605&r1=691604&r2=691605&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommand.java
Wed Sep  3 06:28:04 2008
@@ -42,9 +42,10 @@
 import java.util.Set;
 
 /**
+ * @todo refactor this & other perforce commands -- most of the invocation and stream
+ *       consumer code could be shared
  * @author Mike Perham
- * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
- *          evenisse $
+ * @version $Id$
  */
 public class PerforceCheckInCommand
     extends AbstractCheckInCommand
@@ -72,19 +73,23 @@
             dos.write( changes.getBytes() );
             dos.close();
             out.close();
-            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream()
) );
-            BufferedReader brErr = new BufferedReader( new InputStreamReader( proc.getErrorStream()
) );
+
+            // TODO find & use a less naive InputStream multiplexer
+            BufferedReader stdout = new BufferedReader( new InputStreamReader( proc.getInputStream()
) );
+            BufferedReader stderr = new BufferedReader( new InputStreamReader( proc.getErrorStream()
) );
             String line;
-            while ( ( line = br.readLine() ) != null )
+            while ( ( line = stdout.readLine() ) != null )
             {
-                getLogger().debug( "Consuming: " + line );
+                getLogger().debug( "Consuming stdout: " + line );
                 consumer.consumeLine( line );
             }
-            while ( ( line = brErr.readLine() ) != null )
+            while ( ( line = stderr.readLine() ) != null )
             {
                 getLogger().debug( "Consuming stderr: " + line );
                 consumer.consumeLine( line );
             }
+            stderr.close();
+            stdout.close();
         }
         catch ( CommandLineException e )
         {
@@ -110,7 +115,7 @@
 
     private static final String NEWLINE = "\r\n";
 
-    public static String createChangeListSpecification( PerforceScmProviderRepository repo,
ScmFileSet files,
+    static String createChangeListSpecification( PerforceScmProviderRepository repo, ScmFileSet
files,
                                                         String msg, String canonicalPath,
String jobs )
     {
         StringBuffer buf = new StringBuffer();

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/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommand.java?rev=691605&r1=691604&r2=691605&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
Wed Sep  3 06:28:04 2008
@@ -40,9 +40,10 @@
 import java.io.OutputStream;
 
 /**
+ * @todo refactor this & other perforce commands -- most of the invocation and stream
+ *       consumer code could be shared
  * @author Mike Perham
- * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
- *          evenisse $
+ * @version $Id$
  */
 public class PerforceCheckOutCommand
     extends AbstractCheckOutCommand
@@ -96,15 +97,22 @@
             dos.close();
             out.close();
 
-            // Read result from STDOUT
-            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream()
) );
+            // TODO find & use a less naive InputStream multiplexer
+            BufferedReader stdout = new BufferedReader( new InputStreamReader( proc.getInputStream()
) );
+            BufferedReader stderr = new BufferedReader( new InputStreamReader( proc.getErrorStream()
) );
             String line;
-            while ( ( line = br.readLine() ) != null )
+            while ( ( line = stdout.readLine() ) != null )
             {
-                getLogger().debug( "Consuming: " + line );
+                getLogger().debug( "Consuming stdout: " + line );
                 consumer.consumeLine( line );
             }
-            br.close();
+            while ( ( line = stderr.readLine() ) != null )
+            {
+                getLogger().debug( "Consuming stderr: " + line );
+                consumer.consumeLine( line );
+            }
+            stderr.close();
+            stdout.close();
             // Read errors from STDERR
             BufferedReader brErr = new BufferedReader( new InputStreamReader( proc.getErrorStream()
) );
             while ( ( line = brErr.readLine() ) != null )

Modified: 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/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommand.java?rev=691605&r1=691604&r2=691605&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommand.java
Wed Sep  3 06:28:04 2008
@@ -38,9 +38,10 @@
 import java.io.InputStreamReader;
 
 /**
+ * @todo refactor this & other perforce commands -- most of the invocation and stream
+ *       consumer code could be shared
  * @author Mike Perham
- * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
- *          evenisse $
+ * @version $Id$
  */
 public class PerforceDiffCommand
     extends AbstractDiffCommand
@@ -54,29 +55,40 @@
         Commandline cl =
             createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(),
startRev, endRev );
         PerforceDiffConsumer consumer = new PerforceDiffConsumer();
+        getLogger().info( "Executing: " + PerforceScmProvider.clean( cl.toString() ) );
         boolean success = false;
         try
         {
             Process proc = cl.execute();
-            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream()
) );
+            // TODO find & use a less naive InputStream multiplexer
+            BufferedReader stdout = new BufferedReader( new InputStreamReader( proc.getInputStream()
) );
+            BufferedReader stderr = new BufferedReader( new InputStreamReader( proc.getErrorStream()
) );
             String line;
-            while ( ( line = br.readLine() ) != null )
+            while ( ( line = stdout.readLine() ) != null )
             {
+                getLogger().debug( "Consuming stdout: " + line );
                 consumer.consumeLine( line );
             }
+            while ( ( line = stderr.readLine() ) != null )
+            {
+                getLogger().debug( "Consuming stderr: " + line );
+                consumer.consumeLine( line );
+            }
+            stderr.close();
+            stdout.close();
             success = proc.waitFor() == 0;
         }
         catch ( CommandLineException e )
         {
-            e.printStackTrace();
+            getLogger().error( e );
         }
         catch ( IOException e )
         {
-            e.printStackTrace();
+            getLogger().error( e );
         }
         catch ( InterruptedException e )
         {
-            e.printStackTrace();
+            getLogger().error( e );
         }
 
         return new DiffScmResult( cl.toString(), success ? "Diff successful" : "Unable to
diff", consumer
@@ -99,4 +111,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/tag/PerforceTagCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.java?rev=691605&r1=691604&r2=691605&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.java
Wed Sep  3 06:28:04 2008
@@ -41,9 +41,10 @@
 import java.util.List;
 
 /**
+ * @todo refactor this & other perforce commands -- most of the invocation and stream
+ *       consumer code could be shared
  * @author Mike Perham
- * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
- *          evenisse $
+ * @version $Id$
  */
 public class PerforceTagCommand
     extends AbstractTagCommand
@@ -99,13 +100,22 @@
         {
             getLogger().debug( PerforceScmProvider.clean( "Executing: " + cl.toString() )
);
             Process proc = cl.execute();
-            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream()
) );
+            // TODO find & use a less naive InputStream multiplexer
+            BufferedReader stdout = new BufferedReader( new InputStreamReader( proc.getInputStream()
) );
+            BufferedReader stderr = new BufferedReader( new InputStreamReader( proc.getErrorStream()
) );
             String line;
-            while ( ( line = br.readLine() ) != null )
+            while ( ( line = stdout.readLine() ) != null )
             {
-                getLogger().debug( "Consuming: " + line );
+                getLogger().debug( "Consuming stdout: " + line );
                 consumer.consumeLine( line );
             }
+            while ( ( line = stderr.readLine() ) != null )
+            {
+                getLogger().debug( "Consuming stderr: " + line );
+                consumer.consumeLine( line );
+            }
+            stderr.close();
+            stdout.close();
         }
         catch ( CommandLineException e )
         {
@@ -132,13 +142,22 @@
             dos.write( label.getBytes() );
             dos.close();
             out.close();
-            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream()
) );
+            // TODO find & use a less naive InputStream multiplexer
+            BufferedReader stdout = new BufferedReader( new InputStreamReader( proc.getInputStream()
) );
+            BufferedReader stderr = new BufferedReader( new InputStreamReader( proc.getErrorStream()
) );
             String line;
-            while ( ( line = br.readLine() ) != null )
+            while ( ( line = stdout.readLine() ) != null )
+            {
+                getLogger().debug( "Consuming stdout: " + line );
+                consumer.consumeLine( line );
+            }
+            while ( ( line = stderr.readLine() ) != null )
             {
-                getLogger().debug( "Consuming: " + line );
+                getLogger().debug( "Consuming stderr: " + line );
                 consumer.consumeLine( line );
             }
+            stderr.close();
+            stdout.close();
         }
         catch ( CommandLineException e )
         {



Mime
View raw message