maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r381349 - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar: ./ command/ command/add/ command/changelog/ command/checkin/ command/checkout/ command/diff/ command/remove/ com...
Date Mon, 27 Feb 2006 14:47:08 GMT
Author: evenisse
Date: Mon Feb 27 06:47:01 2006
New Revision: 381349

URL: http://svn.apache.org/viewcvs?rev=381349&view=rev
Log:
[SCM-161] Proper Std.Err handling and replace wrapResult methods with ScmResult copy constructors
Submitted by : Torbjørn EIkli Smørgrav

Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConsumer.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkin/BazaarCheckInCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/update/BazaarUpdateCommand.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java?rev=381349&r1=381348&r2=381349&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java
Mon Feb 27 06:47:01 2006
@@ -16,6 +16,12 @@
  * limitations under the License.
  */
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.maven.scm.ScmException;
 import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.ScmFileStatus;
@@ -26,15 +32,7 @@
 import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
-import org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer;
 import org.codehaus.plexus.util.cli.Commandline;
-import org.codehaus.plexus.util.cli.StreamConsumer;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 
 /**
  * Common code for executing bazaar commands.
@@ -45,12 +43,12 @@
 {
 
     /**
-     * Map between command  and its valid exitcodes
+     * Map between command and its valid exit codes
      */
     private static final Map exitCodeMap = new HashMap();
 
     /**
-     * Defualt exit codes for entries not in exitCodeMap
+     * Default exit codes for entries not in exitCodeMap
      */
     private static final List defaultExitCodes = new ArrayList();
 
@@ -66,7 +64,7 @@
         exitCodeMap.put( BazaarCommand.DIFF_CMD, diffExitCodes );
     }
 
-    public static ScmResult execute( StreamConsumer consumer, ScmLogger logger, File workingDir,
String[] cmdAndArgs )
+    public static ScmResult execute( BazaarConsumer consumer, ScmLogger logger, File workingDir,
String[] cmdAndArgs )
         throws ScmException
     {
         Commandline cmd = new Commandline();
@@ -79,7 +77,8 @@
             boolean success = workingDir.mkdirs();
             if ( !success )
             {
-                throw new ScmException( "Working directory did not exist and it couldn't
be created: " + workingDir );
+                String msg = "Working directory did not exist and it couldn't be created:
" + workingDir;
+                throw new ScmException( msg );
             }
         }
 
@@ -87,27 +86,28 @@
         logger.info( "Working directory: " + workingDir.getAbsolutePath() );
 
         final int exitCode;
-        StringStreamConsumer stderr = new StringStreamConsumer();
         try
         {
-            exitCode = CommandLineUtils.executeCommandLine( cmd, consumer, stderr );
+            exitCode = CommandLineUtils.executeCommandLine( cmd, consumer, consumer );
         }
         catch ( CommandLineException ex )
         {
             throw new ScmException( "Command could not be executed: " + cmd, ex );
         }
 
-        List exitCodes =
-            exitCodeMap.containsKey( cmdAndArgs[0] ) ? (List) exitCodeMap.get( cmdAndArgs[0]
) : defaultExitCodes;
+        List exitCodes = exitCodeMap.containsKey( cmdAndArgs[0] ) ? (List) exitCodeMap.get(
cmdAndArgs[0] )
+                                                                 : defaultExitCodes;
         boolean success = exitCodes.contains( new Integer( exitCode ) );
 
-        return new ScmResult( cmd.toString(), "Execution of bazaar command failed", stderr.getOutput(),
success );
+        String providerMsg = "Execution of bazaar command: " + ( success ? "succeded" : "failed"
);
+        return new ScmResult( cmd.toString(), providerMsg, consumer.getStdErr(), success
);
     }
 
     public static ScmResult execute( File workingDir, String[] cmdAndArgs )
         throws ScmException
     {
-        return execute( new StringStreamConsumer(), new DefaultLog(), workingDir, cmdAndArgs
);
+        ScmLogger logger = new DefaultLog();
+        return execute( new BazaarConsumer(logger), logger, workingDir, cmdAndArgs );
     }
 
     public static String[] expandCommandLine( String[] cmdAndArgs, ScmFileSet additionalFiles
)
@@ -132,7 +132,7 @@
         throws ScmException
     {
 
-        String[] revCmd = new String[]{BazaarCommand.REVNO_CMD};
+        String[] revCmd = new String[] { BazaarCommand.REVNO_CMD };
         BazaarRevNoConsumer consumer = new BazaarRevNoConsumer( logger );
         BazaarUtils.execute( consumer, logger, workingDir, revCmd );
 
@@ -142,7 +142,7 @@
     /**
      * Get current (working) revision.
      * <p/>
-     * Resolves revision to the last integer found in the command output.
+     * Resolve revision to the last integer found in the command output.
      */
     private static class BazaarRevNoConsumer
         extends BazaarConsumer

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java?rev=381349&r1=381348&r2=381349&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java
Mon Feb 27 06:47:01 2006
@@ -21,7 +21,7 @@
 /**
  * Available/Used bazaar commands.
  * <p/>
- * These commands does not necessarily correspont to the SCM API.
+ * These commands does not necessarily correspond to the SCM API.
  * Eg. "check in" is translated to be "commit" and "push".
  *
  * @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a>

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConsumer.java?rev=381349&r1=381348&r2=381349&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConsumer.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConsumer.java
Mon Feb 27 06:47:01 2006
@@ -16,19 +16,20 @@
  * limitations under the License.
  */
 
-import org.apache.maven.scm.ScmFileStatus;
-import org.apache.maven.scm.util.AbstractConsumer;
-import org.apache.maven.scm.log.ScmLogger;
-import org.codehaus.plexus.util.cli.StreamConsumer;
-
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.util.AbstractConsumer;
+
 /**
  * Base consumer to do common parsing for all bazaar commands.
  * <p/>
- * More spesific: log line on debug, get file status
+ * More specific: log line on debug, get file status
  * and detect warnings from bazaar
  *
  * @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a>
@@ -47,6 +48,18 @@
      */
     private static final Map messages = new HashMap();
 
+    /**
+     * Number of lines to keep from Std.Err
+     * This size is set to ensure that we capture enough info
+     * but still keeps a low memory footprint.
+     */
+    private static final int MAX_STDERR_SIZE = 10;
+
+    /**
+     * A list of the MAX_STDERR_SIZE last errors or warnings.
+     */
+    private final List stderr = new ArrayList();
+
     static
     {
         identifiers.put( "added".intern(), ScmFileStatus.ADDED );
@@ -96,6 +109,20 @@
         doConsume( status, trimmedLine );
     }
 
+    /**
+     * Warnings and errors is usually printed out in Std.Err, thus for derived consumers
+     * operating on Std.Out this would typically return an empty string.
+     *
+     * @return Return the last lines interpreted as an warning or an error
+     */
+    public String getStdErr() {
+        String str = "";
+        for (Iterator it = stderr.iterator(); it.hasNext();) {
+            str += it.next();
+        }
+        return str;
+    }
+
     private static String processInputForKnownIdentifiers( String line )
     {
         for ( Iterator it = identifiers.keySet().iterator(); it.hasNext(); )
@@ -116,6 +143,10 @@
             String prefix = (String) it.next();
             if ( line.startsWith( prefix ) )
             {
+                stderr.add(line); //Add line
+                if (stderr.size() > MAX_STDERR_SIZE) {
+                    stderr.remove(0); //Rotate list
+                }
                 String message = line.substring( prefix.length() );
                 if ( messages.get( prefix ).equals( "WARNING" ) )
                 {

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddCommand.java?rev=381349&r1=381348&r2=381349&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddCommand.java
Mon Feb 27 06:47:01 2006
@@ -26,7 +26,6 @@
 import org.apache.maven.scm.provider.bazaar.command.BazaarCommand;
 
 import java.io.File;
-import java.util.List;
 
 /**
  * Add no recursive.
@@ -48,21 +47,6 @@
         BazaarAddConsumer consumer = new BazaarAddConsumer( getLogger(), workingDir );
         ScmResult result = BazaarUtils.execute( consumer, getLogger(), workingDir, addCmd
);
 
-        return wrapResult( consumer.getAddedFiles(), result );
-    }
-
-    private AddScmResult wrapResult( List files, ScmResult baseResult )
-    {
-        AddScmResult result;
-        if ( baseResult.isSuccess() )
-        {
-            result = new AddScmResult( baseResult.getCommandLine(), files );
-        }
-        else
-        {
-            result = new AddScmResult( baseResult.getCommandLine(), baseResult.getProviderMessage(),
baseResult
-                .getCommandOutput(), baseResult.isSuccess() );
-        }
-        return result;
+        return new AddScmResult( consumer.getAddedFiles(), result );
     }
 }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java?rev=381349&r1=381348&r2=381349&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java
Mon Feb 27 06:47:01 2006
@@ -16,6 +16,11 @@
  * limitations under the License.
  */
 
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.maven.scm.ChangeSet;
 import org.apache.maven.scm.ScmException;
 import org.apache.maven.scm.ScmFileSet;
@@ -27,11 +32,6 @@
 import org.apache.maven.scm.provider.bazaar.BazaarUtils;
 import org.apache.maven.scm.provider.bazaar.command.BazaarCommand;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
 /**
  * @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a>
  */
@@ -66,21 +66,6 @@
             }
         }
 
-        return wrapResult( new ChangeLogSet( inRange, startDate, endDate ), result );
-    }
-
-    private ChangeLogScmResult wrapResult( ChangeLogSet changeLogSet, ScmResult result )
-    {
-        ChangeLogScmResult diffResult;
-        if ( result.isSuccess() )
-        {
-            diffResult = new ChangeLogScmResult( result.getCommandLine(), changeLogSet );
-        }
-        else
-        {
-            diffResult = new ChangeLogScmResult( result.getCommandLine(), result.getProviderMessage(),
result
-                .getCommandOutput(), result.isSuccess() );
-        }
-        return diffResult;
+        return new ChangeLogScmResult( new ChangeLogSet( inRange, startDate, endDate ), result
);
     }
 }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkin/BazaarCheckInCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkin/BazaarCheckInCommand.java?rev=381349&r1=381348&r2=381349&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkin/BazaarCheckInCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkin/BazaarCheckInCommand.java
Mon Feb 27 06:47:01 2006
@@ -85,33 +85,17 @@
         // Commit to local branch
         String[] commitCmd = new String[]{BazaarCommand.COMMIT_CMD, BazaarCommand.MESSAGE_OPTION,
message};
         commitCmd = BazaarUtils.expandCommandLine( commitCmd, fileSet );
-        BazaarUtils.execute( new BazaarConsumer( getLogger() ), getLogger(), fileSet.getBasedir(),
commitCmd );
+        ScmResult result = BazaarUtils.execute( new BazaarConsumer( getLogger() ), getLogger(),
fileSet.getBasedir(), commitCmd );
 
         // Push to parent branch if any
         BazaarScmProviderRepository repository = (BazaarScmProviderRepository) repo;
         if ( !repository.getURI().equals( fileSet.getBasedir().getAbsolutePath() ) )
         {
             String[] push_cmd = new String[]{BazaarCommand.PUSH_CMD, repository.getURI()};
-            ScmResult result = BazaarUtils.execute( new BazaarConsumer( getLogger() ), getLogger(),
fileSet
+            result = BazaarUtils.execute( new BazaarConsumer( getLogger() ), getLogger(),
fileSet
                 .getBasedir(), push_cmd );
-            return wrapResult( commitedFiles, result );
         }
 
-        return new CheckInScmResult( commitCmd[0], commitedFiles );
-    }
-
-    private CheckInScmResult wrapResult( List files, ScmResult baseResult )
-    {
-        CheckInScmResult result;
-        if ( baseResult.isSuccess() )
-        {
-            result = new CheckInScmResult( baseResult.getCommandLine(), files );
-        }
-        else
-        {
-            result = new CheckInScmResult( baseResult.getCommandLine(), baseResult.getProviderMessage(),
baseResult
-                .getCommandOutput(), baseResult.isSuccess() );
-        }
-        return result;
+        return new CheckInScmResult( commitedFiles, result );
     }
 }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java?rev=381349&r1=381348&r2=381349&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java
Mon Feb 27 06:47:01 2006
@@ -31,7 +31,6 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.util.List;
 
 /**
  * @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a>
@@ -74,21 +73,6 @@
         BazaarCheckOutConsumer consumer = new BazaarCheckOutConsumer( getLogger(), checkoutDir
);
         ScmResult result = BazaarUtils.execute( consumer, getLogger(), checkoutDir, inventory_cmd
);
 
-        return wrapResult( consumer.getCheckedOutFiles(), result );
-    }
-
-    private CheckOutScmResult wrapResult( List files, ScmResult baseResult )
-    {
-        CheckOutScmResult result;
-        if ( baseResult.isSuccess() )
-        {
-            result = new CheckOutScmResult( baseResult.getCommandLine(), files );
-        }
-        else
-        {
-            result = new CheckOutScmResult( baseResult.getCommandLine(), baseResult.getProviderMessage(),
baseResult
-                .getCommandOutput(), baseResult.isSuccess() );
-        }
-        return result;
+        return new CheckOutScmResult( consumer.getCheckedOutFiles(), result );
     }
 }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommand.java?rev=381349&r1=381348&r2=381349&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommand.java
Mon Feb 27 06:47:01 2006
@@ -59,22 +59,7 @@
 
         ScmResult result = BazaarUtils.execute( consumer, getLogger(), fileSet.getBasedir(),
diffCmd );
 
-        return wrapResult( consumer, result );
-    }
-
-    private DiffScmResult wrapResult( BazaarDiffConsumer consumer, ScmResult result )
-    {
-        DiffScmResult diffResult;
-        if ( result.isSuccess() )
-        {
-            diffResult = new DiffScmResult( result.getCommandLine(), consumer.getChangedFiles(),
consumer
-                .getDifferences(), consumer.getPatch() );
-        }
-        else
-        {
-            diffResult = new DiffScmResult( result.getCommandLine(), result.getProviderMessage(),
result
-                .getCommandOutput(), result.isSuccess() );
-        }
-        return diffResult;
+        return new DiffScmResult( consumer.getChangedFiles(),
+                                  consumer.getDifferences(), consumer.getPatch(), result
);
     }
 }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveCommand.java?rev=381349&r1=381348&r2=381349&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveCommand.java
Mon Feb 27 06:47:01 2006
@@ -44,11 +44,6 @@
         File workingDir = fileSet.getBasedir();
 
         ScmResult result = BazaarUtils.execute( consumer, getLogger(), workingDir, command
);
-        if ( result.isSuccess() )
-        {
-            return new RemoveScmResult( result.getCommandLine(), consumer.getRemovedFiles()
);
-        }
-
-        return result;
+        return new RemoveScmResult( consumer.getRemovedFiles(), result );
     }
 }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusCommand.java?rev=381349&r1=381348&r2=381349&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusCommand.java
Mon Feb 27 06:47:01 2006
@@ -26,7 +26,6 @@
 import org.apache.maven.scm.provider.bazaar.command.BazaarCommand;
 
 import java.io.File;
-import java.util.List;
 
 /**
  * @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a>
@@ -50,21 +49,6 @@
         String[] statusCmd = new String[]{STATUS_CMD};
         ScmResult result = BazaarUtils.execute( consumer, getLogger(), workingDir, statusCmd
);
 
-        return wrapResult( consumer.getStatus(), result );
-    }
-
-    private StatusScmResult wrapResult( List files, ScmResult baseResult )
-    {
-        StatusScmResult result;
-        if ( baseResult.isSuccess() )
-        {
-            result = new StatusScmResult( baseResult.getCommandLine(), files );
-        }
-        else
-        {
-            result = new StatusScmResult( baseResult.getCommandLine(), baseResult.getProviderMessage(),
baseResult
-                .getCommandOutput(), baseResult.isSuccess() );
-        }
-        return result;
+        return new StatusScmResult( consumer.getStatus(), result );
     }
 }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/update/BazaarUpdateCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/update/BazaarUpdateCommand.java?rev=381349&r1=381348&r2=381349&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/update/BazaarUpdateCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/update/BazaarUpdateCommand.java
Mon Feb 27 06:47:01 2006
@@ -16,6 +16,12 @@
  * limitations under the License.
  */
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.maven.scm.ScmException;
 import org.apache.maven.scm.ScmFile;
 import org.apache.maven.scm.ScmFileSet;
@@ -32,11 +38,6 @@
 import org.apache.maven.scm.provider.bazaar.command.diff.BazaarDiffConsumer;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
 /**
  * @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a>
  */
@@ -45,7 +46,8 @@
     implements BazaarCommand
 {
 
-    protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet
fileSet, String tag )
+    protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo,
+                                                    ScmFileSet fileSet, String tag )
         throws ScmException
     {
 
@@ -59,24 +61,29 @@
         // Update branch
         String[] update_cmd = new String[]{BazaarCommand.PULL_CMD};
         ScmResult updateResult =
-            BazaarUtils.execute( new BazaarConsumer( getLogger() ), getLogger(), workingDir,
update_cmd );
+            BazaarUtils.execute( new BazaarConsumer( getLogger() ), getLogger(),
+                                 workingDir, update_cmd );
 
         if ( !updateResult.isSuccess() )
         {
-            return wrapResult( new ArrayList(), updateResult );
+            return new UpdateScmResult( null, null, updateResult );
         }
 
         // Find changes from last revision
         int prev_revi = BazaarUtils.getCurrentRevisionNumber( getLogger(), workingDir ) -
1;
-        String[] diff_cmd = new String[]{DIFF_CMD, REVISION_OPTION, "" + prev_revi};
-        BazaarDiffConsumer diff_consumer = new BazaarDiffConsumer( getLogger(), workingDir
);
-        ScmResult diffResult = BazaarUtils.execute( diff_consumer, getLogger(), workingDir,
diff_cmd );
+        String[] diffCmd = new String[]{DIFF_CMD, REVISION_OPTION, "" + prev_revi};
+        BazaarDiffConsumer diffConsumer = new BazaarDiffConsumer( getLogger(), workingDir
);
+        ScmResult diffResult = BazaarUtils.execute( diffConsumer, getLogger(), workingDir,
diffCmd );
 
         // Now translate between diff and update file status
         List updatedFiles = new ArrayList();
-        for ( Iterator it = diff_consumer.getChangedFiles().iterator(); it.hasNext(); )
+        List changes = new ArrayList();
+        List diffFiles = diffConsumer.getChangedFiles();
+        Map diffChanges = diffConsumer.getDifferences();
+        for ( Iterator it = diffFiles.iterator(); it.hasNext(); )
         {
             ScmFile file = (ScmFile) it.next();
+            changes.add(diffChanges.get(file));
             if ( file.getStatus() == ScmFileStatus.MODIFIED )
             {
                 updatedFiles.add( new ScmFile( file.getPath(), ScmFileStatus.PATCHED ) );
@@ -87,22 +94,7 @@
             }
         }
 
-        return wrapResult( updatedFiles, diffResult );
-    }
-
-    private UpdateScmResult wrapResult( List files, ScmResult baseResult )
-    {
-        UpdateScmResult result;
-        if ( baseResult.isSuccess() )
-        {
-            result = new UpdateScmResult( baseResult.getCommandLine(), files );
-        }
-        else
-        {
-            result = new UpdateScmResult( baseResult.getCommandLine(), baseResult.getProviderMessage(),
baseResult
-                .getCommandOutput(), baseResult.isSuccess() );
-        }
-        return result;
+        return new UpdateScmResult( updatedFiles, changes, diffResult );
     }
 
     protected ChangeLogCommand getChangeLogCommand()



Mime
View raw message