maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r527432 - in /maven/scm/trunk: maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvs-commons/src/main/java/org/apache/maven/scm/provider/cvslib/command/changel...
Date Wed, 11 Apr 2007 09:35:25 GMT
Author: evenisse
Date: Wed Apr 11 02:35:23 2007
New Revision: 527432

URL: http://svn.apache.org/viewvc?view=rev&rev=527432
Log:
[SCM-294] Merge CVS changelogs if they are equals

Modified:
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogSet.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvs-commons/src/main/java/org/apache/maven/scm/provider/cvslib/command/changelog/AbstractCvsChangeLogCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvs-commons/src/main/java/org/apache/maven/scm/provider/cvslib/command/changelog/CvsChangeLogConsumer.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvsexe/src/main/java/org/apache/maven/scm/provider/cvslib/cvsexe/command/changelog/CvsExeChangeLogCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvsjava/src/main/java/org/apache/maven/scm/provider/cvslib/cvsjava/command/changelog/CvsJavaChangeLogCommand.java

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogSet.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogSet.java?view=diff&rev=527432&r1=527431&r2=527432
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogSet.java
(original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogSet.java
Wed Apr 11 02:35:23 2007
@@ -20,6 +20,7 @@
  */
 
 import org.apache.maven.scm.ChangeSet;
+import org.apache.maven.scm.ScmVersion;
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -40,6 +41,10 @@
 
     private Date endDate;
 
+    private ScmVersion startVersion;
+
+    private ScmVersion endVersion;
+
     /**
      * Initializes a new instance of this class.
      *
@@ -86,6 +91,36 @@
     }
 
     /**
+     * Returns the start version (revision/branch/label) for this set.
+     *
+     * @return the start version (revision/branch/label) for this set, or <code>null</code>.
+     */
+    public ScmVersion getStartVersion()
+    {
+        return startVersion;
+    }
+
+    public void setStartVersion( ScmVersion startVersion )
+    {
+        this.startVersion = startVersion;
+    }
+
+    /**
+     * Returns the end version (revision/branch/label) for this set.
+     *
+     * @return the end version (revision/branch/label) for this set, or <code>null</code>.
+     */
+    public ScmVersion getEndVersion()
+    {
+        return endVersion;
+    }
+
+    public void setEndVersion( ScmVersion endVersion )
+    {
+        this.endVersion = endVersion;
+    }
+
+    /**
      * Returns the collection of changeSet.
      *
      * @return the collection of {@link org.apache.maven.scm.ChangeSet} objects for this
set.
@@ -139,6 +174,19 @@
         {
             buffer.append( " end=\"" )
                 .append( formatter.format( getEndDate() ) )
+                .append( "\"" );
+        }
+
+        if ( startVersion != null )
+        {
+            buffer.append( " startVersion=\"" )
+                .append( getStartVersion() )
+                .append( "\"" );
+        }
+        if ( endVersion != null )
+        {
+            buffer.append( " endVersion=\"" )
+                .append( getEndVersion() )
                 .append( "\"" );
         }
 

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvs-commons/src/main/java/org/apache/maven/scm/provider/cvslib/command/changelog/AbstractCvsChangeLogCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvs-commons/src/main/java/org/apache/maven/scm/provider/cvslib/command/changelog/AbstractCvsChangeLogCommand.java?view=diff&rev=527432&r1=527431&r2=527432
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvs-commons/src/main/java/org/apache/maven/scm/provider/cvslib/command/changelog/AbstractCvsChangeLogCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvs-commons/src/main/java/org/apache/maven/scm/provider/cvslib/command/changelog/AbstractCvsChangeLogCommand.java
Wed Apr 11 02:35:23 2007
@@ -106,10 +106,11 @@
         getLogger().info( "Executing: " + cl );
         getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath()
);
 
-        return executeCvsCommand( cl, startDate, endDate, datePattern );
+        return executeCvsCommand( cl, startDate, endDate, startVersion, endVersion, datePattern
);
     }
 
     protected abstract ChangeLogScmResult executeCvsCommand( Commandline cl, Date startDate,
Date endDate,
+                                                             ScmVersion startVersion, ScmVersion
endVersion,
                                                              String datePattern )
         throws ScmException;
 

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvs-commons/src/main/java/org/apache/maven/scm/provider/cvslib/command/changelog/CvsChangeLogConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvs-commons/src/main/java/org/apache/maven/scm/provider/cvslib/command/changelog/CvsChangeLogConsumer.java?view=diff&rev=527432&r1=527431&r2=527432
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvs-commons/src/main/java/org/apache/maven/scm/provider/cvslib/command/changelog/CvsChangeLogConsumer.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvs-commons/src/main/java/org/apache/maven/scm/provider/cvslib/command/changelog/CvsChangeLogConsumer.java
Wed Apr 11 02:35:23 2007
@@ -25,6 +25,9 @@
 import org.apache.maven.scm.util.AbstractConsumer;
 
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
 
@@ -112,7 +115,49 @@
 
     public List getModifications()
     {
-        return entries;
+        Collections.sort( entries, new Comparator()
+        {
+            public int compare( Object entry1, Object entry2 )
+            {
+                ChangeSet set1 = (ChangeSet) entry1;
+                ChangeSet set2 = (ChangeSet) entry2;
+                return set1.getDate().compareTo( set2.getDate() );
+            }
+        } );
+        List fixedModifications = new ArrayList();
+        ChangeSet currentEntry = null;
+        for ( Iterator entryIterator = entries.iterator(); entryIterator.hasNext(); )
+        {
+            ChangeSet entry = (ChangeSet) entryIterator.next();
+            if ( currentEntry == null )
+            {
+                currentEntry = entry;
+            }
+            else if ( areEqual( currentEntry, entry ) )
+            {
+                currentEntry.addFile( (ChangeFile) entry.getFiles().get( 0 ) );
+            }
+            else
+            {
+                fixedModifications.add( currentEntry );
+                currentEntry = entry;
+            }
+        }
+        if ( currentEntry != null )
+        {
+            fixedModifications.add( currentEntry );
+        }
+        return fixedModifications;
+    }
+
+    private boolean areEqual( ChangeSet set1, ChangeSet set2 )
+    {
+        if ( set1.getAuthor().equals( set2.getAuthor() ) && set1.getComment().equals(
set2.getComment() ) &&
+            set1.getDate().equals( set2.getDate() ) )
+        {
+            return true;
+        }
+        return false;
     }
 
     public void consumeLine( String line )

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvsexe/src/main/java/org/apache/maven/scm/provider/cvslib/cvsexe/command/changelog/CvsExeChangeLogCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvsexe/src/main/java/org/apache/maven/scm/provider/cvslib/cvsexe/command/changelog/CvsExeChangeLogCommand.java?view=diff&rev=527432&r1=527431&r2=527432
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvsexe/src/main/java/org/apache/maven/scm/provider/cvslib/cvsexe/command/changelog/CvsExeChangeLogCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvsexe/src/main/java/org/apache/maven/scm/provider/cvslib/cvsexe/command/changelog/CvsExeChangeLogCommand.java
Wed Apr 11 02:35:23 2007
@@ -20,6 +20,7 @@
  */
 
 import org.apache.maven.scm.ScmException;
+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.provider.cvslib.command.changelog.AbstractCvsChangeLogCommand;
@@ -37,7 +38,8 @@
 public class CvsExeChangeLogCommand
     extends AbstractCvsChangeLogCommand
 {
-    protected ChangeLogScmResult executeCvsCommand( Commandline cl, Date startDate, Date
endDate, String datePattern )
+    protected ChangeLogScmResult executeCvsCommand( Commandline cl, Date startDate, Date
endDate, String datePattern,
+                                                    ScmVersion startVersion, ScmVersion endVersion
)
         throws ScmException
     {
         CvsChangeLogConsumer consumer = new CvsChangeLogConsumer( getLogger(), datePattern
);
@@ -60,7 +62,10 @@
             return new ChangeLogScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(),
false );
         }
 
-        return new ChangeLogScmResult( cl.toString(),
-                                       new ChangeLogSet( consumer.getModifications(), startDate,
endDate ) );
+        ChangeLogSet changeLogSet = new ChangeLogSet( consumer.getModifications(), startDate,
endDate );
+        changeLogSet.setStartVersion( startVersion );
+        changeLogSet.setEndVersion( endVersion );
+
+        return new ChangeLogScmResult( cl.toString(), changeLogSet );
     }
 }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvsjava/src/main/java/org/apache/maven/scm/provider/cvslib/cvsjava/command/changelog/CvsJavaChangeLogCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvsjava/src/main/java/org/apache/maven/scm/provider/cvslib/cvsjava/command/changelog/CvsJavaChangeLogCommand.java?view=diff&rev=527432&r1=527431&r2=527432
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvsjava/src/main/java/org/apache/maven/scm/provider/cvslib/cvsjava/command/changelog/CvsJavaChangeLogCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvsjava/src/main/java/org/apache/maven/scm/provider/cvslib/cvsjava/command/changelog/CvsJavaChangeLogCommand.java
Wed Apr 11 02:35:23 2007
@@ -20,6 +20,7 @@
  */
 
 import org.apache.maven.scm.ScmException;
+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.provider.cvslib.command.changelog.AbstractCvsChangeLogCommand;
@@ -40,7 +41,8 @@
 public class CvsJavaChangeLogCommand
     extends AbstractCvsChangeLogCommand
 {
-    protected ChangeLogScmResult executeCvsCommand( Commandline cl, Date startDate, Date
endDate, String datePattern )
+    protected ChangeLogScmResult executeCvsCommand( Commandline cl, Date startDate, Date
endDate,
+                                                    ScmVersion startVersion, ScmVersion endVersion,
String datePattern )
         throws ScmException
     {
         CvsLogListener logListener = new CvsLogListener();
@@ -75,8 +77,11 @@
                                            false );
         }
 
-        return new ChangeLogScmResult( cl.toString(),
-                                       new ChangeLogSet( consumer.getModifications(), startDate,
endDate ) );
+        ChangeLogSet changeLogSet = new ChangeLogSet( consumer.getModifications(), startDate,
endDate );
+        changeLogSet.setStartVersion( startVersion );
+        changeLogSet.setEndVersion( endVersion );
+
+        return new ChangeLogScmResult( cl.toString(), changeLogSet );
     }
 
     protected void addDateRangeParameter( Commandline cl, String dateRange )



Mime
View raw message