maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r757015 - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src: main/java/org/apache/maven/scm/provider/perforce/command/changelog/ test/java/org/apache/maven/scm/provider/perforce/command/changelog/
Date Sat, 21 Mar 2009 20:55:44 GMT
Author: olamy
Date: Sat Mar 21 20:55:43 2009
New Revision: 757015

URL: http://svn.apache.org/viewvc?rev=757015&view=rev
Log:
[SCM-332] Perforce provider give one changeset entry for each file
Submitted by Jean-Pierre Matsumoto


Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogConsumer.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogConsumerTest.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogConsumer.java?rev=757015&r1=757014&r2=757015&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogConsumer.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogConsumer.java
Sat Mar 21 20:55:43 2009
@@ -21,6 +21,7 @@
 
 import org.apache.maven.scm.ChangeFile;
 import org.apache.maven.scm.ChangeSet;
+import org.apache.maven.scm.ScmException;
 import org.apache.maven.scm.log.ScmLogger;
 import org.apache.maven.scm.util.AbstractConsumer;
 import org.apache.regexp.RE;
@@ -28,6 +29,7 @@
 
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -133,9 +135,37 @@
     //
     // ----------------------------------------------------------------------
 
-    public List getModifications()
+    public List getModifications() throws ScmException
     {
-        return entries;
+    	
+    	// Here there are one entry for each couple (changelist,file). We merge
+    	// entries to have only one entry per changelist
+    	
+    	// Date > ChangeSet
+        HashMap groupedEntries = new HashMap();
+        for ( int i = 0; i < entries.size(); i++ )
+        {
+            ChangeSet cs = (ChangeSet) entries.get( i );
+            ChangeSet hit = (ChangeSet) groupedEntries.get( cs.getDate() );
+            if ( hit != null )
+            {
+                if ( cs.getFiles().size() != 1 )
+                {
+                    throw new ScmException( "Merge of entries failed. Bad entry size: " +
cs.getFiles().size() );
+                }
+                hit.addFile( (ChangeFile) cs.getFiles().get( 0 ) );
+            }
+            else
+            {
+                groupedEntries.put( cs.getDate(), cs );
+            }
+        }
+
+        ArrayList result = new ArrayList();
+        result.addAll( groupedEntries.values() );
+
+        return result;
+    	
     }
 
     // ----------------------------------------------------------------------

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogConsumerTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogConsumerTest.java?rev=757015&r1=757014&r2=757015&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogConsumerTest.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/changelog/PerforceChangeLogConsumerTest.java
Sat Mar 21 20:55:43 2009
@@ -55,8 +55,8 @@
         }
 
         ArrayList entries = new ArrayList( consumer.getModifications() );
-        assertEquals( "Wrong number of entries returned", 9, entries.size() );
-        ChangeSet entry = (ChangeSet) entries.get( 0 );
+        assertEquals( "Wrong number of entries returned", 7, entries.size() );
+        ChangeSet entry = (ChangeSet) entries.get(2);
         assertEquals( "jim", entry.getAuthor() );
         assertEquals( "demo/demo.c", ( (ChangeFile) entry.getFiles().get( 0 ) ).getName()
);
         assertEquals( "2003-10-01", entry.getDateFormatted() );



Mime
View raw message