maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r947469 - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src: main/java/org/apache/maven/scm/provider/accurev/ main/java/org/apache/maven/scm/provider/accurev/cli/ main/java/org/apache/maven/scm/provider/accurev/command/...
Date Sun, 23 May 2010 19:02:24 GMT
Author: olamy
Date: Sun May 23 19:02:24 2010
New Revision: 947469

URL: http://svn.apache.org/viewvc?rev=947469&view=rev
Log:
[SCM-544] Add blame command to AccuRev provider
Submitted by Grant Gardner 

Added:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AnnotateConsumer.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/cli/AnnotateConsumerTest.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTckTest.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTest.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/annotate.txt
  (with props)
Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRev.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProvider.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLine.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameConsumer.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/site/apt/index.apt
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLineTest.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/blame/AccuRevBlameConsumerTest.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/accurev/annotatelog.txt

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRev.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/AccuRev.java?rev=947469&r1=947468&r2=947469&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRev.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRev.java
Sun May 23 19:02:24 2010
@@ -25,6 +25,8 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.maven.scm.command.blame.BlameLine;
+
 /**
  * Represents the AccuRev CLI interface
  * 
@@ -33,6 +35,8 @@ import java.util.Map;
 public interface AccuRev
 {
 
+    public static final String ACCUREV_TIME_FORMAT_STRING = "yyyy/MM/dd HH:mm:ss";
+
     public static final SimpleDateFormat ACCUREV_TIME_SPEC = new SimpleDateFormat( "yyyy/MM/dd
HH:mm:ss" );
 
     public static final String DEFAULT_REMOVE_MESSAGE = "removed (maven-scm)";
@@ -232,6 +236,17 @@ public interface AccuRev
         throws AccuRevException;
 
     /**
+     * AccuRev annotate an element
+     * 
+     * @param file
+     * @param lines - array which will be filled with annotated lines for the associated
file
+     * @return
+     * @throws AccuRevException
+     */
+    boolean annotate( File baseDir, File file, List<BlameLine> lines )
+        throws AccuRevException;
+    
+    /**
      * Logins in as the given user, retains authtoken for use with subsequent commands.
      * 
      * @param user

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProvider.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/AccuRevScmProvider.java?rev=947469&r1=947468&r2=947469&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProvider.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProvider.java
Sun May 23 19:02:24 2010
@@ -347,12 +347,12 @@ public class AccuRevScmProvider
     }
 
     /** {@inheritDoc} */
+    @Override
     protected BlameScmResult blame( ScmProviderRepository repository, ScmFileSet fileSet,
CommandParameters parameters )
         throws ScmException
     {
-        AccuRevScmProviderRepository accuRevRepository = (AccuRevScmProviderRepository) repository;
-        AccuRevBlameCommand blameCommand = new AccuRevBlameCommand( accuRevRepository.getAccuRev().getExecutable()
);
-        blameCommand.setLogger( getLogger() );
-        return (BlameScmResult) blameCommand.execute( repository, fileSet, parameters );
+
+        AccuRevBlameCommand blameCommand = new AccuRevBlameCommand( getLogger() );
+        return blameCommand.blame( repository, fileSet, parameters );
     }
 }

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=947469&r1=947468&r2=947469&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
Sun May 23 19:02:24 2010
@@ -29,6 +29,7 @@ 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;
@@ -585,6 +586,16 @@ public class AccuRevCommandLine
 
     }
 
+    public boolean annotate( File basedir, File file, List<BlameLine> lines )
+        throws AccuRevException
+    {
+
+        String[] annotate = { "annotate", "-ftud" };
+        AnnotateConsumer stdout = new AnnotateConsumer( lines, getLogger() );
+
+        return executeCommandLine( basedir, annotate, Collections.singletonList( file ),
stdout );
+    }
+    
     public boolean showRefTrees( Map<String, WorkSpace> workSpaces )
         throws AccuRevException
     {

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AnnotateConsumer.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/AnnotateConsumer.java?rev=947469&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AnnotateConsumer.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AnnotateConsumer.java
Sun May 23 19:02:24 2010
@@ -0,0 +1,78 @@
+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.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.maven.scm.command.blame.BlameLine;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.accurev.AccuRev;
+import org.apache.maven.scm.util.AbstractConsumer;
+
+/**
+ * @author Evgeny Mandrikov
+ * @author Grant Gardner
+ * @since 1.4
+ */
+public class AnnotateConsumer
+    extends AbstractConsumer
+{
+
+    /* 3 godin 2009/11/18 16:26:33 */
+    private static final Pattern LINE_PATTERN = Pattern.compile( "^\\s+(\\d+)\\s+(\\w+)\\s+([0-9/]+
[0-9:]+).*" );
+
+    private List<BlameLine> lines;
+
+    public AnnotateConsumer( List<BlameLine> lines, ScmLogger scmLogger )
+    {
+
+        super( scmLogger );
+        this.lines = lines;
+    }
+
+    public void consumeLine( String line )
+    {
+
+        final Matcher matcher = LINE_PATTERN.matcher( line );
+        if ( matcher.matches() )
+        {
+            String revision = matcher.group( 1 ).trim();
+            String author = matcher.group( 2 ).trim();
+            String dateStr = matcher.group( 3 ).trim();
+
+            Date date = parseDate( dateStr, null, AccuRev.ACCUREV_TIME_FORMAT_STRING );
+
+            lines.add( new BlameLine( date, revision, author ) );
+        }
+        else
+        {
+            throw new RuntimeException( "Unable to parse annotation from line: " + line );
+        }
+    }
+
+    public List<BlameLine> getLines()
+    {
+
+        return lines;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AnnotateConsumer.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/AnnotateConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AnnotateConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=947469&r1=947468&r2=947469&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
Sun May 23 19:02:24 2010
@@ -19,65 +19,66 @@ 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;
+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.AbstractBlameCommand;
 import org.apache.maven.scm.command.blame.BlameScmResult;
+import org.apache.maven.scm.log.ScmLogger;
 import org.apache.maven.scm.provider.ScmProviderRepository;
-import org.codehaus.plexus.util.cli.CommandLineException;
-import org.codehaus.plexus.util.cli.CommandLineUtils;
-import org.codehaus.plexus.util.cli.Commandline;
-
-import java.io.File;
+import org.apache.maven.scm.provider.accurev.AccuRev;
+import org.apache.maven.scm.provider.accurev.AccuRevException;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommand;
 
 /**
  * @author Evgeny Mandrikov
+ * @author Grant Gardner
  * @since 1.4
  */
 public class AccuRevBlameCommand
-    extends AbstractBlameCommand
+    extends AbstractAccuRevCommand
 {
-    private final String accurevExecutable;
 
-    public AccuRevBlameCommand( String accurevExec )
+    public AccuRevBlameCommand( ScmLogger logger )
     {
-        accurevExecutable = accurevExec;
+
+        super( logger );
     }
 
-    public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory,
String filename )
-        throws ScmException
+    @SuppressWarnings( "unchecked" )
+    @Override
+    protected BlameScmResult executeAccurevCommand( AccuRevScmProviderRepository repository,
ScmFileSet fileSet,
+                                                    CommandParameters parameters )
+        throws ScmException, AccuRevException
     {
-        Commandline cl = createCommandLine( accurevExecutable, workingDirectory.getBasedir(),
filename );
 
-        AccuRevBlameConsumer consumer = new AccuRevBlameConsumer( getLogger() );
+        AccuRev accuRev = repository.getAccuRev();
+        List/* <BlameLine> */lines = new ArrayList();
 
-        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
+        File file = new File( parameters.getString( CommandParameter.FILE ) );
 
-        int exitCode;
+        boolean success = accuRev.annotate( fileSet.getBasedir(), file, lines );
 
-        try
-        {
-            exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
-        }
-        catch ( CommandLineException ex )
+        if ( success )
         {
-            throw new ScmException( "Error while executing command.", ex );
+            return new BlameScmResult( accuRev.getCommandLines(), lines );
         }
-        if ( exitCode != 0 )
+        else
         {
-            return new BlameScmResult( cl.toString(), "The accurev command failed.", stderr.getOutput(),
false );
+            return new BlameScmResult( accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(),
false );
         }
 
-        return new BlameScmResult( cl.toString(), consumer.getLines() );
     }
 
-    public static Commandline createCommandLine( String accurevExecutable, File workingDirectory,
String filename )
+    public BlameScmResult blame( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters
parameters )
+        throws ScmException
     {
-        Commandline cl = new Commandline();
-        cl.setExecutable( accurevExecutable );
-        cl.setWorkingDirectory( workingDirectory );
-        cl.createArg().setValue( "annotate" );
-        cl.createArg().setValue( filename );
-        return cl;
+
+        return (BlameScmResult) execute( repository, fileSet, parameters );
     }
 }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameConsumer.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/AccuRevBlameConsumer.java?rev=947469&r1=947468&r2=947469&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameConsumer.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameConsumer.java
Sun May 23 19:02:24 2010
@@ -1,79 +0,0 @@
-package org.apache.maven.scm.provider.accurev.command.blame;
-
-/*
- * 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 org.apache.maven.scm.command.blame.BlameLine;
-import org.apache.maven.scm.log.ScmLogger;
-import org.apache.maven.scm.util.AbstractConsumer;
-import org.apache.regexp.RE;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author Evgeny Mandrikov
- * @since 1.4
- */
-public class AccuRevBlameConsumer
-    extends AbstractConsumer
-{
-    private static final String ACCUREV_TIMESTAMP_PATTERN = "yyyy/MM/dd HH:mm:ss";
-
-    /* 3 godin 2009/11/18 16:26:33 */
-    private static final String LINE_PATTERN = "\\s+(\\d+)\\s+(\\w+)\\s+([^ ]+ [^ ]+)";
-
-    /**
-     * @see #LINE_PATTERN
-     */
-    private RE lineRegexp;
-
-    private List lines = new ArrayList();
-
-    public AccuRevBlameConsumer( ScmLogger logger )
-    {
-        super( logger );
-        lineRegexp = new RE( LINE_PATTERN );
-    }
-
-    public void consumeLine( String line )
-    {
-        if ( lineRegexp.match( line ) )
-        {
-            String revision = lineRegexp.getParen( 1 ).trim();
-            String author = lineRegexp.getParen( 2 ).trim();
-            String dateStr = lineRegexp.getParen( 3 ).trim();
-
-            if ( getLogger().isDebugEnabled() )
-            {
-                getLogger().debug( author + " " + dateStr );
-            }
-
-            Date date = parseDate( dateStr, null, ACCUREV_TIMESTAMP_PATTERN );
-
-            lines.add( new BlameLine( date, revision, author ) );
-        }
-    }
-
-    public List getLines()
-    {
-        return lines;
-    }
-}

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/site/apt/index.apt?rev=947469&r1=947468&r2=947469&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/site/apt/index.apt
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/site/apt/index.apt
Sun May 23 19:02:24 2010
@@ -1,4 +1,4 @@
---------------
+ --------------
  Maven SCM AccuRev provider
  --------------
  Grant Gardner
@@ -187,13 +187,15 @@ SCM Commands  
 
   List the changes promoted into a stream between timestamps. 
   
-  <<<accurev hist -s <stream> -t T1-T2>>>>
+  <<<accurev hist -s <stream> -t T1-T2>>>
   
   <<NOTE>> This will not pickup changes promoted into a parent stream
   
   <<TODO>> Filter results based on supplied fileSet.
   
-  <<TODO>> Filter results based on URL's project path.       
+  <<TODO>> Filter results based on URL's project path.
+  
+  <<TODO>> Use diff -v <stream> -V <stream> -t T1-T2 to get files
that have changed upstream      
 
 * Diff
   
@@ -210,7 +212,7 @@ SCM Commands  
   If no versions specified and stream is in URL, then compare workspace to that stream
   * <<< accurev diff -v <urlStream> >>>
   
-  If no versions specified and no strema in URL, then compare workspace to basis stream
+  If no versions specified and no stream in URL, then compare workspace to basis stream
   * <<< accurev diff -b >>>
 
   
@@ -218,6 +220,14 @@ SCM Commands  
 
   <<<accurev defunct>>> the elements specified in the fileset, or the whole
basedir
   
+* Blame
+
+  <<<accurev annotate>>> the specified file
+  
+  file must be in a workspace/reftree
+  
+  <<TODO>> Question why blame uses CommandParameter.FILE instead of just the
fileset, also why not blame on a version?
+  
 * Branch
 
   Not implemented.
@@ -228,4 +238,4 @@ SCM Commands  
 Troubleshooting
  
   Generally to get yourself out of trouble you'll need to manipulate AccuRev externally by
moving workspaces around
-  bumping versions, reparenting streams.  
\ No newline at end of file
+  bumping versions, reparenting streams.  

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLineTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLineTest.java?rev=947469&r1=947468&r2=947469&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLineTest.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLineTest.java
Sun May 23 19:02:24 2010
@@ -35,6 +35,7 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.command.blame.BlameLine;
 import org.apache.maven.scm.log.ScmLogger;
 import org.apache.maven.scm.provider.accurev.AccuRev;
 import org.apache.maven.scm.provider.accurev.AccuRevStat;
@@ -530,4 +531,20 @@ public class AccuRevCommandLineTest
 
     }
 
+    @Test
+    public void testAnnotate()
+        throws Exception
+    {
+
+        File basedir = new File( "/my/workspace" );
+        File file = new File( "src/main/java/foo.java" );
+
+        AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+        accuRevCL.annotate( basedir, file, new ArrayList<BlameLine>() );
+
+        Commandline lastCL = accuRevCL.getCommandline();
+        assertThat( lastCL.getWorkingDirectory(), is( basedir.getCanonicalFile() ) );
+        assertThat( lastCL.getArguments(), is( new String[] { "annotate", "-ftud", file.getPath()
} ) );
+
+    }
 }

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/cli/AnnotateConsumerTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/cli/AnnotateConsumerTest.java?rev=947469&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/cli/AnnotateConsumerTest.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/cli/AnnotateConsumerTest.java
Sun May 23 19:02:24 2010
@@ -0,0 +1,66 @@
+
+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 static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.command.blame.BlameLine;
+import org.apache.maven.scm.log.DefaultLog;
+import org.apache.maven.scm.provider.accurev.AccuRev;
+import org.junit.Test;
+
+/**
+ * @author Evgeny Mandrikov
+ * @author Grant Gardner
+ */
+public class AnnotateConsumerTest extends ScmTestCase {
+
+    @Test
+    public void testParse() throws Exception {
+
+        List<BlameLine> consumedLines = new ArrayList<BlameLine>();
+
+        AnnotateConsumer consumer = new AnnotateConsumer(consumedLines, new DefaultLog());
+
+        AccuRevJUnitUtil.consume("/annotate.txt", consumer);
+
+        Assert.assertEquals(12, consumer.getLines().size());
+
+        BlameLine line1 = (BlameLine) consumer.getLines().get(0);
+        Assert.assertEquals("2", line1.getRevision());
+        Assert.assertEquals("godin", line1.getAuthor());
+        assertThat(line1.getDate(), is(AccuRev.ACCUREV_TIME_SPEC.parse("2008/10/26 16:26:44")));
+
+        BlameLine line12 = (BlameLine) consumer.getLines().get(11);
+        Assert.assertEquals("1", line12.getRevision());
+        Assert.assertEquals("godin", line12.getAuthor());
+        assertThat(line12.getDate(), is(AccuRev.ACCUREV_TIME_SPEC.parse("2008/10/17 11:41:50")));
+
+    }
+
+}

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

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

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/cli/AnnotateConsumerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTckTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTckTest.java?rev=947469&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTckTest.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTckTest.java
Sun May 23 19:02:24 2010
@@ -0,0 +1,132 @@
+package org.apache.maven.scm.provider.accurev.command.blame;
+
+/*
+ * 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 static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.InputStream;
+
+import org.apache.maven.scm.command.blame.BlameScmResult;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.cli.AccuRevJUnitUtil;
+import org.apache.maven.scm.provider.accurev.command.AccuRevTckUtil;
+import org.apache.maven.scm.tck.command.blame.BlameCommandTckTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith( JUnit4.class )
+public class AccuRevBlameCommandTckTest
+    extends BlameCommandTckTest
+{
+
+    private AccuRevTckUtil accurevTckTestUtil = new AccuRevTckUtil();
+
+    @Override
+    protected InputStream getCustomConfiguration()
+        throws Exception
+
+    {
+
+        return AccuRevJUnitUtil.getPlexusConfiguration();
+    }
+
+    @Override
+    @Test
+    public void testBlameCommand()
+        throws Exception
+    {
+
+        super.testBlameCommand();
+    }
+
+    @Override
+    protected void verifyResult( BlameScmResult result )
+    {
+
+        assertThat( result, is( not( nullValue() ) ) );
+        assertThat( result.getLines().size(), is( 1 ) );
+
+    }
+
+    @Override
+    @Before
+    public void setUp()
+        throws Exception
+    {
+
+        super.setUp();
+    }
+
+    @Override
+    protected File getWorkingCopy()
+    {
+
+        return accurevTckTestUtil.getWorkingCopy();
+    }
+
+    @Override
+    protected File getAssertionCopy()
+    {
+
+        return accurevTckTestUtil.getAssertionCopy();
+    }
+
+    @Override
+    public String getScmUrl()
+        throws Exception
+    {
+
+        return accurevTckTestUtil.getScmUrl();
+    }
+
+    @Override
+    public void initRepo()
+        throws Exception
+    {
+
+        accurevTckTestUtil.initRepo( getContainer() );
+        System.setProperty( AccuRevScmProviderRepository.TAG_PREFIX, accurevTckTestUtil.getDepotName()
+ "_" );
+    }
+
+    @Override
+    @After
+    public void tearDown()
+        throws Exception
+    {
+
+        try
+        {
+            accurevTckTestUtil.tearDown();
+            accurevTckTestUtil.removeWorkSpace( getWorkingCopy() );
+            accurevTckTestUtil.removeWorkSpace( getAssertionCopy() );
+
+        }
+        finally
+        {
+            System.clearProperty( AccuRevScmProviderRepository.TAG_PREFIX );
+            super.tearDown();
+        }
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTckTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTckTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTckTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTest.java?rev=947469&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTest.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTest.java
Sun May 23 19:02:24 2010
@@ -0,0 +1,85 @@
+package org.apache.maven.scm.provider.accurev.command.blame;
+
+/*
+ * 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 static org.apache.maven.scm.provider.accurev.AddElementsAction.*;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.maven.scm.CommandParameter;
+import org.apache.maven.scm.CommandParameters;
+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.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest;
+import org.jmock.Expectations;
+import org.junit.Test;
+
+public class AccuRevBlameCommandTest
+    extends AbstractAccuRevCommandTest
+{
+
+    @SuppressWarnings( "unchecked" )
+    @Test
+    public void testBlame()
+        throws Exception
+    {
+
+        final File file = new File( "src/main/java/Foo.java" );
+        final ScmFileSet testFileSet = new ScmFileSet( basedir, file );
+
+        final Date date = new Date();
+        final BlameLine blameLine = new BlameLine( date, "12", "theAuthor" );
+
+        context.checking( new Expectations()
+        {
+
+            {
+                one( accurev ).annotate( with( basedir ), with( file ), with( any( List.class
) ) );
+                will( doAll( addElementsTo( 2, blameLine ), returnValue( true ) ) );
+                inSequence( sequence );
+
+            }
+        } );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        AccuRevBlameCommand command = new AccuRevBlameCommand( getLogger() );
+
+        CommandParameters commandParameters = new CommandParameters();
+        commandParameters.setString( CommandParameter.FILE, file.getPath() );
+        BlameScmResult result = command.blame( repo, testFileSet, commandParameters );
+
+        context.assertIsSatisfied();
+
+        assertThat( result.isSuccess(), is( true ) );
+        assertThat( result.getLines().size(), is( 1 ) );
+        assertThat( ( (BlameLine) result.getLines().get( 0 ) ), is( blameLine ) );
+
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommandTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/blame/AccuRevBlameConsumerTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/blame/AccuRevBlameConsumerTest.java?rev=947469&r1=947468&r2=947469&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/blame/AccuRevBlameConsumerTest.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/blame/AccuRevBlameConsumerTest.java
Sun May 23 19:02:24 2010
@@ -1,67 +0,0 @@
-package org.apache.maven.scm.provider.accurev.commands.blame;
-
-/*
- * 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.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-
-import junit.framework.Assert;
-
-import org.apache.maven.scm.ScmTestCase;
-import org.apache.maven.scm.command.blame.BlameLine;
-import org.apache.maven.scm.log.DefaultLog;
-import org.apache.maven.scm.provider.accurev.command.blame.AccuRevBlameConsumer;
-
-/**
- * @author Evgeny Mandrikov
- */
-public class AccuRevBlameConsumerTest
-    extends ScmTestCase
-{
-
-    public void testParse()
-        throws Exception
-    {
-        File testFile = getTestFile("src/test/resources/accurev/annotatelog.txt");
-
-        AccuRevBlameConsumer consumer = new AccuRevBlameConsumer(new DefaultLog());
-
-        FileInputStream fis = new FileInputStream(testFile);
-        BufferedReader in = new BufferedReader(new InputStreamReader(fis));
-        String s = in.readLine();
-        while (s != null) {
-            consumer.consumeLine(s);
-            s = in.readLine();
-        }
-
-        Assert.assertEquals(12, consumer.getLines().size());
-
-        BlameLine line1 = (BlameLine) consumer.getLines().get(0);
-        Assert.assertEquals("2", line1.getRevision());
-        Assert.assertEquals("godin", line1.getAuthor());
-
-        BlameLine line12 = (BlameLine) consumer.getLines().get(11);
-        Assert.assertEquals("1", line12.getRevision());
-        Assert.assertEquals("godin", line12.getAuthor());
-    }
-
-}

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/accurev/annotatelog.txt
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/accurev/annotatelog.txt?rev=947469&r1=947468&r2=947469&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/accurev/annotatelog.txt
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/accurev/annotatelog.txt
Sun May 23 19:02:24 2010
@@ -1,12 +0,0 @@
-       2 godin           2008/10/26 16:26:44   <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       2 godin           2008/10/26 16:26:44            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
-       2 godin           2008/10/26 16:26:44       <modelVersion>4.0.0</modelVersion>
-       3 godin           2009/11/18 16:26:33
-       3 godin           2009/11/18 16:26:33       <distributionManagement>
-       3 godin           2009/11/18 16:26:33           <repository>
-       3 godin           2009/11/18 16:26:33               <id>localhost</id>
-       3 godin           2009/11/18 16:26:33               <name>dumping to target</name>
-       3 godin           2009/11/18 16:26:33               <url>file://${basedir}/target/repo/</url>
-       3 godin           2009/11/18 16:26:33           </repository>
-       3 godin           2009/11/18 16:26:33       </distributionManagement>
-       1 godin           2008/10/17 11:41:50   </project>

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/annotate.txt
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/annotate.txt?rev=947469&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/annotate.txt
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/annotate.txt
Sun May 23 19:02:24 2010
@@ -0,0 +1,12 @@
+       2 godin           2008/10/26 16:26:44   <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       2 godin           2008/10/26 16:26:44            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+       2 godin           2008/10/26 16:26:44       <modelVersion>4.0.0</modelVersion>
+       3 godin           2009/11/18 16:26:33
+       3 godin           2009/11/18 16:26:33       <distributionManagement>
+       3 godin           2009/11/18 16:26:33           <repository>
+       3 godin           2009/11/18 16:26:33               <id>localhost</id>
+       3 godin           2009/11/18 16:26:33               <name>dumping to target</name>
+       3 godin           2009/11/18 16:26:33               <url>file://${basedir}/target/repo/</url>
+       3 godin           2009/11/18 16:26:33           </repository>
+       3 godin           2009/11/18 16:26:33       </distributionManagement>
+       1 godin           2008/10/17 11:41:50   </project>

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/annotate.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/annotate.txt
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/annotate.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message