maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r942226 - 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/accur...
Date Fri, 07 May 2010 21:08:51 GMT
Author: olamy
Date: Fri May  7 21:08:50 2010
New Revision: 942226

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

Added:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommand.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameConsumer.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/blame/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/blame/AccuRevBlameConsumerTest.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/accurev/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/accurev/annotatelog.txt
  (with props)
Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/pom.xml
    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

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/pom.xml
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/pom.xml?rev=942226&r1=942225&r2=942226&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/pom.xml (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/pom.xml Fri May  7 21:08:50
2010
@@ -38,6 +38,10 @@
       <artifactId>maven-scm-test</artifactId>
     </dependency>
     <dependency>
+      <groupId>regexp</groupId>
+      <artifactId>regexp</artifactId>
+    </dependency>    
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>4.5</version>

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=942226&r1=942225&r2=942226&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
Fri May  7 21:08:50 2010
@@ -247,5 +247,7 @@ public interface AccuRev
 
     boolean showRefTrees( Map<String, WorkSpace> workSpaces )
         throws AccuRevException;
+    
+    String getExecutable();
 
 }
\ 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/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=942226&r1=942225&r2=942226&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
Fri May  7 21:08:50 2010
@@ -33,6 +33,7 @@ import org.apache.maven.scm.ScmFile;
 import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.ScmRevision;
 import org.apache.maven.scm.command.add.AddScmResult;
+import org.apache.maven.scm.command.blame.BlameScmResult;
 import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
 import org.apache.maven.scm.command.checkin.CheckInScmResult;
 import org.apache.maven.scm.command.checkout.CheckOutScmResult;
@@ -46,6 +47,7 @@ import org.apache.maven.scm.provider.Abs
 import org.apache.maven.scm.provider.ScmProviderRepository;
 import org.apache.maven.scm.provider.accurev.cli.AccuRevCommandLine;
 import org.apache.maven.scm.provider.accurev.command.add.AccuRevAddCommand;
+import org.apache.maven.scm.provider.accurev.command.blame.AccuRevBlameCommand;
 import org.apache.maven.scm.provider.accurev.command.changelog.AccuRevChangeLogCommand;
 import org.apache.maven.scm.provider.accurev.command.checkin.AccuRevCheckInCommand;
 import org.apache.maven.scm.provider.accurev.command.checkout.AccuRevCheckOutCommand;
@@ -343,4 +345,14 @@ public class AccuRevScmProvider
         AccuRevRemoveCommand command = new AccuRevRemoveCommand( getLogger() );
         return command.remove( repository, fileSet, parameters );
     }
+    
+    /** {@inheritDoc} */
+    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 );
+    }
 }

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=942226&r1=942225&r2=942226&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 May  7 21:08:50 2010
@@ -645,4 +645,9 @@ public class AccuRevCommandLine
         System.out.println( Arrays.toString( myCL.authArgs ) );
 
     }
+
+    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/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=942226&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommand.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommand.java
Fri May  7 21:08:50 2010
@@ -0,0 +1,83 @@
+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.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.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;
+
+/**
+ * @author Evgeny Mandrikov
+ * @since 1.4
+ */
+public class AccuRevBlameCommand
+    extends AbstractBlameCommand
+{
+    private final String accurevExecutable;
+
+    public AccuRevBlameCommand( String accurevExec )
+    {
+        accurevExecutable = accurevExec;
+    }
+
+    public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory,
String filename )
+        throws ScmException
+    {
+        Commandline cl = createCommandLine( accurevExecutable, workingDirectory.getBasedir(),
filename );
+
+        AccuRevBlameConsumer consumer = new AccuRevBlameConsumer( getLogger() );
+
+        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
+
+        int exitCode;
+
+        try
+        {
+            exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
+        }
+        catch ( CommandLineException ex )
+        {
+            throw new ScmException( "Error while executing command.", ex );
+        }
+        if ( exitCode != 0 )
+        {
+            return new BlameScmResult( cl.toString(), "The accurev command failed.", stderr.getOutput(),
false );
+        }
+
+        return new BlameScmResult( cl.toString(), consumer.getLines() );
+    }
+
+    public static Commandline createCommandLine( String accurevExecutable, File workingDirectory,
String filename )
+    {
+        Commandline cl = new Commandline();
+        cl.setExecutable( accurevExecutable );
+        cl.setWorkingDirectory( workingDirectory );
+        cl.createArg().setValue( "annotate" );
+        cl.createArg().setValue( filename );
+        return cl;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameCommand.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/command/blame/AccuRevBlameCommand.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/command/blame/AccuRevBlameCommand.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=942226&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameConsumer.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameConsumer.java
Fri May  7 21:08:50 2010
@@ -0,0 +1,79 @@
+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;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/command/blame/AccuRevBlameConsumer.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/command/blame/AccuRevBlameConsumer.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/command/blame/AccuRevBlameConsumer.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/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=942226&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/blame/AccuRevBlameConsumerTest.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/blame/AccuRevBlameConsumerTest.java
Fri May  7 21:08:50 2010
@@ -0,0 +1,67 @@
+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());
+    }
+
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/blame/AccuRevBlameConsumerTest.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/commands/blame/AccuRevBlameConsumerTest.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/commands/blame/AccuRevBlameConsumerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=942226&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/accurev/annotatelog.txt
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/test/resources/accurev/annotatelog.txt
Fri May  7 21:08:50 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/accurev/annotatelog.txt
------------------------------------------------------------------------------
    svn:eol-style = native

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

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



Mime
View raw message