maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r980673 [2/5] - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev: ./ src/main/java/org/apache/maven/scm/provider/accurev/ src/main/java/org/apache/maven/scm/provider/accurev/cli/ src/main/java/org/apache/maven/scm/provider...
Date Fri, 30 Jul 2010 08:14:30 GMT
Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLine.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLine.java?rev=980673&r1=980672&r2=980673&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLine.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLine.java Fri Jul 30 08:14:27 2010
@@ -22,20 +22,23 @@ package org.apache.maven.scm.provider.ac
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.InputStream;
-import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Pattern;
 
 import org.apache.maven.scm.command.blame.BlameLine;
-import org.apache.maven.scm.log.DefaultLog;
 import org.apache.maven.scm.log.ScmLogger;
 import org.apache.maven.scm.provider.accurev.AccuRev;
 import org.apache.maven.scm.provider.accurev.AccuRevException;
 import org.apache.maven.scm.provider.accurev.AccuRevInfo;
 import org.apache.maven.scm.provider.accurev.AccuRevStat;
+import org.apache.maven.scm.provider.accurev.CategorisedElements;
+import org.apache.maven.scm.provider.accurev.FileDifference;
+import org.apache.maven.scm.provider.accurev.Stream;
 import org.apache.maven.scm.provider.accurev.Transaction;
 import org.apache.maven.scm.provider.accurev.WorkSpace;
 import org.codehaus.plexus.util.Os;
@@ -69,8 +72,13 @@ public class AccuRevCommandLine
 
     private String executable = "accurev";
 
+    private long executableModTime;
+
+    private String clientVersion;
+
     public AccuRevCommandLine()
     {
+
         super();
         reset();
 
@@ -99,6 +107,7 @@ public class AccuRevCommandLine
 
     public void setExecutable( String accuRevExe )
     {
+
         executable = accuRevExe;
         reset();
     }
@@ -117,6 +126,7 @@ public class AccuRevCommandLine
                                         StreamConsumer stdoutConsumer )
         throws AccuRevException
     {
+
         setWorkingDirectory( basedir );
         setCommandLineArgs( args );
 
@@ -125,7 +135,7 @@ public class AccuRevCommandLine
             for ( File file : elements )
             {
                 String path = file.getPath();
-                //Hack for Windows "/./". TODO find a nicer way to handle this.
+                // Hack for Windows "/./". TODO find a nicer way to handle this.
                 if ( "\\.".equals( path ) )
                 {
                     path = "\\.\\";
@@ -133,11 +143,12 @@ public class AccuRevCommandLine
                 cl.createArg().setValue( path );
             }
         }
-        return executeCommandLine( null, stdoutConsumer );
+        return executeCommandLine( null, stdoutConsumer ) == 0;
     }
 
     private void setCommandLineArgs( String[] args )
     {
+
         cl.clearArgs();
 
         if ( args.length > 0 )
@@ -161,10 +172,10 @@ public class AccuRevCommandLine
         throws AccuRevException
     {
 
-        return executeCommandLine( args, null, null );
+        return executeCommandLine( args, null, null ) == 0;
     }
 
-    private boolean executeCommandLine( String[] args, InputStream stdin, StreamConsumer stdout )
+    private int executeCommandLine( String[] args, InputStream stdin, StreamConsumer stdout )
         throws AccuRevException
     {
 
@@ -174,9 +185,10 @@ public class AccuRevCommandLine
 
     }
 
-    private boolean executeCommandLine( InputStream stdin, StreamConsumer stdout )
+    private int executeCommandLine( InputStream stdin, StreamConsumer stdout )
         throws AccuRevException
     {
+
         commandLines.append( cl.toString() );
         commandLines.append( ';' );
 
@@ -192,7 +204,7 @@ public class AccuRevCommandLine
             {
                 getLogger().debug( "Non zero result - " + result );
             }
-            return result == 0;
+            return result;
         }
         catch ( CommandLineException ex )
         {
@@ -214,6 +226,7 @@ public class AccuRevCommandLine
                                       StreamConsumer stderr )
         throws CommandLineException
     {
+
         int result = CommandLineUtils.executeCommandLine( cl, stdin, stdout, stderr );
         stdout.waitComplete();
 
@@ -222,11 +235,13 @@ public class AccuRevCommandLine
 
     protected Commandline getCommandline()
     {
+
         return cl;
     }
 
     public void reset()
     {
+
         // TODO find out why Commandline allows executable, args etc to be initialised to
         // null, but not allowing them to be reset to null. This results is weird "clear"
         // behaviour. It is just safer to start again.
@@ -259,6 +274,7 @@ public class AccuRevCommandLine
     public boolean mkws( String basisStream, String workspaceName, File basedir )
         throws AccuRevException
     {
+
         setWorkingDirectory( basedir );
         String[] mkws = { "mkws", "-b", basisStream, "-w", workspaceName, "-l", basedir.getAbsolutePath() };
 
@@ -269,9 +285,10 @@ public class AccuRevCommandLine
     /**
      * {@inheritDoc}
      */
-    public boolean update( File baseDir, String transactionId, List<File> updatedFiles )
+    public List<File> update( File baseDir, String transactionId )
         throws AccuRevException
     {
+
         if ( transactionId == null )
         {
             transactionId = "highest";
@@ -279,16 +296,19 @@ public class AccuRevCommandLine
         String[] update = { "update", "-t", transactionId };
         setWorkingDirectory( baseDir );
 
-        return executeCommandLine( update, null, new FileConsumer( updatedFiles, FileConsumer.UPDATE_PATTERN ) );
+        List<File> updatedFiles = new ArrayList<File>();
+        return executeCommandLine( update, null, new FileConsumer( updatedFiles, FileConsumer.UPDATE_PATTERN ) ) == 0 ? updatedFiles
+                        : null;
 
     }
 
     /**
      * {@inheritDoc}
      */
-    public boolean add( File basedir, List<File> elements, String message, List<File> addedFiles )
+    public List<File> add( File basedir, List<File> elements, String message )
         throws AccuRevException
     {
+
         if ( StringUtils.isBlank( message ) )
         {
             message = AccuRev.DEFAULT_ADD_MESSAGE;
@@ -306,14 +326,16 @@ public class AccuRevCommandLine
             recursive = true;
         }
 
+        List<File> addedFiles = new ArrayList<File>();
         return executeCommandLine( basedir, new String[] { "add", "-c", message, recursive ? "-R" : null }, elements,
-                                   FileConsumer.ADD_PATTERN, addedFiles );
+                                   FileConsumer.ADD_PATTERN, addedFiles ) ? addedFiles : null;
 
     }
 
-    public boolean defunct( File basedir, List<File> files, String message, List<File> defunctedFiles )
+    public List<File> defunct( File basedir, List<File> files, String message )
         throws AccuRevException
     {
+
         if ( StringUtils.isBlank( message ) )
         {
             message = AccuRev.DEFAULT_REMOVE_MESSAGE;
@@ -324,68 +346,96 @@ public class AccuRevCommandLine
             files = Collections.singletonList( CURRENT_DIR );
         }
 
+        ArrayList<File> defunctFiles = new ArrayList<File>();
         return executeCommandLine( basedir, new String[] { "defunct", "-c", message }, files,
-                                   FileConsumer.DEFUNCT_PATTERN, defunctedFiles );
+                                   FileConsumer.DEFUNCT_PATTERN, defunctFiles ) ? defunctFiles : null;
     }
 
-    public boolean promote( File basedir, List<File> files, String message, List<File> promotedFiles )
+    public List<File> promote( File basedir, List<File> files, String message )
         throws AccuRevException
     {
+
         if ( StringUtils.isBlank( message ) )
         {
             message = AccuRev.DEFAULT_PROMOTE_MESSAGE;
         }
+        List<File> promotedFiles = new ArrayList<File>();
         return executeCommandLine( basedir, new String[] { "promote", "-K", "-c", message }, files,
-                                   FileConsumer.PROMOTE_PATTERN, promotedFiles );
+                                   FileConsumer.PROMOTE_PATTERN, promotedFiles ) ? promotedFiles : null;
 
     }
 
     public String getCommandLines()
     {
+
         return commandLines.toString();
     }
 
     public String getErrorOutput()
     {
+
         return errorOutput.toString();
     }
 
     public void setLogger( ScmLogger logger )
     {
+
         this.logger = logger;
         this.systemErr = new ErrorConsumer( logger, errorOutput );
     }
 
     public ScmLogger getLogger()
     {
+
         return logger;
     }
 
     public boolean mkdepot( String depotName )
         throws AccuRevException
     {
+
         String[] mkdepot = { "mkdepot", "-p", depotName };
 
         return executeCommandLine( mkdepot );
 
     }
 
+    public boolean mkstream( String backingStream, String newStreamName )
+        throws AccuRevException
+    {
+        String[] mkstream = { "mkstream", "-b", backingStream, "-s", newStreamName };
+        return executeCommandLine( mkstream );
+
+    }
+
+    public boolean promoteStream( String subStream, String commitMessage, List<File> promotedFiles )
+        throws AccuRevException
+    {
+        String[] promote = { "promote", "-s", subStream, "-d" };
+        return executeCommandLine( promote );
+
+    }
+
     /**
      * {@inheritDoc}
      */
-    public boolean promoteAll( File baseDir, String commitMessage, List<File> promotedFiles )
+    public List<File> promoteAll( File baseDir, String commitMessage )
         throws AccuRevException
     {
+
         setWorkingDirectory( baseDir );
         String[] promote = { "promote", "-p", "-K", "-c", commitMessage };
 
-        return executeCommandLine( promote, null, new FileConsumer( promotedFiles, FileConsumer.PROMOTE_PATTERN ) );
+        List<File> promotedFiles = new ArrayList<File>();
+        return executeCommandLine( promote, null, new FileConsumer( promotedFiles, FileConsumer.PROMOTE_PATTERN ) ) == 0 ? promotedFiles
+                        : null;
 
     }
 
     public AccuRevInfo info( File basedir )
         throws AccuRevException
     {
+
         setWorkingDirectory( basedir );
         String[] info = { "info" };
         AccuRevInfo result = new AccuRevInfo( basedir );
@@ -396,6 +446,7 @@ public class AccuRevCommandLine
 
     private void setWorkingDirectory( File basedir )
     {
+
         // TODO raise bug against plexus. Null is OK for working directory
         // but once set to not-null cannot be set back to null!
         // this is a problem if the old workingdir has been deleted
@@ -411,15 +462,17 @@ public class AccuRevCommandLine
     public boolean reactivate( String workSpaceName )
         throws AccuRevException
     {
+
         String[] reactivate = { "reactivate", "wspace", workSpaceName };
 
-        return executeCommandLine( reactivate, null, new CommandOutputConsumer( getLogger(), null ) );
+        return executeCommandLine( reactivate, null, new CommandOutputConsumer( getLogger(), null ) ) == 0;
 
     }
 
     public boolean rmws( String workSpaceName )
         throws AccuRevException
     {
+
         String[] rmws = { "rmws", "-s", workSpaceName };
 
         return executeCommandLine( rmws );
@@ -429,6 +482,7 @@ public class AccuRevCommandLine
     public String stat( File element )
         throws AccuRevException
     {
+
         String[] stat = { "stat", "-fx", element.getAbsolutePath() };
 
         StatConsumer statConsumer = new StatConsumer( getLogger() );
@@ -440,6 +494,7 @@ public class AccuRevCommandLine
     public boolean chws( File basedir, String workSpaceName, String newBasisStream )
         throws AccuRevException
     {
+
         setWorkingDirectory( basedir );
         return executeCommandLine( new String[] { "chws", "-s", workSpaceName, "-b", newBasisStream, "-l", "." } );
 
@@ -452,14 +507,16 @@ public class AccuRevCommandLine
         return executeCommandLine( new String[] { "mksnap", "-s", snapShotName, "-b", basisStream, "-t", "now" } );
     }
 
-    public boolean statTag( String streamName, List<File> taggedFiles )
+    public List<File> statTag( String streamName )
         throws AccuRevException
     {
-        return executeCommandLine( null, new String[] { "stat", "-a", "-ffl", "-s", streamName }, null,
-                                   FileConsumer.STAT_PATTERN, taggedFiles );
+
+        List<File> taggedFiles = new ArrayList<File>();
+        String[] stat = new String[] { "stat", "-a", "-ffl", "-s", streamName };
+        return executeCommandLine( null, stat, null, FileConsumer.STAT_PATTERN, taggedFiles ) ? taggedFiles : null;
     }
 
-    public boolean stat( File basedir, Collection<File> elements, AccuRevStat statType, List<File> matchingElements )
+    public List<File> stat( File basedir, Collection<File> elements, AccuRevStat statType )
         throws AccuRevException
     {
 
@@ -477,10 +534,12 @@ public class AccuRevCommandLine
 
         String[] args = { "stat", "-ffr", statType.getStatArg(), recursive ? "-R" : null };
 
-        return executeCommandLine( basedir, args, elements, statType.getMatchPattern(), matchingElements );
+        List<File> matchingElements = new ArrayList<File>();
+        return executeCommandLine( basedir, args, elements, statType.getMatchPattern(), matchingElements ) ? matchingElements
+                        : null;
     }
 
-    public boolean pop( File basedir, Collection<File> elements, List<File> poppedFiles )
+    public List<File> pop( File basedir, Collection<File> elements )
         throws AccuRevException
     {
 
@@ -491,10 +550,12 @@ public class AccuRevCommandLine
 
         String[] popws = { "pop", "-R" };
 
-        return executeCommandLine( basedir, popws, elements, FileConsumer.POPULATE_PATTERN, poppedFiles );
+        List<File> poppedFiles = new ArrayList<File>();
+        return executeCommandLine( basedir, popws, elements, FileConsumer.POPULATE_PATTERN, poppedFiles ) ? poppedFiles
+                        : null;
     }
 
-    public boolean pop( File basedir, String versionSpec, Collection<File> elements, List<File> poppedFiles )
+    public List<File> pop( File basedir, String versionSpec, Collection<File> elements )
         throws AccuRevException
     {
 
@@ -505,27 +566,34 @@ public class AccuRevCommandLine
 
         String[] pop = { "pop", "-v", versionSpec, "-L", basedir.getAbsolutePath(), "-R" };
 
-        return executeCommandLine( basedir, pop, elements, FileConsumer.POPULATE_PATTERN, poppedFiles );
+        List<File> poppedFiles = new ArrayList<File>();
+        return executeCommandLine( basedir, pop, elements, FileConsumer.POPULATE_PATTERN, poppedFiles ) ? poppedFiles
+                        : null;
     }
 
-    public boolean statBackingStream( File basedir, Collection<File> elements, Collection<File> memberElements,
-                                      Collection<File> nonMemberElements )
+    public CategorisedElements statBackingStream( File basedir, Collection<File> elements )
         throws AccuRevException
     {
+
+        CategorisedElements catElems = new CategorisedElements();
+
         if ( elements.isEmpty() )
         {
-            return true;
+            return catElems;
         }
         String[] args = { "stat", "-b", "-ffr" };
 
-        return executeCommandLine( basedir, args, elements, new StatBackingConsumer( memberElements, nonMemberElements ) );
+        return executeCommandLine( basedir, args, elements, new StatBackingConsumer( catElems.getMemberElements(),
+                                                                                     catElems.getNonMemberElements() ) ) ? catElems
+                        : null;
 
     }
 
-    public boolean history( String baseStream, String fromTimeSpec, String toTimeSpec, int count,
-                            List<Transaction> transactions )
+    public List<Transaction> history( String baseStream, String fromTimeSpec, String toTimeSpec, int count,
+                                      boolean depotHistory, boolean transactionsOnly )
         throws AccuRevException
     {
+
         String timeSpec = fromTimeSpec;
 
         if ( toTimeSpec != null )
@@ -538,9 +606,23 @@ public class AccuRevCommandLine
             timeSpec = timeSpec + "." + count;
         }
 
-        String[] hist = { "hist", "-fx", "-s", baseStream, "-t", timeSpec };
+        String[] hist =
+            { "hist", transactionsOnly ? "-ftx" : "-fx", depotHistory ? "-p" : "-s", baseStream, "-t", timeSpec };
+
+        ArrayList<Transaction> transactions = new ArrayList<Transaction>();
         HistoryConsumer stdout = new HistoryConsumer( getLogger(), transactions );
-        return executeCommandLine( hist, null, stdout );
+        return executeCommandLine( hist, null, stdout ) == 0 ? transactions : null;
+    }
+
+    public List<FileDifference> diff( String baseStream, String fromTimeSpec, String toTimeSpec )
+        throws AccuRevException
+    {
+        String timeSpec = fromTimeSpec + "-" + toTimeSpec;
+        String[] diff = { "diff", "-fx", "-a", "-i", "-v", baseStream, "-V", baseStream, "-t", timeSpec };
+
+        List<FileDifference> results = new ArrayList<FileDifference>();
+        DiffConsumer stdout = new DiffConsumer( getLogger(), results );
+        return executeCommandLine( diff, null, stdout ) < 2 ? results : null;
     }
 
     public boolean login( String user, String password )
@@ -562,7 +644,7 @@ public class AccuRevCommandLine
                 password = "\"\"";
             }
             String[] login = { "login", "-A", user, password };
-            result = executeCommandLine( login, null, stdout );
+            result = executeCommandLine( login, null, stdout ) == 0;
         }
         else
         {
@@ -570,7 +652,7 @@ public class AccuRevCommandLine
             password = StringUtils.clean( password ) + "\n";
             byte[] bytes = password.getBytes();
             ByteArrayInputStream stdin = new ByteArrayInputStream( bytes );
-            result = executeCommandLine( login, stdin, stdout );
+            result = executeCommandLine( login, stdin, stdout ) == 0;
 
         }
 
@@ -581,84 +663,74 @@ public class AccuRevCommandLine
     public boolean logout()
         throws AccuRevException
     {
+
         String[] logout = { "logout" };
         return executeCommandLine( logout );
 
     }
 
-    public boolean annotate( File basedir, File file, List<BlameLine> lines )
+    public List<BlameLine> annotate( File basedir, File file )
         throws AccuRevException
     {
 
         String[] annotate = { "annotate", "-ftud" };
+        List<BlameLine> lines = new ArrayList<BlameLine>();
         AnnotateConsumer stdout = new AnnotateConsumer( lines, getLogger() );
 
-        return executeCommandLine( basedir, annotate, Collections.singletonList( file ), stdout );
+        return executeCommandLine( basedir, annotate, Collections.singletonList( file ), stdout ) ? lines : null;
     }
-    
-    public boolean showRefTrees( Map<String, WorkSpace> workSpaces )
+
+    public Map<String, WorkSpace> showRefTrees()
         throws AccuRevException
     {
+
         String[] show = { "show", "-fx", "refs" };
-        WorkSpaceConsumer stdout = new WorkSpaceConsumer( getLogger(), workSpaces );
-        return executeCommandLine( show, null, stdout );
+        Map<String, WorkSpace> refTrees = new HashMap<String, WorkSpace>();
+        WorkSpaceConsumer stdout = new WorkSpaceConsumer( getLogger(), refTrees );
+        return executeCommandLine( show, null, stdout ) == 0 ? refTrees : null;
     }
 
-    public boolean showWorkSpaces( Map<String, WorkSpace> workSpaces )
+    public Map<String, WorkSpace> showWorkSpaces()
         throws AccuRevException
     {
+
         String[] show = { "show", "-a", "-fx", "wspaces" };
+        Map<String, WorkSpace> workSpaces = new HashMap<String, WorkSpace>();
         WorkSpaceConsumer stdout = new WorkSpaceConsumer( getLogger(), workSpaces );
-        return executeCommandLine( show, null, stdout );
+        return executeCommandLine( show, null, stdout ) == 0 ? workSpaces : null;
     }
 
-    public static void main( String[] args )
+    public Stream showStream( String stream )
         throws AccuRevException
     {
-        AccuRevCommandLine myCL = new AccuRevCommandLine( args[0], Integer.parseInt( args[1] ) );
-        myCL.setLogger( new DefaultLog()
-        {
+        String[] show = { "show", "-s", stream, "-fx", "streams" };
+        List<Stream> streams = new ArrayList<Stream>();
+        StreamsConsumer stdout = new StreamsConsumer( getLogger(), streams );
 
-            @Override
-            public void debug( String content )
-            {
-                debug( content, null );
-            }
+        return executeCommandLine( show, null, stdout ) == 0 && streams.size() == 1 ? streams.get( 0 ) : null;
+    }
 
-            @Override
-            public void debug( Throwable error )
-            {
-                debug( null, error );
-            }
+    public String getExecutable()
+    {
 
-            @Override
-            public void debug( String content, Throwable error )
-            {
-                if ( content != null )
-                {
-                    System.err.println( content );
-                }
-                if ( error != null )
-                {
-                    error.printStackTrace( System.err );
-                }
-            }
+        return executable;
+    }
 
-            @Override
-            public boolean isDebugEnabled()
-            {
-                return true;
-            }
-        } );
+    public String getClientVersion()
+        throws AccuRevException
+    {
 
-        myCL.login( args[2], args[3] );
+        long lastModified = new File( getExecutable() ).lastModified();
+        if ( clientVersion == null || executableModTime != lastModified )
+        {
+            executableModTime = lastModified;
 
-        System.out.println( Arrays.toString( myCL.authArgs ) );
+            ClientVersionConsumer stdout = new ClientVersionConsumer();
+            executeCommandLine( new String[] {}, null, stdout );
+            clientVersion = stdout.getClientVersion();
+        }
+        return clientVersion;
 
     }
 
-    public String getExecutable()
-    {
-        return executable;
-    }
 }

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/ClientVersionConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/ClientVersionConsumer.java?rev=980673&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/ClientVersionConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/ClientVersionConsumer.java Fri Jul 30 08:14:27 2010
@@ -0,0 +1,51 @@
+package org.apache.maven.scm.provider.accurev.cli;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+public class ClientVersionConsumer
+    implements StreamConsumer
+{
+    private static final Pattern CLIENT_VERSION_PATTERN = Pattern.compile( "^AccuRev ([0-9a-z.]+) .*" );
+
+    private String clientVersion;
+
+    public void consumeLine( String line )
+    {
+        if ( clientVersion == null )
+        {
+            Matcher matcher = CLIENT_VERSION_PATTERN.matcher( line );
+            if ( matcher.matches() )
+            {
+                clientVersion = matcher.group( 1 );
+            }
+        }
+    }
+
+    public String getClientVersion()
+    {
+        return clientVersion;
+    }
+
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/ClientVersionConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/ClientVersionConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/DiffConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/DiffConsumer.java?rev=980673&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/DiffConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/DiffConsumer.java Fri Jul 30 08:14:27 2010
@@ -0,0 +1,73 @@
+package org.apache.maven.scm.provider.accurev.cli;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.List;
+import java.util.Map;
+
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.accurev.FileDifference;
+
+public class DiffConsumer
+    extends XppStreamConsumer
+{
+
+    private List<FileDifference> results;
+
+    private FileDifference currentDifference;
+
+    public DiffConsumer( ScmLogger logger, List<FileDifference> results )
+    {
+        super( logger );
+        this.results = results;
+    }
+
+    @Override
+    protected void startTag( List<String> tagPath, Map<String, String> attributes )
+    {
+        String tagName = getTagName( tagPath );
+        if ( "Element".equals( tagName ) )
+        {
+            currentDifference = new FileDifference();
+        }
+        else if ( "Stream2".equals( tagName ) )
+        {
+            currentDifference.setElementId( Long.parseLong( attributes.get( "eid" ) ) );
+            currentDifference.setNewVersion( attributes.get( "Name" ), attributes.get( "Version" ) );
+        }
+        else if ( "Stream1".equals( tagName ) )
+        {
+            currentDifference.setElementId( Long.parseLong( attributes.get( "eid" ) ) );
+            currentDifference.setOldVersion( attributes.get( "Name" ), attributes.get( "Version" ) );
+        }
+
+    }
+
+    @Override
+    protected void endTag( List<String> tagPath )
+    {
+        String tagName = getTagName( tagPath );
+        if ( "Element".equals( tagName ) )
+        {
+            results.add( currentDifference );
+        }
+    }
+
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/DiffConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/DiffConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/StreamsConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/StreamsConsumer.java?rev=980673&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/StreamsConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/StreamsConsumer.java Fri Jul 30 08:14:27 2010
@@ -0,0 +1,58 @@
+package org.apache.maven.scm.provider.accurev.cli;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.accurev.Stream;
+
+public class StreamsConsumer
+    extends XppStreamConsumer
+{
+
+    private List<Stream> streams;
+
+    public StreamsConsumer( ScmLogger logger, List<Stream> streams )
+    {
+        super( logger );
+        this.streams = streams;
+    }
+
+    @Override
+    protected void startTag( List<String> tagPath, Map<String, String> attributes )
+    {
+        String tagName = getTagName( tagPath );
+        if ( "stream".equals( tagName ) )
+        {
+            String name = attributes.get( "name" );
+            long streamId = Long.parseLong( attributes.get( "streamNumber" ) );
+            String basis = attributes.get( "basis" );
+            String basisStreamNumber = attributes.get( "basisStreamNumber" );
+            long basisStreamId = basisStreamNumber == null ? 0 : Long.parseLong( basisStreamNumber );
+            String depot = attributes.get( "depotName" );
+            Date startTime = new Date( Long.parseLong( attributes.get( "startTime" ) ) * 1000 );
+            String streamType = attributes.get( "type" );
+            streams.add( new Stream( name, streamId, basis, basisStreamId, depot, startTime, streamType ) );
+        }
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/StreamsConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/StreamsConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/XppStreamConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/XppStreamConsumer.java?rev=980673&r1=980672&r2=980673&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/XppStreamConsumer.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/XppStreamConsumer.java Fri Jul 30 08:14:27 2010
@@ -20,8 +20,12 @@ package org.apache.maven.scm.provider.ac
  */
 
 import java.io.IOException;
-import java.io.PipedReader;
-import java.io.PipedWriter;
+import java.io.Writer;
+import java.nio.channels.Channels;
+import java.nio.channels.Pipe;
+import java.nio.channels.Pipe.SinkChannel;
+import java.nio.channels.Pipe.SourceChannel;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -49,9 +53,7 @@ public abstract class XppStreamConsumer
         return logger;
     }
 
-    private PipedWriter writer;
-
-    private PipedReader reader;
+    private Writer writer;
 
     private XmlPullParser parser = new MXParser();
 
@@ -59,36 +61,41 @@ public abstract class XppStreamConsumer
 
     private ScmLogger logger;
 
+    private int lineCount = 0;
+
     public XppStreamConsumer( ScmLogger logger )
     {
 
         super();
         this.logger = logger;
-        writer = new PipedWriter();
         try
         {
-            reader = new PipedReader( writer );
-            parser.setInput( reader );
+            Pipe p = Pipe.open();
+            SinkChannel sink = p.sink();
+            SourceChannel source = p.source();
+
+            writer = Channels.newWriter( sink, Charset.defaultCharset().name() );
+            parser.setInput( Channels.newReader( source, Charset.defaultCharset().name() ) );
         }
         catch ( Exception e )
         {
             logger.error( "Exception initialising pipe", e );
         }
 
-        this.start();
-
     }
 
     public final void consumeLine( String line )
     {
-        if ( logger.isDebugEnabled() )
-        {
-            logger.debug( "Consumed: " + line );
-        }
-
+        // Do not debug line here - as CommandOutputConsumer wraps this and uses
+        // the same logger
         try
         {
             writer.append( line );
+            if ( lineCount == 0 )
+            {
+                this.start();
+            }
+            lineCount++;
             writer.flush();
         }
         catch ( IOException e )
@@ -199,20 +206,16 @@ public abstract class XppStreamConsumer
      */
     public void waitComplete()
     {
-
-        //Can close the writer here because CommandLineUtils waits for the StreamPumpers to finish.
-        if ( writer != null )
+        Thread.yield();
+        try
         {
-            try
-            {
-                writer.close();
-            }
-            catch ( IOException e )
-            {
-                logger.warn( e );
-            }
-
+            writer.close();
         }
+        catch ( IOException e1 )
+        {
+            logger.warn( "Exception flushing output", e1 );
+        }
+
         while ( !isComplete() )
         {
 
@@ -222,21 +225,22 @@ public abstract class XppStreamConsumer
                 {
                     if ( !isComplete() )
                     {
-                        this.wait( 2000 );
+                        this.wait( 1000 );
                     }
                 }
                 catch ( Exception e )
                 {
                     logger.warn( e );
-                }
 
+                }
             }
         }
+
     }
 
     private boolean isComplete()
     {
-        return complete;
+        return complete || lineCount == 0;
     }
 
     protected void startTag( List<String> tagPath, Map<String, String> attributes )

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/AbstractAccuRevExtractSourceCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/AbstractAccuRevExtractSourceCommand.java?rev=980673&r1=980672&r2=980673&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/AbstractAccuRevExtractSourceCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/AbstractAccuRevExtractSourceCommand.java Fri Jul 30 08:14:27 2010
@@ -20,7 +20,6 @@ package org.apache.maven.scm.provider.ac
  */
 
 import java.io.File;
-import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.maven.scm.CommandParameter;
@@ -51,8 +50,6 @@ public abstract class AbstractAccuRevExt
         throws ScmException, AccuRevException
     {
 
-        List<File> checkedOutFiles = new ArrayList<File>();
-
         ScmVersion scmVersion = parameters.getScmVersion( CommandParameter.SCM_VERSION, null );
 
         AccuRevVersion accuRevVersion = repository.getAccuRevVersion( scmVersion );
@@ -77,18 +74,17 @@ public abstract class AbstractAccuRevExt
             throw new ScmException( "Checkout directory " + basedir.getAbsolutePath() + " not empty" );
         }
 
-        boolean success = extractSource( repository, basedir, basisStream, transactionId, checkedOutFiles );
-
-        List<ScmFile> scmFiles = getScmFiles( checkedOutFiles, ScmFileStatus.CHECKED_OUT );
+        List<File> checkedOutFiles = extractSource( repository, basedir, basisStream, transactionId );
+        List<ScmFile> scmFiles =
+            checkedOutFiles == null ? null : getScmFiles( checkedOutFiles, ScmFileStatus.CHECKED_OUT );
 
-        return getScmResult( repository, scmFiles, success );
+        return getScmResult( repository, scmFiles );
 
     }
 
-    protected abstract ScmResult getScmResult( AccuRevScmProviderRepository repository, List<ScmFile> scmFiles,
-                                               boolean success );
+    protected abstract ScmResult getScmResult( AccuRevScmProviderRepository repository, List<ScmFile> scmFiles );
 
-    protected abstract boolean extractSource( AccuRevScmProviderRepository repository, File basedir,
-                                              String basisStream, String transactionId, List<File> checkedOutFiles )
+    protected abstract List<File> extractSource( AccuRevScmProviderRepository repository, File basedir,
+                                                 String basisStream, String transactionId )
         throws AccuRevException;
 }
\ No newline at end of file

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/add/AccuRevAddCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/add/AccuRevAddCommand.java?rev=980673&r1=980672&r2=980673&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/add/AccuRevAddCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/add/AccuRevAddCommand.java Fri Jul 30 08:14:27 2010
@@ -20,7 +20,6 @@ package org.apache.maven.scm.provider.ac
  */
 
 import java.io.File;
-import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.maven.scm.CommandParameter;
@@ -52,30 +51,25 @@ public class AccuRevAddCommand
      * 
      * @todo handle the "binary" parameter. AccuRev does a reasonable job of detecting this itself.
      */
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     protected ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
                                                CommandParameters parameters )
         throws ScmException, AccuRevException
     {
 
-        final List<File> addedFiles = new ArrayList<File>();
-
         AccuRev accuRev = repository.getAccuRev();
 
         String message = parameters.getString( CommandParameter.MESSAGE, "" );
 
-        boolean success = true;
-
         File basedir = fileSet.getBasedir();
 
         List<File> relativeFiles = fileSet.getFileList();
 
-        success = accuRev.add( basedir, relativeFiles, message, addedFiles );
-
-        List<ScmFile> resultFiles = getScmFiles( addedFiles, ScmFileStatus.ADDED );
+        List<File> addedFiles = accuRev.add( basedir, relativeFiles, message );
 
-        if ( success )
+        if ( addedFiles != null )
         {
+            List<ScmFile> resultFiles = getScmFiles( addedFiles, ScmFileStatus.ADDED );
             return new AddScmResult( accuRev.getCommandLines(), resultFiles );
         }
         else

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommand.java?rev=980673&r1=980672&r2=980673&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommand.java Fri Jul 30 08:14:27 2010
@@ -20,13 +20,13 @@ package org.apache.maven.scm.provider.ac
  */
 
 import java.io.File;
-import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.maven.scm.CommandParameter;
 import org.apache.maven.scm.CommandParameters;
 import org.apache.maven.scm.ScmException;
 import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.blame.BlameLine;
 import org.apache.maven.scm.command.blame.BlameScmResult;
 import org.apache.maven.scm.log.ScmLogger;
 import org.apache.maven.scm.provider.ScmProviderRepository;
@@ -50,7 +50,6 @@ public class AccuRevBlameCommand
         super( logger );
     }
 
-    @SuppressWarnings( "unchecked" )
     @Override
     protected BlameScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
                                                     CommandParameters parameters )
@@ -58,13 +57,12 @@ public class AccuRevBlameCommand
     {
 
         AccuRev accuRev = repository.getAccuRev();
-        List/* <BlameLine> */lines = new ArrayList();
 
         File file = new File( parameters.getString( CommandParameter.FILE ) );
 
-        boolean success = accuRev.annotate( fileSet.getBasedir(), file, lines );
+        List<BlameLine> lines = accuRev.annotate( fileSet.getBasedir(), file );
 
-        if ( success )
+        if ( lines != null )
         {
             return new BlameScmResult( accuRev.getCommandLines(), lines );
         }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommand.java?rev=980673&r1=980672&r2=980673&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommand.java Fri Jul 30 08:14:27 2010
@@ -19,11 +19,13 @@ package org.apache.maven.scm.provider.ac
  * under the License.
  */
 
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.maven.scm.ChangeFile;
 import org.apache.maven.scm.ChangeSet;
@@ -33,22 +35,30 @@ import org.apache.maven.scm.ScmBranch;
 import org.apache.maven.scm.ScmException;
 import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.ScmRevision;
 import org.apache.maven.scm.ScmVersion;
 import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
 import org.apache.maven.scm.command.changelog.ChangeLogSet;
 import org.apache.maven.scm.log.ScmLogger;
 import org.apache.maven.scm.provider.ScmProviderRepository;
 import org.apache.maven.scm.provider.accurev.AccuRev;
+import org.apache.maven.scm.provider.accurev.AccuRevCapability;
 import org.apache.maven.scm.provider.accurev.AccuRevException;
 import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
 import org.apache.maven.scm.provider.accurev.AccuRevVersion;
+import org.apache.maven.scm.provider.accurev.FileDifference;
+import org.apache.maven.scm.provider.accurev.Stream;
 import org.apache.maven.scm.provider.accurev.Transaction;
 import org.apache.maven.scm.provider.accurev.Transaction.Version;
 import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommand;
 import org.codehaus.plexus.util.StringUtils;
 
 /**
- * TODO filter results based on project_path
+ * TODO filter results based on project_path Find appropriate start and end transaction ids from parameters. Streams
+ * must be the same. Diff on stream start to end - these are the upstream changes Hist on the stream start+1 to end
+ * remove items from the upstream set if they appear in the history For workspaces diff doesn't work. So we would not
+ * pickup any upstream changes, just the "keep" transactions which is not very useful. Hist on the workspace Then diff /
+ * hist on the basis stream, skipping any transactions that are coming from the workspace.
  * 
  * @author ggardner
  */
@@ -58,6 +68,7 @@ public class AccuRevChangeLogCommand
 
     public AccuRevChangeLogCommand( ScmLogger logger )
     {
+
         super( logger );
     }
 
@@ -81,8 +92,11 @@ public class AccuRevChangeLogCommand
         if ( startVersion != null && StringUtils.isNotEmpty( startVersion.getName() ) )
         {
             AccuRevVersion fromVersion = repository.getAccuRevVersion( startVersion );
-            AccuRevVersion toVersion = repository.getAccuRevVersion( endVersion );
-
+            // if no end version supplied then use same basis as startVersion
+            AccuRevVersion toVersion =
+                endVersion == null ? new AccuRevVersion( fromVersion.getBasisStream(), "now" )
+                                : repository.getAccuRevVersion( endVersion );
+                
             if ( !StringUtils.equals( fromVersion.getBasisStream(), toVersion.getBasisStream() ) )
             {
                 throw new AccuRevException( "Not able to provide change log between different streams " + fromVersion
@@ -108,7 +122,7 @@ public class AccuRevChangeLogCommand
             // Last x days.
             int day = 24 * 60 * 60 * 1000;
             startDate = new Date( System.currentTimeMillis() - (long) numDays * day );
-            endDate = new Date( System.currentTimeMillis() + (long) day );
+            endDate = new Date( System.currentTimeMillis() + day );
         }
 
         if ( endDate != null && startDate == null )
@@ -116,110 +130,189 @@ public class AccuRevChangeLogCommand
             throw new ScmException( "The end date is set but the start date isn't." );
         }
 
-        if ( startDate == null )
+        // Date parameters override transaction ids in versions
+        if ( startDate != null )
         {
-            if ( fromSpec == null )
-            {
-                fromSpec = "1";
-            }
-            startDate = getSpecAsDate( repository, stream, fromSpec );
+            fromSpec = AccuRevScmProviderRepository.formatTimeSpec( startDate );
         }
-        else
+        else if ( fromSpec == null )
         {
-            fromSpec = formatTimeSpec( startDate );
+            fromSpec = "1";
         }
 
-        if ( endDate == null )
+        // Convert the fromSpec to both a date AND a transaction id by looking up
+        // the nearest transaction in the depot.
+        Transaction fromTransaction = getDepotTransaction( repository, stream, fromSpec );
+
+        long fromTranId = 1;
+        if ( fromTransaction != null )
         {
-            if ( toSpec == null )
+            // This tran id is less than or equal to the date/tranid we requested.
+            fromTranId = fromTransaction.getTranId();
+            if ( startDate == null )
             {
-                toSpec = "highest";
+                startDate = fromTransaction.getWhen();
             }
-            endDate = getSpecAsDate( repository, stream, toSpec );
-        }
-        else
-        {
-            toSpec = formatTimeSpec( endDate );
         }
 
-        List<Transaction> streamHistory = new ArrayList<Transaction>();
-
-        AccuRev accurev = repository.getAccuRev();
-
-        String message = "Changelog: from " + fromSpec + " (" + startDate + "), to " + toSpec + " (" + endDate + ")";
-        boolean success = true;
-        if ( startDate != null && startDate.after( endDate ) )
+        if ( endDate != null )
         {
-            getLogger().warn( "Skipping " + message );
+            toSpec = AccuRevScmProviderRepository.formatTimeSpec( endDate );
         }
-        else
+        else if ( toSpec == null )
         {
-            getLogger().info( message );
-            success = accurev.history( stream, fromSpec, toSpec, 0, streamHistory );
+            toSpec = "highest";
         }
 
-        if ( success )
+        Transaction toTransaction = getDepotTransaction( repository, stream, toSpec );
+        long toTranId = 1;
+        if ( toTransaction != null )
         {
-            return new ChangeLogScmResult( accurev.getCommandLines(), getChangeLog( streamHistory, startDate, endDate ) );
-        }
-        else
-        {
-            return new ChangeLogScmResult( accurev.getCommandLines(), "AccuRev Error", accurev.getErrorOutput(), false );
-        }
-
-    }
-
-    public static String formatTimeSpec( Date when )
-    {
-        if ( when == null )
-        {
-            return "now";
+            toTranId = toTransaction.getTranId();
+            if ( endDate == null )
+            {
+                endDate = toTransaction.getWhen();
+            }
         }
+        startVersion = new ScmRevision( repository.getRevision( stream, fromTranId ) );
+        endVersion = new ScmRevision( repository.getRevision( stream, toTranId ) );
 
-        return AccuRev.ACCUREV_TIME_SPEC.format( when );
+        //TODO Split this method in two here. above to convert params to start and end (stream,tranid,date) and test independantly
+        
+        List<Transaction> streamHistory = Collections.emptyList();
+        List<Transaction> workspaceHistory = Collections.emptyList();
+        List<FileDifference> streamDifferences = Collections.emptyList();
 
-    }
+        StringBuffer errorMessage = new StringBuffer();
 
-    private Date getSpecAsDate( AccuRevScmProviderRepository repo, String stream, String timeSpec )
-        throws AccuRevException
-    {
+        AccuRev accurev = repository.getAccuRev();
 
-        if ( "now".equals( timeSpec ) || "highest".equals( timeSpec ) )
+        Stream changelogStream = accurev.showStream( stream );
+        if ( changelogStream == null )
         {
-            return new Date();
+            errorMessage.append( "Unknown accurev stream -" ).append( stream ).append( "." );
         }
-
-        if ( StringUtils.isNumeric( timeSpec ) )
+        else
         {
-            AccuRev accuRev = repo.getAccuRev();
-            List<Transaction> transactions = new ArrayList<Transaction>();
-            accuRev.history( stream, timeSpec, null, 1, transactions );
-            if ( transactions.size() > 0 )
+
+            String message =
+                "Changelog on stream " + stream + "(" + changelogStream.getStreamType() + ") from " + fromTranId + " ("
+                    + startDate + "), to " + toTranId + " (" + endDate + ")";
+
+            if ( startDate != null && startDate.after( endDate ) || fromTranId >= toTranId )
             {
-                return transactions.get( 0 ).getWhen();
+                getLogger().warn( "Skipping out of range " + message );
             }
             else
             {
-                return null;
+
+                getLogger().info( message );
+
+                // In 4.7.2 and higher we have a diff command that will list all the file differences in a stream
+                // and thus can be used to detect upstream changes
+                // Unfortunately diff -v -V -t does not work in workspaces.
+                Stream diffStream = changelogStream;
+                if ( changelogStream.isWorkspace() )
+                {
+
+                    workspaceHistory =
+                        accurev.history( stream, Long.toString( fromTranId + 1 ), Long.toString( toTranId ), 0, false,
+                                         false );
+
+                    if ( workspaceHistory == null )
+                    {
+                        errorMessage.append( "history on workspace " + stream + " from " + fromTranId + 1 + " to "
+                            + toTranId + " failed." );
+
+                    }
+
+                    // do the diff/hist on the basis stream instead.
+                    stream = changelogStream.getBasis();
+                    diffStream = accurev.showStream( stream );
+
+                }
+
+                if ( AccuRevCapability.DIFF_BETWEEN_STREAMS.isSupported( accurev.getClientVersion() ) )
+                {
+                    if ( startDate.before( diffStream.getStartDate() ) )
+                    {
+                        getLogger().warn( "Skipping diff of " + stream + " due to start date out of range" );
+                    }
+                    else
+                    {
+                        streamDifferences =
+                            accurev.diff( stream, Long.toString( fromTranId ), Long.toString( toTranId ) );
+                        if ( streamDifferences == null )
+                        {
+                            errorMessage.append( "Diff " + stream + "- " + fromTranId + " to " + toTranId + "failed." );
+                        }
+                    }
+                }
+
+                // History needs to start from the transaction after our starting transaction
+
+                streamHistory =
+                    accurev.history( stream, Long.toString( fromTranId + 1 ), Long.toString( toTranId ), 0, false,
+                                     false );
+                if ( streamHistory == null )
+                {
+                    errorMessage.append( "history on stream " + stream + " from " + fromTranId + 1 + " to " + toTranId
+                        + " failed." );
+                }
+
             }
         }
 
-        try
+        String errorString = errorMessage.toString();
+        if ( StringUtils.isBlank( errorString ) )
         {
-            return AccuRev.ACCUREV_TIME_SPEC.parse( timeSpec );
+            ChangeLogSet changeLog =
+                getChangeLog( changelogStream, streamDifferences, streamHistory, workspaceHistory, startDate, endDate );
+
+            changeLog.setEndVersion( endVersion );
+            changeLog.setStartVersion( startVersion );
+
+            return new ChangeLogScmResult( accurev.getCommandLines(), changeLog );
         }
-        catch ( ParseException e )
+        else
         {
-            throw new AccuRevException( "Invalid timespec " + timeSpec, e );
+            return new ChangeLogScmResult( accurev.getCommandLines(), "AccuRev errors: " + errorMessage,
+                                           accurev.getErrorOutput(), false );
         }
 
     }
 
-    private ChangeLogSet getChangeLog( List<Transaction> streamHistory, Date startDate, Date endDate )
+    private Transaction getDepotTransaction( AccuRevScmProviderRepository repo, String stream, String tranSpec )
+        throws AccuRevException
+    {
+        return repo.getDepotTransaction( stream, tranSpec );
+
+    }
+
+    private ChangeLogSet getChangeLog( Stream stream, List<FileDifference> streamDifferences,
+                                       List<Transaction> streamHistory, List<Transaction> workspaceHistory,
+                                       Date startDate, Date endDate )
     {
 
+        // Collect all the "to" versions from the streamDifferences into a Map by element id
+        // If that version is seen in the promote/keep history then we move it from the map
+        // At the end we create a pseudo ChangeSet for any remaining entries in the map as
+        // representing "upstream changes"
+        Map<Long, FileDifference> differencesMap = new HashMap<Long, FileDifference>();
+        for ( FileDifference fileDifference : streamDifferences )
+        {
+            differencesMap.put( fileDifference.getElementId(), fileDifference );
+        }
+
+        List<Transaction> mergedHistory = new ArrayList<Transaction>( streamHistory );
+        // will never match a version
+        String streamPrefix = "/";
+
+        mergedHistory.addAll( workspaceHistory );
+        streamPrefix = stream.getId() + "/";
+
         List<ChangeSet> entries = new ArrayList<ChangeSet>( streamHistory.size() );
-        for ( Transaction t : streamHistory )
+        for ( Transaction t : mergedHistory )
         {
             if ( ( startDate != null && t.getWhen().before( startDate ) )
                 || ( endDate != null && t.getWhen().after( endDate ) ) )
@@ -228,16 +321,92 @@ public class AccuRevChangeLogCommand
                 continue;
             }
 
+            // Needed to make Tck test pass against accurev > 4.7.2 - the changelog only expects to deal with
+            // files. Stream changes and cross links are important entries in the changelog.
+            // However we should only see mkstream once and it is irrelevant given we are interrogating
+            // the history of this stream.
+            if ( "mkstream".equals( t.getTranType() ) )
+            {
+                continue;
+            }
+
             Collection<Version> versions = t.getVersions();
             List<ChangeFile> files = new ArrayList<ChangeFile>( versions.size() );
+
             for ( Version v : versions )
             {
-                ChangeFile f = new ChangeFile( v.getElementName(), v.getVirtualSpec() + " (" + v.getRealSpec() + ")" );
-                files.add( f );
+
+                // Remove diff representing this promote
+                FileDifference difference = differencesMap.get( v.getElementId() );
+                // TODO: how are defuncts shown in the version history?
+                if ( difference != null )
+                {
+                    String newVersionSpec = difference.getNewVersionSpec();
+                    if ( newVersionSpec != null && newVersionSpec.equals( v.getRealSpec() ) )
+                    {
+                        if ( getLogger().isDebugEnabled() )
+                        {
+                            getLogger().debug( "Removing difference for " + v );
+                        }
+                        differencesMap.remove( v.getElementId() );
+                    }
+                }
+
+                // Add this file, unless the virtual version indicates this is the basis stream, and the real
+                // version came from our workspace stream (ie, this transaction is a promote from the workspace
+                // to its basis stream, and is therefore NOT a change
+                if ( v.getRealSpec().startsWith( streamPrefix ) && !v.getVirtualSpec().startsWith( streamPrefix ) )
+                {
+                    if ( getLogger().isDebugEnabled() )
+                    {
+                        getLogger().debug( "Skipping workspace to basis stream promote " + v );
+                    }
+                }
+                else
+                {
+                    ChangeFile f =
+                        new ChangeFile( v.getElementName(), v.getVirtualSpec() + " (" + v.getRealSpec() + ")" );
+                    files.add( f );
+                }
+
+            }
+
+            if ( versions.isEmpty() || !files.isEmpty() )
+            {
+                ChangeSet changeSet = new ChangeSet( t.getWhen(), t.getComment(), t.getAuthor(), files );
+
+                entries.add( changeSet );
+            }
+            else
+            {
+                if ( getLogger().isDebugEnabled() )
+                {
+                    getLogger().debug( "All versions removed for " + t );
+                }
             }
-            ChangeSet changeSet = new ChangeSet( t.getWhen(), t.getComment(), t.getAuthor(), files );
 
-            entries.add( changeSet );
+        }
+
+        // Anything left in the differencesMap represents a change from a higher stream
+        // We don't have details on who or where these came from, but it is important to
+        // detect these for CI tools like Continuum
+        if ( !differencesMap.isEmpty() )
+        {
+            List<ChangeFile> upstreamFiles = new ArrayList<ChangeFile>();
+            for ( FileDifference difference : differencesMap.values() )
+            {
+                if ( difference.getNewVersionSpec() != null )
+                {
+                    upstreamFiles.add( new ChangeFile( difference.getNewFile().getPath(),
+                                                       difference.getNewVersionSpec() ) );
+                }
+                else
+                {
+                    // difference is a deletion
+                    upstreamFiles.add( new ChangeFile( difference.getOldFile().getPath(), null ) );
+                }
+            }
+            entries.add( new ChangeSet( endDate, "Upstream changes", "various", upstreamFiles ) );
         }
 
         return new ChangeLogSet( entries, startDate, endDate );
@@ -246,6 +415,7 @@ public class AccuRevChangeLogCommand
     public ChangeLogScmResult changelog( ScmProviderRepository repo, ScmFileSet testFileSet, CommandParameters params )
         throws ScmException
     {
+
         return (ChangeLogScmResult) execute( repo, testFileSet, params );
     }
 

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommand.java?rev=980673&r1=980672&r2=980673&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommand.java Fri Jul 30 08:14:27 2010
@@ -20,7 +20,6 @@ package org.apache.maven.scm.provider.ac
  */
 
 import java.io.File;
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
@@ -57,12 +56,10 @@ public class AccuRevCheckInCommand
         AccuRev accuRev = repository.getAccuRev();
 
         String message = parameters.getString( CommandParameter.MESSAGE );
-        final List<File> promotedFiles = new ArrayList<File>();
-
-        boolean success = false;
+        List<File> promotedFiles = null;
 
         File basedir = fileSet.getBasedir();
-        @SuppressWarnings("unchecked")
+        @SuppressWarnings( "unchecked" )
         List<File> fileList = fileSet.getFileList();
 
         if ( fileList.isEmpty() )
@@ -74,7 +71,7 @@ public class AccuRevCheckInCommand
 
             if ( repository.isWorkSpaceRoot( info ) )
             {
-                success = accuRev.promoteAll( basedir, message, promotedFiles );
+                promotedFiles = accuRev.promoteAll( basedir, message );
             }
             else
             {
@@ -84,20 +81,21 @@ public class AccuRevCheckInCommand
         }
         else
         {
-            success = accuRev.promote( basedir, fileList, message, promotedFiles );
+            promotedFiles = accuRev.promote( basedir, fileList, message );
         }
 
-        Iterator<File> iter = promotedFiles.iterator();
-        while ( iter.hasNext() )
+
+        if ( promotedFiles != null )
         {
-            if ( new File( basedir, iter.next().getPath() ).isDirectory() )
+            Iterator<File> iter = promotedFiles.iterator();
+            while ( iter.hasNext() )
             {
-                iter.remove();
+                if ( new File( basedir, iter.next().getPath() ).isDirectory() )
+                {
+                    iter.remove();
+                }
             }
-        }
-
-        if ( success )
-        {
+            // TODO capture the transaction id from the promote
             return new CheckInScmResult( accuRev.getCommandLines(), getScmFiles( promotedFiles,
                                                                                  ScmFileStatus.CHECKED_IN ) );
         }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/checkout/AccuRevCheckOutCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/checkout/AccuRevCheckOutCommand.java?rev=980673&r1=980672&r2=980673&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/checkout/AccuRevCheckOutCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/checkout/AccuRevCheckOutCommand.java Fri Jul 30 08:14:27 2010
@@ -20,6 +20,7 @@ package org.apache.maven.scm.provider.ac
  */
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.maven.scm.CommandParameters;
@@ -54,23 +55,26 @@ public class AccuRevCheckOutCommand
     }
 
     @Override
-    protected boolean extractSource( AccuRevScmProviderRepository repository, File basedir, String basisStream,
-                                     String transactionId, List<File> checkedOutFiles )
+    protected List<File> extractSource( AccuRevScmProviderRepository repository, File basedir, String basisStream,
+                                        String transactionId )
         throws AccuRevException
     {
         AccuRev accuRev = repository.getAccuRev();
 
         AccuRevInfo info = accuRev.info( basedir );
 
+        List<File> extractedFiles = new ArrayList<File>();
+
         boolean success = true;
         if ( info.isWorkSpace() )
         {
 
             if ( !repository.isWorkSpaceTop( info ) )
             {
-                throw new AccuRevException( String
-                    .format( "Can't checkout to %s, a subdirectory of existing workspace %s", basedir, info
-                        .getWorkSpace() ) );
+                throw new AccuRevException(
+                                            String.format(
+                                                           "Can't checkout to %s, a subdirectory of existing workspace %s",
+                                                           basedir, info.getWorkSpace() ) );
             }
             // workspace exists at this basedir already.
             if ( !basisStream.equals( info.getBasis() ) )
@@ -82,8 +86,15 @@ public class AccuRevCheckOutCommand
             if ( success )
             {
                 // repopulate everything in the workspace.
-                success = accuRev.pop( basedir, null, checkedOutFiles );
-
+                List<File> poppedFiles = accuRev.pop( basedir, null );
+                if ( poppedFiles != null )
+                {
+                    extractedFiles.addAll( poppedFiles );
+                }
+                else
+                {
+                    success = false;
+                }
             }
 
         }
@@ -91,7 +102,8 @@ public class AccuRevCheckOutCommand
         {
             // not a workspace, make one...
             // TODO set incl rules to only include the projectPath
-
+            // TODO somehow set provider message (via throw exception?
+            // if basisStream is null
             String workSpaceName = getWorkSpaceName( basedir, basisStream );
 
             success = accuRev.mkws( basisStream, workSpaceName, basedir );
@@ -104,17 +116,25 @@ public class AccuRevCheckOutCommand
 
         if ( success )
         {
-            success = accuRev.update( basedir, transactionId, checkedOutFiles );
+            List<File> updatedFiles = accuRev.update( basedir, transactionId );
+            if ( updatedFiles != null )
+            {
+                extractedFiles.addAll( updatedFiles );
+            }
+            else
+            {
+                success = false;
+            }
         }
-        return success;
+        return success ? extractedFiles : null;
     }
 
     @Override
-    protected ScmResult getScmResult( AccuRevScmProviderRepository repository, List<ScmFile> scmFiles, boolean success )
+    protected ScmResult getScmResult( AccuRevScmProviderRepository repository, List<ScmFile> scmFiles )
     {
 
         AccuRev accuRev = repository.getAccuRev();
-        if ( success )
+        if ( scmFiles != null )
         {
             return new CheckOutScmResult( accuRev.getCommandLines(), scmFiles, repository.getProjectPath() );
         }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/export/AccuRevExportCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/export/AccuRevExportCommand.java?rev=980673&r1=980672&r2=980673&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/export/AccuRevExportCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/export/AccuRevExportCommand.java Fri Jul 30 08:14:27 2010
@@ -54,8 +54,8 @@ public class AccuRevExportCommand
     }
 
     @Override
-    protected boolean extractSource( AccuRevScmProviderRepository repository, File basedir, String basisStream,
-                                     String transactionId, List<File> checkedOutFiles )
+    protected List<File> extractSource( AccuRevScmProviderRepository repository, File basedir, String basisStream,
+                                        String transactionId )
         throws AccuRevException
     {
         AccuRev accuRev = repository.getAccuRev();
@@ -65,7 +65,6 @@ public class AccuRevExportCommand
 
         boolean removedWorkspace = false;
 
-        boolean success;
         // We'll do a pop -V.
 
         if ( info.isWorkSpace() )
@@ -75,9 +74,11 @@ public class AccuRevExportCommand
 
             if ( stat != null )
             {
-                throw new AccuRevException( String
-                    .format( "Cannot populate %s, as it is a non-ignored subdirectory of workspace %s rooted at %s.",
-                             basedir.getAbsolutePath(), info.getWorkSpace(), info.getTop() ) );
+                throw new AccuRevException(
+                                            String.format(
+                                                           "Cannot populate %s, as it is a non-ignored subdirectory of workspace %s rooted at %s.",
+                                                           basedir.getAbsolutePath(), info.getWorkSpace(),
+                                                           info.getTop() ) );
             }
 
             // ok, the subdirectory must be ignored. temporarily remove the workspace.
@@ -87,8 +88,8 @@ public class AccuRevExportCommand
 
         try
         {
-            success = accuRev.pop( basedir, basisStream, Collections.singletonList( new File( repository
-                .getDepotRelativeProjectPath() ) ), checkedOutFiles );
+            return accuRev.pop( basedir, basisStream,
+                                Collections.singletonList( new File( repository.getDepotRelativeProjectPath() ) ) );
 
         }
         finally
@@ -98,7 +99,6 @@ public class AccuRevExportCommand
                 accuRev.reactivate( info.getWorkSpace() );
             }
         }
-        return success;
     }
 
     private void validateTransactionId( String transactionId )
@@ -116,15 +116,14 @@ public class AccuRevExportCommand
             return;
         }
 
-        throw new AccuRevException( "Transaction id " + transactionId
-            + " out of range. Export can only extract current sources" );
+        getLogger().warn( String.format("Ignoring transaction id %s, Export can only extract current sources",transactionId ));
     }
 
     @Override
-    protected ScmResult getScmResult( AccuRevScmProviderRepository repository, List<ScmFile> scmFiles, boolean success )
+    protected ScmResult getScmResult( AccuRevScmProviderRepository repository, List<ScmFile> scmFiles )
     {
         AccuRev accuRev = repository.getAccuRev();
-        if ( success )
+        if ( scmFiles != null )
         {
             return new ExportScmResult( accuRev.getCommandLines(), scmFiles );
         }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/login/AccuRevLoginCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/login/AccuRevLoginCommand.java?rev=980673&r1=980672&r2=980673&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/login/AccuRevLoginCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/login/AccuRevLoginCommand.java Fri Jul 30 08:14:27 2010
@@ -47,26 +47,38 @@ public class AccuRevLoginCommand
                                                CommandParameters parameters )
         throws ScmException, AccuRevException
     {
-        boolean result = true;
+        boolean result = false;
+        AccuRev accurev = repository.getAccuRev();
+        AccuRevInfo info = accurev.info( null );
 
-        if ( repository.getUser() != null )
+        String providerMessage = "";
+        if ( info == null )
         {
-            AccuRev accurev = repository.getAccuRev();
-            // Check if we've already logged in as this user and our token is still valid.
-            AccuRevInfo info = accurev.info( null );
-
-            if ( !repository.getUser().equals( info.getUser() ) )
+            providerMessage = "Unable to retrieve accurev info";
+        }
+        else if ( repository.getUser() != null )
+        {
+            // Check if we've already logged in as this user
+            result = repository.getUser().equals( info.getUser() );
+            if ( result )
+            {
+                providerMessage = "Skipping login - already logged in as " + repository.getUser();
+            }
+            else
             {
                 result = accurev.login( repository.getUser(), repository.getPassword() );
+                providerMessage = ( result ? "Success" : "Failure" ) + " logging in as " + repository.getUser();
             }
-            return new LoginScmResult( accurev.getCommandLines(), null, accurev.getErrorOutput(), result );
         }
         else
         {
-            getLogger().info( "No AccuRev user supplied, assuming logged in externally" );
-            return new LoginScmResult( null, null, null, true );
+            result = info.isLoggedIn();
+            providerMessage = result ? ( "Logged in externally as " + info.getUser() ) : "Not logged in";
         }
 
+        getLogger().debug( providerMessage );
+        return new LoginScmResult( accurev.getCommandLines(), providerMessage, accurev.getErrorOutput(), result );
+
     }
 
     public LoginScmResult login( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/remove/AccuRevRemoveCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/remove/AccuRevRemoveCommand.java?rev=980673&r1=980672&r2=980673&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/remove/AccuRevRemoveCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/remove/AccuRevRemoveCommand.java Fri Jul 30 08:14:27 2010
@@ -19,7 +19,6 @@ package org.apache.maven.scm.provider.ac
  * under the License.
  */
 import java.io.File;
-import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.maven.scm.CommandParameter;
@@ -51,25 +50,21 @@ public class AccuRevRemoveCommand
                                                CommandParameters parameters )
         throws ScmException, AccuRevException
     {
-        final List<File> removedFiles = new ArrayList<File>();
 
         AccuRev accuRev = repository.getAccuRev();
 
         String message = parameters.getString( CommandParameter.MESSAGE, "" );
 
-        boolean success = true;
-
         File basedir = fileSet.getBasedir();
 
-        @SuppressWarnings("unchecked")
+        @SuppressWarnings( "unchecked" )
         List<File> relativeFiles = fileSet.getFileList();
 
-        success = accuRev.defunct( basedir, relativeFiles, message, removedFiles );
-
-        List<ScmFile> resultFiles = getScmFiles( removedFiles, ScmFileStatus.DELETED );
+        final List<File> removedFiles = accuRev.defunct( basedir, relativeFiles, message );
 
-        if ( success )
+        if ( removedFiles != null )
         {
+            List<ScmFile> resultFiles = getScmFiles( removedFiles, ScmFileStatus.DELETED );
             return new RemoveScmResult( accuRev.getCommandLines(), resultFiles );
         }
         else

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/status/AccuRevStatusCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/status/AccuRevStatusCommand.java?rev=980673&r1=980672&r2=980673&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/status/AccuRevStatusCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/status/AccuRevStatusCommand.java Fri Jul 30 08:14:27 2010
@@ -21,7 +21,6 @@ package org.apache.maven.scm.provider.ac
 
 import java.io.File;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.maven.scm.CommandParameters;
@@ -37,6 +36,7 @@ import org.apache.maven.scm.provider.acc
 import org.apache.maven.scm.provider.accurev.AccuRevException;
 import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
 import org.apache.maven.scm.provider.accurev.AccuRevStat;
+import org.apache.maven.scm.provider.accurev.CategorisedElements;
 import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommand;
 
 public class AccuRevStatusCommand
@@ -54,39 +54,69 @@ public class AccuRevStatusCommand
         throws ScmException, AccuRevException
     {
 
-        boolean success = true;
         AccuRev accuRev = repository.getAccuRev();
 
         File basedir = fileSet.getBasedir();
-        @SuppressWarnings("unchecked")
+        @SuppressWarnings( "unchecked" )
         List<File> elements = fileSet.getFileList();
 
-        List<File> defunctElements = new ArrayList<File>();
-        List<File> modOrAddedElements = new ArrayList<File>();
-        List<File> modifiedElements = new ArrayList<File>();
-        List<File> addedElements = new ArrayList<File>();
-        List<File> missingElements = new ArrayList<File>();
-        List<File> externalElements = new ArrayList<File>();
+        List<File> defunctElements = accuRev.stat( basedir, elements, AccuRevStat.DEFUNCT );
 
-        success = success && accuRev.stat( basedir, elements, AccuRevStat.DEFUNCT, defunctElements );
+        if ( defunctElements == null )
+        {
+            return error( accuRev, "Failed retrieving defunct elements" );
+        }
 
-        success = success && accuRev.stat( basedir, elements, AccuRevStat.KEPT, modOrAddedElements );
+        List<File> keptElements = accuRev.stat( basedir, elements, AccuRevStat.KEPT );
 
         // Defunct elements are also listed as kept (AccuRev 4.7.1), exclude those here.
-        Iterator<File> iter = modOrAddedElements.iterator();
-        while ( iter.hasNext() )
+        if ( keptElements == null )
+        {
+            return error( accuRev, "Failed retrieving kept elements" );
+        }
+
+        List<File> modOrAddedElements = new ArrayList<File>();
+
+        for ( File file : keptElements )
         {
-            if ( defunctElements.contains( iter.next() ) )
+            if ( !defunctElements.contains( file ) )
             {
-                iter.remove();
+                modOrAddedElements.add( file );
             }
         }
 
-        success = success && accuRev.stat( basedir, elements, AccuRevStat.MODIFIED, modOrAddedElements );
-        success = success && accuRev.statBackingStream( basedir, modOrAddedElements, modifiedElements, addedElements );
+        List<File> modifiedElements = accuRev.stat( basedir, elements, AccuRevStat.MODIFIED );
+
+        if ( modifiedElements == null )
+        {
+            return error( accuRev, "Failed retrieving modified elements" );
+        }
+
+        modOrAddedElements.addAll( modifiedElements );
+
+        CategorisedElements catElems = accuRev.statBackingStream( basedir, modOrAddedElements );
+
+        if ( catElems == null )
+        {
+            return error( accuRev, "Failed stat backing stream to split modified and added elements" );
+        }
 
-        success = success && accuRev.stat( basedir, elements, AccuRevStat.MISSING, missingElements );
-        success = success && accuRev.stat( basedir, elements, AccuRevStat.EXTERNAL, externalElements );
+        List<File> addedElements = catElems.getNonMemberElements();
+        modifiedElements = catElems.getMemberElements();
+
+        List<File> missingElements = accuRev.stat( basedir, elements, AccuRevStat.MISSING );
+
+        if ( missingElements == null )
+        {
+            return error( accuRev, "Failed retrieving missing elements" );
+        }
+
+        List<File> externalElements = accuRev.stat( basedir, elements, AccuRevStat.EXTERNAL );
+
+        if ( externalElements == null )
+        {
+            return error( accuRev, "Failed retrieving external elements" );
+        }
 
         List<ScmFile> resultFiles = getScmFiles( defunctElements, ScmFileStatus.DELETED );
         resultFiles.addAll( getScmFiles( modifiedElements, ScmFileStatus.MODIFIED ) );
@@ -94,17 +124,15 @@ public class AccuRevStatusCommand
         resultFiles.addAll( getScmFiles( missingElements, ScmFileStatus.MISSING ) );
         resultFiles.addAll( getScmFiles( externalElements, ScmFileStatus.UNKNOWN ) );
 
-        if ( success )
-        {
-            return new StatusScmResult( accuRev.getCommandLines(), resultFiles );
-        }
-        else
-        {
-            return new StatusScmResult( accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false );
-        }
+        return new StatusScmResult( accuRev.getCommandLines(), resultFiles );
 
     }
 
+    private ScmResult error( AccuRev accuRev, String message )
+    {
+        return new StatusScmResult( accuRev.getCommandLines(), "AccuRev " + message, accuRev.getErrorOutput(), false );
+    }
+
     public StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
         throws ScmException
     {

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/tag/AccuRevTagCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/tag/AccuRevTagCommand.java?rev=980673&r1=980672&r2=980673&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/tag/AccuRevTagCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/tag/AccuRevTagCommand.java Fri Jul 30 08:14:27 2010
@@ -20,7 +20,7 @@ package org.apache.maven.scm.provider.ac
  */
 
 import java.io.File;
-import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.maven.scm.CommandParameter;
 import org.apache.maven.scm.CommandParameters;
@@ -52,26 +52,25 @@ public class AccuRevTagCommand
         throws ScmException, AccuRevException
     {
 
-        ArrayList<File> taggedFiles = new ArrayList<File>();
-
         AccuRev accuRev = repository.getAccuRev();
 
-        String tagName = parameters.getString( CommandParameter.TAG_NAME );
+        String snapshotName = parameters.getString( CommandParameter.TAG_NAME );
 
-        tagName = repository.getExtendedTagName( tagName );
+        snapshotName = repository.getSnapshotName( snapshotName );
 
         File basedir = fileSet.getBasedir();
         boolean success = true;
 
         AccuRevInfo info = accuRev.info( basedir );
+        List<File> taggedFiles = null;
 
-        success = accuRev.mksnap( tagName, info.getBasis() );
+        success = accuRev.mksnap( snapshotName, info.getBasis() );
         if ( success )
         {
-            success = accuRev.statTag( tagName, taggedFiles );
+            taggedFiles = accuRev.statTag( snapshotName );
         }
 
-        if ( success )
+        if ( success && taggedFiles != null )
         {
             return new TagScmResult( accuRev.getCommandLines(), getScmFiles( taggedFiles, ScmFileStatus.TAGGED ) );
         }



Mime
View raw message